Синтаксис:
Используется csharp
using UnityEngine.UI;
public class Console : MonoBehaviour
{
private Text field;
void Start()
{
field = GetComponentInChildren<Text>();
}
void OnGUI()
{
if (Event.current.Equals(Event.KeyboardEvent(KeyCode.Return.ToString())))
{
WriteConsole(field.text);
}
}
void WriteConsole(string Command)
{
switch (Command)
{
case "Kill":
KillPlayer();
break;
default:
print(Command);
break;
}
}
void KillPlayer()
{
Spawn.Players[0].GetComponent<IsDead>().Dead();
}
}
public class Console : MonoBehaviour
{
private Text field;
void Start()
{
field = GetComponentInChildren<Text>();
}
void OnGUI()
{
if (Event.current.Equals(Event.KeyboardEvent(KeyCode.Return.ToString())))
{
WriteConsole(field.text);
}
}
void WriteConsole(string Command)
{
switch (Command)
{
case "Kill":
KillPlayer();
break;
default:
print(Command);
break;
}
}
void KillPlayer()
{
Spawn.Players[0].GetComponent<IsDead>().Dead();
}
}
И возникла проблема, я не вижу что вводится в поле inputfield хотя в дочернем объекте text введеный текст отображается.