using HighlightPlus; using QFramework; using QFramework.Example; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class DeviceItem : MonoBehaviour { public XMLTool.Device device; public TipItem tipItem; public void Init(XMLTool.Device device) { this.device = device; if (string.IsNullOrEmpty(device.HighColor) == false) { var effect = gameObject.GetOrAddComponent(); gameObject.GetOrAddComponent(); effect.outlineColor = Color.green; StringEventSystem.Global.Register(Global.HighLightTrigger, OnHighLightTriggerEvent).UnRegisterWhenGameObjectDestroyed(gameObject); } if (device.MeshCollider) { gameObject.GetOrAddComponent(); } else if (string.IsNullOrEmpty(device.BoxColliderSize) == false) { BoxCollider box = gameObject.GetOrAddComponent(); box.size = Utility.GetVector3FromStrArray(device.BoxColliderSize); if (string.IsNullOrEmpty(device.BoxColliderCenter) == false) { box.center = Utility.GetVector3FromStrArray(device.BoxColliderCenter); } } if (string.IsNullOrEmpty(device.Tip) == false) { tipItem = gameObject.GetOrAddComponent(); tipItem.Set(device.Tip); } } private void OnHighLightTriggerEvent(string[] obj) { if (obj.Length > 0) { bool isActive = true; bool.TryParse(obj[0], out isActive); if (obj.Length == 1 || (obj.Length > 1 && obj[1] == device.Name)) { gameObject.GetComponent().enabled = isActive; } } } private void OnMouseUpAsButton() { var effect = gameObject.GetComponent(); if (effect != null) { effect.highlighted = false; } } }