private void Initialize(PlainStateMachineBuilder builder) { if (builder == null) { return; } _builder = builder; backgroundTexture = CreateBackgroundTexture(backgroundColor); titleContent = new GUIContent("Plain State Machine Builder Window"); _nodes = new List <StateNode>(); _transitions = new List <TransitionConnection>(); _gridDrawer = new BackgroundGridDrawer(); _windowEventHandler = new WindowEventHandler(this); _nodeEventHandler = new StateNodeEventHandler(this); _transitionConnectionEventHandler = new TransitionConnectionEventHandler(this); _metadata = new PlainStateMachineBuilderMetadata(); _inspectorDrawer = new InspectorDrawer(); LoadBuilder(); _builderSettingsDrawer = new PlainStateMachineBuilderSettingsDrawer(_builder); _builderSettingsDrawer.OnStateIdTypeChanged += OnStateIdTypeChanged; _builderSettingsDrawer.OnTriggerTypeChanged += OnTriggerTypeChanged; Undo.undoRedoPerformed += Reload; }
private void LoadStates() { var states = _builder.GetStates(); if (states != null) { _metadata = _builder.GetMetadata <PlainStateMachineBuilderMetadata>(MetadataKey); var initialStateId = _builder.GetInitialStateId(); for (int i = 0; i < states.Length; i++) { var current = states[i]; for (int j = 0; j < _metadata.StateNodesMetadata.Count; j++) { if (PlainStateMachineBuilderHelper.AreEquals(_metadata.StateNodesMetadata[j].StateId, current.StateId)) { AddNodeFrom(states[i], _metadata.StateNodesMetadata[j]); break; } } } var initialNode = StateNodeOf(initialStateId); if (initialNode != null) { SetInitialStateNode(initialNode); } } }