private static void OnEndNewTransitionEvent() { if (StateTransitionGUI.startNewTranstion) { Event e = Event.current; if (e.type == EventType.MouseMove) { StateTransitionGUI.toPosition = StateMachineUtils.MousePos2MachineGridPos(e.mousePosition); e.Use(); } if (e.isMouse) { if (e.button == 0) { foreach (var item in MachineStateGUIDataControl.allMachineStateGUI) { if (StateMachineUtils.MachineGridRectContainsMousePos(e.mousePosition, item.GUIRect)) { MachineDataController.AddNewTransitionGUI(StateTransitionGUI.startPositionMs, item.state); break; } } StateTransitionGUI.startNewTranstion = false; e.Use(); StateMachineEditorWindow.Instance.wantsMouseMove = false; } else if (e.button == 1) { StateTransitionGUI.startNewTranstion = false; e.Use(); StateMachineEditorWindow.Instance.wantsMouseMove = false; } } } }
private static void AddNewMachineStateGUIOnMouseMenu(object mousePos) { Vector2 mPos = (Vector2)mousePos; mPos = StateMachineUtils.MousePos2MachineGridPos(mPos); MachineDataController.AddNewMachineStateGUI(mPos); Debug.Log("AddNewMachineStateGUIOnMouseMenu :" + mPos); }
void CreateItem(MessageString ms) { LogicObject lo = JsonUtils.JsonToClassOrStruct <LogicObject>(ms.value); MachineStateGUI msg = MachineDataController.AddNewMachineStateGUI(new Vector2(500, 450), lo.name, false); LogicObjectBehaviour be = new LogicObjectBehaviour(); be.logicObj = lo; msg.state.stateBaseBehaviours.Add(be); msg.name = lo.name; LogicSystemEditorWindow.AddLogicObject(lo); }
public static void DeleteSelectObjet() { if (selectObject != null) { if (selectObject is MachineStateGUI) { MachineDataController.DeleteMachineStateGUI(((MachineStateGUI)selectObject)); } else if (selectObject is StateTransitionArrowLine) { MachineDataController.DeleteStateTransitionArrowLine(((StateTransitionArrowLine)selectObject)); } } }
public override void OnInspectorGUI() { targetObj = (LogicObjectBehaviour)target; logicObj = targetObj.logicObj; GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("ID :" + logicObj.id); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); //logicObj.name = EditorDrawGUIUtil.DrawBaseValue ("Name", logicObj.name).ToString(); if (LogicSystemEditorWindow.data != null) { isStartModel = LogicSystemEditorWindow.data.startId == logicObj.id; } stateGUI.NormalStateColor = isStartModel ? UnityEditor.Graphs.Styles.Color.Yellow : UnityEditor.Graphs.Styles.Color.Gray; if (!isStartModel) { bool oldState = logicObj.isSupportAlwaysActive; logicObj.isSupportAlwaysActive = (bool)EditorDrawGUIUtil.DrawBaseValue("是否支持永远激活状态", logicObj.isSupportAlwaysActive); if (oldState != logicObj.isSupportAlwaysActive && logicObj.isSupportAlwaysActive) { foreach (var item in stateGUI.FromArrowLines) { MachineDataController.DeleteStateTransitionArrowLine(item); } } if (logicObj.isSupportAlwaysActive) { stateGUI.NormalStateColor = UnityEditor.Graphs.Styles.Color.Red; } DrawNameAndClassListGUI("事件:", logicObj.events, LogicComponentType.Event); DrawNameAndClassListGUI("条件:", logicObj.conditions, LogicComponentType.Condition); } DrawNameAndClassListGUI("动作:", logicObj.actions, LogicComponentType.Action); string tempStr = ""; foreach (int ch in logicObj.childObjects) { tempStr += ch + ","; } GUILayout.Label("Child ID:" + tempStr); GUILayout.Label("Pos:" + targetObj.logicObj.editorPos); GUILayout.Space(6); SaveToBackupGUI(); }
void OnDestroy() { OnDrawLeftPartGUI = null; OnDrawTopToolBarGUI = null; OnCreateMachineStateGUI = null; OnDeleteMachineStateGUI = null; OnAddStateTransition = null; OnDeleteStateTransition = null; OnDeleteStateTransitionArrowLine = null; MachineDataController.ClearAllData(); if (OnDestroyWindow != null) { OnDestroyWindow(); } }
//public EditorWindow animatorWindow; static void Init() { data = LogicObjectDataController.GetDataFromFile(logicDataName); if (data.logicObjs.Count == 0) { LogicObject r = CreateLogicObject("开始", new Vector2(500, 400)); data.startId = r.id; } Dictionary <int, MachineStateGUI> allState = new Dictionary <int, MachineStateGUI>(); foreach (var item in data.logicObjs) { MachineStateGUI msg = MachineDataController.AddNewMachineStateGUI(item.editorPos, item.name); LogicObjectBehaviour be = new LogicObjectBehaviour(); msg.state.stateBaseBehaviours.Add(be); be.state = msg.state; be.logicObj = item; bool isStartModel = LogicSystemEditorWindow.data.startId == item.id; msg.NormalStateColor = isStartModel ? UnityEditor.Graphs.Styles.Color.Yellow : UnityEditor.Graphs.Styles.Color.Gray; if (!isStartModel && item.isSupportAlwaysActive) { msg.NormalStateColor = UnityEditor.Graphs.Styles.Color.Red; } allState.Add(item.id, msg); } foreach (var item in data.logicObjs) { foreach (var child in item.childObjects) { MachineDataController.AddNewTransitionGUI(allState[item.id].state, allState[child].state); } } StateMachineEditorWindow.OnDrawLeftPartGUI = OnGUI; StateMachineEditorWindow.OnCreateMachineStateGUI = CreateNewModel; internalValueTypeList.Add(typeof(string).FullName); internalValueTypeList.Add(typeof(int).FullName); internalValueTypeList.Add(typeof(float).FullName); internalValueTypeList.Add(typeof(Vector2).FullName); internalValueTypeList.Add(typeof(Vector3).FullName); internalValueTypeList.Add(typeof(bool).FullName); }
protected override void OnInspectorGUI() { // base.OnInspectorGUI(); GUILayout.BeginVertical("box"); for (int i = 0; i < line.transitions.Count; i++) { StateTransition st = line.transitions[i]; MachineStateGUI mag0 = MachineStateGUIDataControl.GetMachineStateGUI(st.fromState); MachineStateGUI mag1 = MachineStateGUIDataControl.GetMachineStateGUI(st.toState); GUILayout.BeginHorizontal("box"); GUILayout.Label(mag0.name + " -> " + mag1.name); if (line.transitions.Count > 1 && GUILayout.Button("-")) { MachineDataController.DeleteStateTransition(line, st); return; } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }