void DrawCurrentRunningState(artConfigurationData configData) { if (!Application.isPlaying) { return; } ArtimechEditor theStateMachineEditor = (ArtimechEditor)m_State.m_UnityObject; GameObject gameObj = null; iMachineBase stateMachine; if (theStateMachineEditor.SelectedObj is GameObject) { gameObj = (GameObject)theStateMachineEditor.SelectedObj; stateMachine = gameObj.GetComponent <iMachineBase>(); } else { stateMachine = (iMachineBase)theStateMachineEditor.SelectedObj; } string currentClassName = stateMachine.GetCurrentState().GetType().ToString(); currentClassName = utlDataAndFile.GetAfter(currentClassName, "."); if (currentClassName == this.ClassName) { Rect drawRect = new Rect(WinRect.x - configData.DebugBoxSize, WinRect.y - configData.DebugBoxSize, WinRect.width + (configData.DebugBoxSize * 2), WinRect.height + (configData.DebugBoxSize * 2)); artGUIUtils.DrawRect(drawRect, configData.DebugBoxLineSize, configData.DebugBoxLineColor, configData.DebugBoxColor); } //theStateMachineEditor.EditorRepaint(); }
/// <summary> /// Test conditionals are placed here. /// </summary> /// <param name="state"></param> /// <returns>true or false depending if transition conditions are met.</returns> public override string UpdateConditionalTest(baseState state) { string strOut = null; ArtimechEditor theStateMachineEditor = (ArtimechEditor)state.m_UnityObject; if (theStateMachineEditor.SelectedObj == null) { return(null); } bool abool = theStateMachineEditor.SelectedObj is GameObject; if (!abool) { return(null); } GameObject gmObject = (GameObject)theStateMachineEditor.SelectedObj; iMachineBase[] machines = gmObject.GetComponents <iMachineBase>(); if (machines.Length == 1) { strOut = m_ChangeStateName; } return(strOut); }
/// <summary> /// When the state becomes active Enter() is called once. /// </summary> public override void Enter() { ArtimechEditor theStateMachineEditor = (ArtimechEditor)GetScriptableObject; theStateMachineEditor.DrawToolBarBool = true; theStateMachineEditor.Repaint(); base.Enter(); }
/// <summary> /// Test conditionals are placed here. /// </summary> /// <param name="state"></param> /// <returns>true or false depending if transition conditions are met.</returns> public override string UpdateConditionalTest(baseState state) { ArtimechEditor theStateMachineEditor = (ArtimechEditor)state.m_UnityObject; if (theStateMachineEditor.CreateStateBool) { return(m_ChangeStateName); } return(null); }
/// <summary> /// Update /// </summary> public void Update(EditorWindow eWindow) { m_ArtimechEditor = (ArtimechEditor)eWindow; m_WinRect.x = eWindow.position.width * 0.5f; m_WinRect.width = eWindow.position.width * 0.65f; //m_WinRect.height = Screen.height * 0.25f; m_WinRect.height = 140; m_WinRect.x = (eWindow.position.width * 0.5f) - (m_WinRect.width * 0.5f); m_WinRect.y = (eWindow.position.height * 0.5f) - (m_WinRect.height * 0.5f); GUI.Window(m_Id, WinRect, Draw, m_Title); }
/// <summary> /// Test conditionals are placed here. /// </summary> /// <param name="state"></param> /// <returns>true or false depending if transition conditions are met.</returns> public override string UpdateConditionalTest(baseState state) { string strOut = null; ArtimechEditor theStateMachineEditor = (ArtimechEditor)state.m_UnityObject; if (theStateMachineEditor.GetResizeNode() != null) { strOut = m_ChangeStateName; } return(strOut); }
/// <summary> /// Test conditionals are placed here. /// </summary> /// <param name="state"></param> /// <returns>true or false depending if transition conditions are met.</returns> public override string UpdateConditionalTest(baseState state) { string strOut = null; ArtimechEditor theStateMachineEditor = (ArtimechEditor)state.m_UnityObject; if (theStateMachineEditor.SelectedObj != theStateMachineEditor.WasSelectedObj) { strOut = m_ChangeStateName; } return(strOut); }
void SetMachineScript() { ArtimechEditor theStateMachineEditor = (ArtimechEditor)m_State.m_UnityObject; for (int i = 0; i < m_MachineSelectionBools.Length; i++) { if (m_MachineSelectionBools[i] == true) { theStateMachineEditor.MachineScript = m_Machines[i]; return; } } }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <returns></returns> protected artVisualStateNode FindStateWindowsNodeByName(string name) { ArtimechEditor theStateMachineEditor = (ArtimechEditor)GetScriptableObject; artVisualStateNode node = null; for (int i = 0; i < theStateMachineEditor.VisualStateNodes.Count; i++) { if (theStateMachineEditor.VisualStateNodes[i].ClassName == name) { return(theStateMachineEditor.VisualStateNodes[i]); } } return(node); }
/// <summary> /// Test conditionals are placed here. /// </summary> /// <param name="state"></param> /// <returns>true or false depending if transition conditions are met.</returns> public override string UpdateConditionalTest(baseState state) { string strOut = null; //check to see if the selected object has changed. ArtimechEditor editor = (ArtimechEditor)state.m_UnityObject; if (editor.SelectedObj == null) { strOut = m_ChangeStateName; } return(strOut); }
protected artVisualStateNode CreateVisualStateNode(string typeName) { ArtimechEditor theStateMachineEditor = (ArtimechEditor)GetScriptableObject; artVisualStateNode visualNode = new artVisualStateNode(theStateMachineEditor.VisualStateNodes.Count + 10000); visualNode.ClassName = typeName; float posX = 0; float posY = 0; float width = 0; float height = 0; string winName = typeName; string strBuff = ""; string fileName = ""; //fileName = utlDataAndFile.FindPathAndFileByClassName(typeName, false); fileName = utlDataAndFile.FindPathAndFileByClassNameByDirectoryArray(typeName, theStateMachineEditor.ConfigData.GetRefactorAndConstructionPaths()); 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") { posX = Convert.ToSingle(words[i + 1]); } if (words[i] == "posY") { posY = 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]); } } visualNode.Set(fileName, typeName, winName, posX, posY, width, height); return(visualNode); }
/// <summary> /// Test conditionals are placed here. /// </summary> /// <param name="state"></param> /// <returns>true or false depending if transition conditions are met.</returns> public override string UpdateConditionalTest(baseState state) { string strOut = null; ArtimechEditor theStateMachineEditor = (ArtimechEditor)state.m_UnityObject; GameObject gmObject = (GameObject)theStateMachineEditor.SelectedObj; if (gmObject.GetComponent <iMachineBase>() == null) { strOut = m_ChangeStateName; } return(strOut); }
void ThreadProc() { while (true) { // if (m_EditorWindow != null) // m_EditorWindow.Repaint(); m_RotAngle += 3.0f; if (m_EditorWindow != null) { ArtimechEditor theScript = (ArtimechEditor)m_EditorWindow; theScript.RepaintOnUpdate = true; } Thread.Sleep(20); } }
/// <summary> /// Test conditionals are placed here. /// </summary> /// <param name="state"></param> /// <returns>true or false depending if transition conditions are met.</returns> public override string UpdateConditionalTest(baseState state) { string strOut = null; ArtimechEditor theStateMachineEditor = (ArtimechEditor)state.m_UnityObject; for (int i = 0; i < theStateMachineEditor.VisualStateNodes.Count; i++) { if (theStateMachineEditor.VisualStateNodes[i].MoveBool) { strOut = m_ChangeStateName; return(strOut); } } return(strOut); }
void AddConfigureMenuEntries(GenericMenu toolsMenu, ArtimechEditor editor) { //EditorGUI.BeginDisabledGroup(SelectedObj == null ? true : false); // EditorGUI.BeginDisabledGroup(true); artConfigurationData[] data = utlDataAndFile.GetAllInstances <artConfigurationData>(); for (int i = 0; i < data.Length; i++) { //new GenericMenu.MenuFunction2(this.ToggleLogStackTraces), current //if (SelectedObj == null) // toolsMenu.AddDisabledItem(new GUIContent("Configure/" + data[i].name)); //else //toolsMenu.AddItem(new GUIContent("Configure/" + data[i].name, "Select a configuartion file to use."), data[i] == editor.ConfigData ? true : false, new GenericMenu.MenuFunction2(editor.OnConfigure), data[i]); toolsMenu.AddItem(new GUIContent(data[i].name, "Select a configuartion file to use."), data[i] == editor.ConfigData ? true : false, new GenericMenu.MenuFunction2(editor.OnConfigure), data[i]); } // EditorGUI.EndDisabledGroup(); }
new public void Draw(int id) { m_MousePos = Event.current.mousePosition; Rect rect = new Rect(0, 0, WinRect.width, WinRect.height); EditorGUI.DrawRect(rect, m_WindowColor); ArtimechEditor theStateMachineEditor = (ArtimechEditor)m_State.m_UnityObject; stateEditorDrawUtils.DrawGridBackground(theStateMachineEditor.ConfigData); for (int i = 0; i < theStateMachineEditor.VisualStateNodes.Count; i++) { theStateMachineEditor.VisualStateNodes[i].Update(m_State, theStateMachineEditor.TransMtx, theStateMachineEditor.ConfigData); } }
/// <summary> /// /// </summary> /// <param name="fileName"></param> protected void CreateVisualStateNodes(string fileName) { string strBuff = utlDataAndFile.LoadTextFromFile(fileName); this.PopulateStateStrings(strBuff); ArtimechEditor theStateMachineEditor = (ArtimechEditor)GetScriptableObject; for (int i = 0; i < m_ListOfStateStringsInMachine.Count; i++) { artVisualStateNode node = CreateVisualStateNode(m_ListOfStateStringsInMachine[i]); theStateMachineEditor.VisualStateNodes.Add(node); } for (int i = 0; i < theStateMachineEditor.VisualStateNodes.Count; i++) { string stateFileName = utlDataAndFile.FindPathAndFileByClassName(theStateMachineEditor.VisualStateNodes[i].ClassName, false); string buffer = utlDataAndFile.LoadTextFromFile(stateFileName); PopulateLinkedConditionStates(theStateMachineEditor.VisualStateNodes[i], buffer); } }
public bool AddStateCodeToStateMachineCode(string fileAndPath, string stateName) { string strBuff = ""; strBuff = utlDataAndFile.LoadTextFromFile(fileAndPath); ArtimechEditor theScript = (ArtimechEditor)GetScriptableObject; if (strBuff == null || strBuff.Length == 0) { return(false); } string modStr = ""; string objTypeStr = ""; if (theScript.SelectedObj is GameObject) { objTypeStr = "(this.gameObject),"; } else { objTypeStr = "(this),"; } string insertString = "\n AddState(new " + stateName + objTypeStr + "\"" + stateName + "\"" + ");"; modStr = utlDataAndFile.InsertInFrontOf(strBuff, "<ArtiMechStates>", insertString); utlDataAndFile.SaveTextToFile(fileAndPath, modStr); return(true); }
/// <summary> /// Draws the "Display" window of this window. Everything is active. /// </summary> /// <param name="id"></param> void DrawNodeWindow(int id, artConfigurationData configData) { if (Event.current.button == 0 && Event.current.isMouse && ResizeBodyHover) { } if (Event.current.button == 1 && Event.current.isMouse) { //if (m_State != null && m_State is editorDisplayWindowsState) ArtimechEditor theStateMachineEditor = (ArtimechEditor)m_State.m_UnityObject; if (IsWithinUsingPanZoomTransform(Event.current.mousePosition, theStateMachineEditor.TransMtx)) { artDisplayWindowsBaseState dState = (artDisplayWindowsBaseState)m_State; if (dState != null && Event.current.type == EventType.MouseDown && dState.DrawMenuBool) { GenericMenu menu = new GenericMenu(); for (int i = 0; i < configData.ConditionalCopyInfo.Length; i++) { menu.AddItem(new GUIContent("Add Conditional/" + configData.ConditionalCopyInfo[i].m_MenuString), false, dState.AddConditionalCallback, new conditionalSelection(this, i)); } /* menu.AddItem(new GUIContent("Add Conditional/Subscription Conditional"), * false, * dState.AddConditionalCallback, * new editorDisplayWindowsState.menuData("Assets/Scripts/Common/statemachine/state_examples/stateCondSubExample.cs", "stateCondSubExample"));*/ menu.AddSeparator(""); menu.AddItem(new GUIContent("Edit Script"), false, dState.EditScriptCallback, this); menu.AddSeparator(""); menu.AddItem(new GUIContent("Refactor State Class"), false, this.RefactorClassCallback, this); //stateEditorUtils.SelectedNode = this; menu.ShowAsContext(); Event.current.Use(); } //Debug.Log("--------------------------------------"); return; } } //draws background and outline. //int lineWidth = 2; /* Color lineColor = new Color(0, 0.3f, 0, 1); * Color backGroundColor = new Color(0.0f, 0.8f, 0.8f, 1.0f);*/ Rect rect = new Rect(m_WinRect.x, m_WinRect.y, WinRect.width, WinRect.height); artGUIUtils.DrawRect(rect, configData.WindowOutlineLineWidth, configData.WindowLineColor, configData.StateWindowColor); DrawStateContent(configData); //draw the exit button in the title bar Color shadowCol = new Color(0, 0, 0, 0.2f); float xOffset = 8.0f; float yOffset = 9.0f; float boxSize = 8; //create the close button rectangle m_CloseButtonRect = new Rect(WinRect.x + WinRect.width - (xOffset + (boxSize * 0.5f)), WinRect.y + yOffset - (boxSize * 0.5f), boxSize, boxSize); if (m_CloseButtonRect.Contains(Event.current.mousePosition)) { artGUIUtils.DrawRect(m_CloseButtonRect, 2, Color.black, Color.red); if (Event.current.button == 0 && Event.current.isMouse) { ArtimechEditor theStateMachineEditor = (ArtimechEditor)m_State.m_UnityObject; theStateMachineEditor.DeleteStateBool = true; theStateMachineEditor.DeleteStateClass = ClassName; } } else { artGUIUtils.DrawRect(m_CloseButtonRect, 2, Color.black, Color.clear); } artGUIUtils.DrawX(new Vector3(WinRect.x + WinRect.width - (xOffset * 0.95f), WinRect.y + yOffset * 0.95f, 0), boxSize - 1, boxSize - 1, 2, shadowCol); artGUIUtils.DrawX(new Vector3(WinRect.x + WinRect.width - (xOffset * 1.0f), WinRect.y + yOffset * 1.0f, 0), boxSize - 1, boxSize - 1, 1, Color.black); //draw the resizer const float initSizerSize = 15; float sizerSize = initSizerSize; artGUIUtils.DrawWindowSizer(new Vector3(WinRect.x + WinRect.width - 2, WinRect.y + this.WinRect.height - 2, 0), sizerSize - 1, sizerSize - 3, 2, Color.grey); sizerSize = 10; artGUIUtils.DrawWindowSizer(new Vector3(WinRect.x + WinRect.width - 2, WinRect.y + this.WinRect.height - 2, 0), sizerSize - 1, sizerSize - 3, 2, Color.grey); sizerSize = 5; artGUIUtils.DrawWindowSizer(new Vector3(WinRect.x + WinRect.width - 2, WinRect.y + this.WinRect.height - 2, 0), sizerSize - 1, sizerSize - 3, 2, Color.grey); const float titleHeight = 15; //create the main body rectangle. m_MainBodyRectA = new Rect(WinRect.x, WinRect.y + titleHeight, WinRect.width, WinRect.height - initSizerSize - titleHeight); //m_MainBodyRectB = new Rect(WinRect.x, WinRect.y + titleHeight, WinRect.width - initSizerSize, WinRect.y - WinRect.height); //main body of the window EditorGUIUtility.AddCursorRect(m_MainBodyRectA, MouseCursor.MoveArrow); // EditorGUIUtility.AddCursorRect(m_MainBodyRectB, MouseCursor.MoveArrow); //resize m_ResizeBodyRect = new Rect(new Rect(WinRect.x + WinRect.width - initSizerSize, WinRect.y + WinRect.height - initSizerSize, initSizerSize, initSizerSize)); EditorGUIUtility.AddCursorRect(m_ResizeBodyRect, MouseCursor.ResizeUpLeft); //title const float rightMarginSize = 15; m_TitleRect = new Rect(WinRect.x, WinRect.y, WinRect.width - rightMarginSize, titleHeight); EditorGUIUtility.AddCursorRect(m_TitleRect, MouseCursor.Text); //close box EditorGUIUtility.AddCursorRect(m_CloseButtonRect, MouseCursor.ArrowMinus); //DrawStateContent(); UpdateMouseHover(Event.current.mousePosition); //artGUIUtils.DrawX(m_LinePos, 10, 10, 1, Color.black); //GUI.DragWindow(); }
new public void Draw(int id) { GUI.depth = 0; var TextStyle = new GUIStyle(); TextStyle.normal.textColor = m_FontColor; TextStyle.fontSize = m_FontSize; //Color backroundColor = new Color(1, 1, 1, 0.8f); // Color backroundColor = new Color(1, 1, 1, 0.8f); Rect rect = new Rect(0, 18, WinRect.width, WinRect.height); EditorGUI.DrawRect(rect, m_WindowColor); GUILayout.Space(10); GUILayout.BeginHorizontal(""); GUILayout.Space(10); GUILayout.Label(m_Message, TextStyle); GUILayout.Space(10); GUILayout.EndHorizontal(); GUILayout.Space(10); m_State.EntryString = EditorGUILayout.TextField(EntryLabel, m_State.EntryString); ArtimechEditor theStateMachineEditor = (ArtimechEditor)m_State.m_UnityObject; theStateMachineEditor.RefactorName = m_State.EntryString; GUILayout.Space(10); GUILayout.BeginHorizontal(""); GUILayout.Space(m_ButtonSideSpacing); if (m_CancelPrompt) { if (GUILayout.Button("Cancel")) { m_State.CancelBool = true; } GUILayout.Space(m_ButtonMiddleSpacing); } if (m_OkPrompt) { if (m_State.EntryString.Length > 0) { if (GUILayout.Button("Ok")) { m_State.OkBool = true; // SetMachineScript(); } } else { EditorGUI.BeginDisabledGroup(true); GUILayout.Button("Ok"); EditorGUI.EndDisabledGroup(); } } GUILayout.Space(m_ButtonSideSpacing); GUILayout.EndHorizontal(); GUI.DrawTexture(new Rect(m_TexturePosAndSize.x, m_TexturePosAndSize.y, m_TexturePosAndSize.z, m_TexturePosAndSize.w), m_ExclamtionTexture); //GUILayout.EndHorizontal(); // GUI.DrawTexture(new Rect(m_TexturePosAndSize.x, m_TexturePosAndSize.y, m_TexturePosAndSize.z, m_TexturePosAndSize.w), m_ExclamtionTexture); //GUI.DragWindow(); }