Синтаксис:
Используется csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ButtonInputConnect : MonoBehaviour
{
public Sprite RectangleBlue, RectangleGreen;
public InputField input;
public Text fText;
private int num;
void Awake()
{
input = GameObject.Find("InputField").GetComponent<InputField>();
}
public void GetInput(string guess)
{
input.text = "";
}
void OnMouseDown()
{
GetComponent<SpriteRenderer>().sprite = RectangleGreen;
}
private void OnMouseUp()
{
GetComponent<SpriteRenderer>().sprite = RectangleBlue;
}
void OnMouseUpAsButton()
{
switch (gameObject.name)
{
num = int.Parse(input.text);
case "rectbutton":
{
if (num == 12345)
{
fText.text = "password1 enter correct";
Application.LoadLevel("controll");
}
else if (num != 12345)
{
fText.text = "password1 doesn't enter correct";
if (num == 54321)
{
fText.text = "password2 enter correct";
Application.LoadLevel("controll");
}
else if (num != 54321)
{
fText.text = "password2 doesn't enter correct";
}
}
}
break;
}
}
}
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ButtonInputConnect : MonoBehaviour
{
public Sprite RectangleBlue, RectangleGreen;
public InputField input;
public Text fText;
private int num;
void Awake()
{
input = GameObject.Find("InputField").GetComponent<InputField>();
}
public void GetInput(string guess)
{
input.text = "";
}
void OnMouseDown()
{
GetComponent<SpriteRenderer>().sprite = RectangleGreen;
}
private void OnMouseUp()
{
GetComponent<SpriteRenderer>().sprite = RectangleBlue;
}
void OnMouseUpAsButton()
{
switch (gameObject.name)
{
num = int.Parse(input.text);
case "rectbutton":
{
if (num == 12345)
{
fText.text = "password1 enter correct";
Application.LoadLevel("controll");
}
else if (num != 12345)
{
fText.text = "password1 doesn't enter correct";
if (num == 54321)
{
fText.text = "password2 enter correct";
Application.LoadLevel("controll");
}
else if (num != 54321)
{
fText.text = "password2 doesn't enter correct";
}
}
}
break;
}
}
}
https://drive.google.com/open?id=1YUTmULUsaraSHevewhuIETMwDLWrG6Az