public void ValueCopy(MovingMapObject moving) { points = moving.points; playOneShot = moving.playOneShot; movingType = moving.movingType; movingTime = moving.movingTime; waitTime = moving.waitTime; isMoveWithPlayer = moving.isMoveWithPlayer; }
void OnSceneGUI() { if (SceneManager.GetActiveScene().buildIndex == 2) { targetObject = (MovingMapObject)target; grid = GameObject.Find("MapCreator").GetComponent <Grid>(); if (targetObject.points != null) { var polyLinePoints = new List <Vector3>(targetObject.points.Count); for (int i = 0; i < targetObject.points.Count; i++) { targetObject.points[i].point = GetGirdPosition(targetObject.points[i].point); targetObject.points[i].point = Handles.PositionHandle(targetObject.points[i].point, Quaternion.identity); polyLinePoints.Add(targetObject.points[i].point); } Handles.DrawAAPolyLine(polyLinePoints.ToArray()); EditorUtility.SetDirty(targetObject); } Handles.BeginGUI(); if (GUILayout.Button("포인트 추가", GUILayout.Width(80f))) { Undo.RecordObject(targetObject, "add points"); targetObject.points.Add(new MovingPointData() { point = new Vector3(targetObject.transform.position.x, targetObject.transform.position.y, targetObject.transform.position.z - 1f), disableCollision = false }); } if (GUILayout.Button("포인트 없애기", GUILayout.Width(80f))) { if (targetObject.points.Count > 0) { Undo.RecordObject(targetObject, "remove points"); targetObject.points.RemoveAt(targetObject.points.Count - 1); } } if (GUILayout.Button("포인트 위치 초기화", GUILayout.Width(115f))) { for (int i = 0; i < targetObject.points.Count; ++i) { targetObject.points[i].point = targetObject.transform.position; } } GUILayout.BeginHorizontal(); //GUILayout.Box("그리드 모드"); //grid.IsGridMove = EditorGUILayout.Toggle(grid.IsGridMove); GUILayout.EndHorizontal(); Handles.EndGUI(); } }
private void CreateNewPrefab() { Transform[] childs = rootObject.GetComponentsInChildren <Transform>(); List <Transform> childList = new List <Transform>(); childList.AddRange(childs); childList.Remove(rootObject.transform); // 본인은 삭제 List <Transform> deleteList = new List <Transform>(); foreach (var child in childList) { if (!child.parent.Equals(rootObject.transform)) { deleteList.Add(child); } } foreach (var child in deleteList) { childList.Remove(child); } // 부모가 rootobject가아니면 맵 오브젝트의 하위 자식. 필요없음 foreach (var orgObject in childList) { GameObject createObj = null; for (int i = 0; i < mapObjectList.Length; ++i) { if (orgObject.name.Contains(mapObjectList[i].name)) { createObj = mapObjectList[i]; break; } } if (createObj == null) { Debug.Log("createObj is null"); } GameObject createedObject = (GameObject)PrefabUtility.InstantiatePrefab(createObj); createedObject.transform.parent = rootObject.transform; createedObject.transform.position = orgObject.transform.position; Trap spike = createedObject.GetComponent <Trap>(); MovingMapObject moving = createedObject.GetComponent <MovingMapObject>(); if (spike != null) { spike.ValueCopy(orgObject.GetComponent <Trap>()); } if (moving != null) { moving.ValueCopy(orgObject.GetComponent <MovingMapObject>()); } } }