internal static T Create <T>(StateMachineAsset machine, string name = null) where T : BaseStateAsset { var state = ScriptableObject.CreateInstance <T>(); state.hideFlags = HideFlags.HideInHierarchy; state._stateMachine = machine; state.name = name ?? "State"; return(state); }
void Initialize() { _stateMachine = _stateMachine ?? StateMachineAsset.GetStateMachineAsset(); _stateNodes = _stateNodes ?? new List <StateNode>(); _transitionNodes = _transitionNodes ?? new List <TransitionNode>(); if (_stateDictionary == null) { _stateDictionary = new Dictionary <int, StateNode>(StateNodes.Count); foreach (var node in StateNodes) { _stateDictionary.Add(node.Id, node); } } }
void OnGUI() { // Initialize if (metaData == null) { metaData = StateMachineAsset.GetStateMachineAsset().Metadata; } if (!initDone) { InitStyles(); } // Draw environment (inclusing zoom and position) BeginMainWindow(metaData.WindowOffset, metaData.WindowZoomPivot, metaData.WindowZoom); DrawGrid(displayArea, 20, 0.2f, Color.gray); DrawGrid(displayArea, 100, 0.4f, Color.gray); DrawLinkLines(); BeginWindows(); foreach (var node in metaData.StateNodes) { node.Center = GUI.Window(node.Id, node.Window, DrawNode, "", _nodeStyles.GetStyle(node)).center; } EndWindows(); DrawMouseLine(); EndMainWindow(); // Handle input (mouse and keyboard) HandleEvents(); // Draw UI (top bars and instructions) GUILayout.BeginVertical(); DrawToolBar(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Middle button to pan and zoom.")); GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent("Right click to create transitions")); GUILayout.EndHorizontal(); GUILayout.EndVertical(); EditorUtility.SetDirty(metaData); }