using System.Collections; using System.Collections.Generic; using UnityEngine; using AX.MessageSystem; using AX.InputSystem; using System; public class PolygonSelect : MonoBehaviour { public bool selected;//是否被选中 void OnEnable() { MessageDispatcher.AddListener("RADIO_SELECTED_COMMAND", RadioSelect);//单选选中处理 MessageDispatcher.AddListener("CANCEL_SELECTED_COMMAND", ClearSelect);//ESC取消选中处理 } void OnDisable() { MessageDispatcher.RemoveListener("RADIO_SELECTED_COMMAND", RadioSelect); MessageDispatcher.RemoveListener("CANCEL_SELECTED_COMMAND", ClearSelect);//ESC取消选中处理 } void OnDestroy() { MessageDispatcher.RemoveListener("RADIO_SELECTED_COMMAND", RadioSelect); MessageDispatcher.RemoveListener("CANCEL_SELECTED_COMMAND", ClearSelect);//ESC取消选中处理 } public float distance; private CameraManager CameraManager;//摄像机控制脚本 //private DistanceCmdArgs SetArg;//设置摄像机的参数类 public void Start() { CameraManager = GameObject.Find("Main Camera").GetComponent(); } /*public void DistanceSetting() { SetArg = new DistanceCmdArgs { TargetPosition = transform.Find("info").position, CameraDistance = distance }; CameraManager.DistanceSetting(SetArg); }*/ private void RadioSelect(IMessage obj) { var gameObjID = (long)obj.Sender; var hitObj = EntitiesManager.Instance.GetEntityByID(gameObjID); if (hitObj == this.gameObject) { GetComponent().Show(); //DistanceSetting(); } else { GetComponent().Hide(); } } private void ClearSelect(IMessage obj) { GetComponent().Hide(); } private void AllSetFalse() { GameObject PolyVerticeFather = GameObject.Find("Canvas/PolyVerticeFather"); foreach (Transform child in PolyVerticeFather.transform) { child.gameObject.SetActive(false); } } }