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.
75 lines
2.2 KiB
75 lines
2.2 KiB
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<CameraManager>(); |
|
} |
|
/*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<PolygonController>().Show(); |
|
//DistanceSetting(); |
|
} |
|
else |
|
{ |
|
GetComponent<PolygonController>().Hide(); |
|
} |
|
} |
|
private void ClearSelect(IMessage obj) |
|
{ |
|
GetComponent<PolygonController>().Hide(); |
|
} |
|
|
|
private void AllSetFalse() |
|
{ |
|
GameObject PolyVerticeFather = GameObject.Find("Canvas/PolyVerticeFather"); |
|
foreach (Transform child in PolyVerticeFather.transform) |
|
{ |
|
child.gameObject.SetActive(false); |
|
} |
|
} |
|
}
|
|
|