using MotionFramework; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; /// /// 点击背包中的物品显示物体 /// public class DisplayKnapsackObjects : MonoBehaviour { public GameObject[] Tool; /// /// 放回背包按钮 /// public Button PutBack; /// /// 梯子动画 /// public SkinnedMeshRenderer LadderSkr; // Start is called before the first frame update void Start() { MotionEngine.GetModule().OnStringEvent += HandleStringEvent; 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); } if (Tool[6].activeInHierarchy) { Tool[6].gameObject.SetActive(false); } }); } 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); } if (message == "验电笔") { Tool[3].gameObject.SetActive(true); } if (message == "螺丝刀") { Tool[4].gameObject.SetActive(true); } if (message == "绝缘胶带") { Tool[5].gameObject.SetActive(true); } if (message == "l型集中器") { Tool[6].gameObject.SetActive(true); } Debug.Log("Received message: " + message); } }