using MotionFramework; using System.Collections; using System.Collections.Generic; using DefaultNamespace.ProcessMode; using UnityEngine; using UnityEngine.UI; /// /// 点击背包中的物品显示物体 /// public class DisplayKnapsackObjects : MonoBehaviour { public GameObject[] Tool; public GameObject ui; public Button processBt; /// /// 放回背包按钮 /// public Button PutBack; /// /// 收回工具按钮 /// public Button[] RetractToolBtn; // Start is called before the first frame update void Start() { MotionEngine.GetModule().OnStringEvent += HandleStringEvent; MotionEngine.GetModule().OnUIEvent += UIEvent; PutBack.onClick.AddListener(() => { //梯子 if (Tool[0].activeInHierarchy) { Tool[0].gameObject.SetActive(false); Ladder.instance.closed(); } //工作证 if (Tool[1].activeInHierarchy) { Tool[1].gameObject.SetActive(false); } //剥线钳 if (Tool[2].activeInHierarchy) { Tool[2].gameObject.SetActive(false); } //验电笔 if (Tool[3].activeInHierarchy) { Tool[3].gameObject.SetActive(false); } //螺丝刀 if (Tool[4].activeInHierarchy) { Tool[4].gameObject.SetActive(false); } //绝缘胶带 if (Tool[5].activeInHierarchy) { Tool[5].gameObject.SetActive(false); } //l型集中器 if (Tool[6].activeInHierarchy) { Tool[6].gameObject.SetActive(false); } }); processBt.onClick.AddListener(delegate { ui.SetActive(false); }); } private void UIEvent() { ui.SetActive(true); } private void HandleStringEvent(string message) { if (message == "梯子") { Tool[0].gameObject.SetActive(true); Ladder.instance.Init(); } if (message == "工作证") { Tool[1].gameObject.SetActive(true); } if (message == "剥线钳") { Tool[2].gameObject.SetActive(true); RetractToolBtn[0].gameObject.SetActive(true); } if (message == "验电笔") { RetractToolBtn[1].gameObject.SetActive(true); Tool[3].gameObject.SetActive(true); } if (message == "螺丝刀") { RetractToolBtn[2].gameObject.SetActive(true); Tool[4].gameObject.SetActive(true); } if (message == "绝缘胶带") { RetractToolBtn[3].gameObject.SetActive(true); Tool[5].gameObject.SetActive(true); } if (message == "l型集中器") { RetractToolBtn[4].gameObject.SetActive(true); Tool[6].gameObject.SetActive(true); } if (message == "盒装封印") { RetractToolBtn[5].gameObject.SetActive(true); Tool[7].gameObject.SetActive(true); } Debug.Log("Received message: " + message); } }