using System.Collections; using System.Collections.Generic; using UnityEngine; public class CloneSplash : CloneSingleObj { private GameObject ClonedObj; // Use this for initialization void Start() { } // Update is called once per frame void Update() { } protected override void Clone() { var hitPoint = data.hitPos; Vector3 clonedObjPos = new Vector3(hitPoint.x, hitPoint.y + Height, hitPoint.z); ClonedObj = EntitiesManager.Instance.CreateObj(clonePrefab, clonedObjPos, transform, gameObjID); //ClonedObj.name = cloneObjType.ToString() + number++; ClonedObj.name = gameObjID.ToString();//名字即ID //clonedObj.name = CloneObjectTool.Instance().getCloneObjectName(cloneObjType); ////有需要的类型赋值头顶名 //string topname = CloneObjName.Instance.GetCloneNameByType(cloneObjType); SelectedObjs.gameObjs.Add(ClonedObj); //设置克隆物体所在楼层属性,属性从点击的对象上获取 var hitObj = EntitiesManager.Instance.GetEntityByID(data.gameObjID); CloneGameObjInfo floorMsg = hitObj.GetComponent(); CloneGameObjInfo objMsg = ClonedObj.GetComponent(); objMsg.gameObjType = cloneObjType; objMsg.buildNum = floorMsg.buildNum; objMsg.floorNum = floorMsg.floorNum; objMsg.interlayerNum = floorMsg.interlayerNum; //float dis = 0; //RaycastHit[] AllHit = Physics.RaycastAll(hitPoint, Vector3.down, 100f, LayerMask.NameToLayer("SoliderRoad")); //foreach (RaycastHit hit in AllHit) //{ // Debug.Log(hit.transform.name + "down"); // if (hit.transform.name.ToUpper().Contains("DIMIAN")) // { // dis = Vector3.Distance(hit.point, hitPoint); // Debug.Log(dis); // } //} ////调节大小 //ClonedObj.transform.localScale = new Vector3(1, dis / 9.2f, 1); //ClonedObj.transform.Translate(Vector3.down * (dis / 2 - 0.4f)); Vector3 hitobjVec = hitObj.transform/*.parent*/.position; //Debug.Log(hitObj.transform.parent.name); ClonedObj.transform.LookAt(new Vector3(hitobjVec.x, ClonedObj.transform.position.y, hitobjVec.z)); ClonedObj.transform.Rotate(new Vector3(0, -180, 0)); SetCloneGameObject(ClonedObj); AddRecordEventClone(ClonedObj.transform);//测试 } public override void SetCloneGameObject(GameObject obj) { obj.AddComponent(); obj.AddComponent(); } }