using AX.InputSystem; using AX.MessageSystem; using System.Collections; using System.Collections.Generic; using UnityEngine; public class CloneRanging : MonoBehaviour { public GameObject clonePrefab;//绑定的预制体 public CloneObjType cloneObjType;//克隆类型 protected int number = 0;//计数 public string ResourcesName; [HideInInspector] public GameObject cloneObj;//克隆出的物体 void OnEnable() { MessageDispatcher.AddListener("CLONE_COMMAND", Execute); } void OnDisable() { MessageDispatcher.RemoveListener("CLONE_COMMAND", Execute); } void OnDestroy() { MessageDispatcher.RemoveListener("CLONE_COMMAND", Execute); } private void Execute(IMessage obj) { var gameObjID = (long)obj.Sender; var data = ((CloneCmdArgs)obj.Data); if (data.cloneObjType == cloneObjType) { var hitPoint = data.hitPos; var HitID = data.gameObjID; this.GetComponent().DrawLineOperation(hitPoint, HitID, gameObjID); } else { this.GetComponent().ResetData(); } } }