/* * public static void AddConditionalCallback(object obj) * { * Debug.Log("Add conditional."); * * }*/ /// <summary> /// adds a state. /// </summary> /// <param name="obj"></param> public static void CreateStateContextCallback(object obj) { //make the passed object to a string //string clb = obj.ToString(); editorDisplayWindowsState.menuData menuData = (editorDisplayWindowsState.menuData)obj; if (/*clb.Equals("addState") && */ GameObject != null) { SaveAllVisualStateMetaData(); if (StateList.Count == 0) { Debug.LogError("StateList is Empty so you can't create a state."); return; } //string stateName = "aMech" + GameObject.name + "State" + utlDataAndFile.GetCode(StateList.Count); int codeIndex = StateList.Count; string stateName = "aMech" + GameObject.name + "State" + utlDataAndFile.GetCode(codeIndex); while (!CreateAndAddStateCodeToProject(GameObject, stateName, menuData.m_FileAndPath, menuData.m_ReplaceName, false)) { codeIndex += 1; stateName = "aMech" + GameObject.name + "State" + utlDataAndFile.GetCode(codeIndex); //sanity check if (codeIndex > 10000) { return; } } string fileAndPath = ""; fileAndPath = utlDataAndFile.FindPathAndFileByClassName(stateName); stateWindowsNode windowNode = new stateWindowsNode(stateEditorUtils.StateList.Count); Vector3 transMousePos = new Vector3(); transMousePos = stateEditorUtils.TranslationMtx.UnTransform(MousePos); windowNode.Set(fileAndPath, stateName, stateName, transMousePos.x, transMousePos.y, 150, 80); StateList.Add(windowNode); SaveStateWindowsNodeData(fileAndPath, stateName, (int)MousePos.x, (int)MousePos.y, 150, 80); fileAndPath = utlDataAndFile.FindPathAndFileByClassName(StateMachineName); SaveStateInfo(StateMachineName, GameObject.name); AddStateCodeToStateMachineCode(fileAndPath, stateName); } }
public static stateWindowsNode CreateStateWindowsNode(string typeName) { stateWindowsNode winNode = new stateWindowsNode(StateList.Count); winNode.ClassName = typeName; float x = 0; float y = 0; float width = 0; float height = 0; string winName = typeName; // TextAsset text = Resources.Load(typeName+".cs") as TextAsset; string strBuff = ""; string fileName = ""; fileName = utlDataAndFile.FindPathAndFileByClassName(typeName, false); strBuff = utlDataAndFile.LoadTextFromFile(fileName); string[] words = strBuff.Split(new char[] { '<', '>' }); for (int i = 0; i < words.Length; i++) { if (words[i] == "alias") { winName = words[i + 1]; } if (words[i] == "posX") { x = Convert.ToSingle(words[i + 1]); } if (words[i] == "posY") { y = Convert.ToSingle(words[i + 1]); } if (words[i] == "sizeX") { width = Convert.ToSingle(words[i + 1]); } if (words[i] == "sizeY") { height = Convert.ToSingle(words[i + 1]); } } winNode.Set(fileName, typeName, winName, x, y, width, height); return(winNode); }