public static void SaveData(string dataName, string pathName, LogicObjectContainer data) { string path = LogicSystemEditorTools.GetPath(dataName, pathName); string content = JsonUtils.ClassOrStructToJson(data); FileUtils.CreateTextFile(path, content); if (!ResourcePathManager.ContainsFileName(dataName)) { ResourcePathManager.Clear(); } }
//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); }