public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.PropertyField(propId, new GUIContent("阻挡门 ID")); EditorGUILayout.PropertyField(propType, new GUIContent("门类型")); EditorGUILayout.PropertyField(propWidth, new GUIContent("门宽度")); EditorGUILayout.PropertyField(propHeight, new GUIContent("门高度")); //EditorGUILayout.PropertyField(propState, new GUIContent("传送门状态(0闭1开)")); EditorGUILayout.PropertyField(propState, new GUIContent("门初始状态(0关1开)")); MapDoorView view = (MapDoorView)target; if (view.gameObject.transform.hasChanged) { Vector3 pos = view.gameObject.transform.localPosition; IntPoint logic = PathUtilEdit.Real2Logic(pos); Quaternion rotat = view.gameObject.transform.localRotation; if (logic.x != propX.intValue || logic.y != propY.intValue) { pos = PathUtilEdit.LogicCenter2Real(logic); //Debug.Log("npc pos changed:" + logic.x + " != " + propX.intValue + "," + logic.y+" != "+propY.intValue); if (EditorData.terrainMan != null) { pos.y = EditorData.terrainMan.GetHeight(pos.x, pos.z); view.gameObject.transform.localPosition = pos; } } propX.intValue = logic.x; propY.intValue = logic.y; propEulerangles.stringValue = rotat.eulerAngles.x.ToString() + "," + rotat.eulerAngles.y.ToString() + "," + rotat.eulerAngles.z.ToString(); } EditorGUILayout.LabelField("X:\t" + propX.intValue); EditorGUILayout.LabelField("Y:\t" + propY.intValue); serializedObject.ApplyModifiedProperties(); }
public GameObject AddDoor(MapDoor door, Vector3 pos) { Object prefab = EditorTool.LoadAssetBundle("model/sence_chuansong.unity3d"); if (prefab == null) { Debug.LogError("阻挡门 资源找不到:model/sence_chuansong.unity3d"); return(null); } string subpath = "door"; Transform parentTrans = getRoot().FindChild(subpath); if (parentTrans == null) { GameObject subroot = new GameObject(subpath); subroot.transform.SetParent(getRoot()); parentTrans = subroot.transform; } string nodeName = "door_" + door.id; GameObject npcObj = (GameObject)GameObject.Instantiate(prefab); npcObj.name = nodeName; npcObj.transform.SetParent(parentTrans); npcObj.transform.localPosition = pos; if (door.eulerangles != null) { string[] arr = door.eulerangles.Split(','); if (arr.Length == 3) { //npcObj.transform.Rotate(float.Parse(arr[0]), float.Parse(arr[1]), float.Parse(arr[2])); npcObj.transform.localRotation = Quaternion.Euler(float.Parse(arr[0]), float.Parse(arr[1]), float.Parse(arr[2])); } } MapDoorView view = npcObj.AddComponent <MapDoorView>(); view.data = door; foreach (ParticleSystem ps in npcObj.GetComponentsInChildren <ParticleSystem>()) { ps.Play(true); } door.target = npcObj; return(npcObj); }