You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.6 KiB
64 lines
1.6 KiB
using UnityEngine; |
|
using AX.MessageSystem; |
|
using System; |
|
|
|
public class TestUI : MonoBehaviour |
|
{ |
|
private bool enableTimer = false; |
|
private float time = 0.0f; |
|
|
|
void OnGUI() |
|
{ |
|
if (GUI.Button(new Rect(0, 0, 200, 50), "重置")) |
|
{ |
|
MessageDispatcher.SendMessage("EVERYONE"); |
|
time = 0.0f; |
|
} |
|
|
|
if (GUI.Button(new Rect(0, 50, 200, 50), "前面的 CUBE 变红")) |
|
{ |
|
MessageDispatcher.SendMessage("LEAD_RED", Color.red); |
|
} |
|
|
|
if (GUI.Button(new Rect(0, 100, 200, 50), "所有的 CUBE 变蓝")) |
|
{ |
|
MessageDispatcher.SendMessage("ALL_BLUE", Color.blue, "CUBE"); |
|
} |
|
|
|
if (GUI.Button(new Rect(0, 150, 200, 50), "所有的对象变绿")) |
|
{ |
|
MessageDispatcher.SendMessage("EVERYONE", Color.green); |
|
} |
|
|
|
if (GUI.Button(new Rect(0, 200, 200, 50), "2 秒钟后,所有的对象变绿")) |
|
{ |
|
MessageDispatcher.SendMessage("EVERYONE", Color.green, 2.0f); |
|
|
|
enableTimer = true; |
|
time = 0.0f; |
|
} |
|
|
|
GUI.Label(new Rect(Screen.width / 2 - 100, 10, 220, 40), "计时: " + time + " 秒"); |
|
} |
|
|
|
void Update() |
|
{ |
|
if (enableTimer) |
|
{ |
|
time += Time.deltaTime; |
|
|
|
if (time >= 2.0f) |
|
enableTimer = false; |
|
} |
|
|
|
if (Input.GetKeyDown(KeyCode.Space)) |
|
{ |
|
MessageDispatcher.SendMessage("OPEN", (object)"NavImage", "CUBE"); |
|
} |
|
|
|
if (Input.GetKeyDown(KeyCode.S)) |
|
{ |
|
MessageDispatcher.SendMessage("CLOSE", (object)"NavImage", "CUBE"); |
|
} |
|
} |
|
}
|
|
|