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 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); }