private void LoadStates()
        {
            var states = _builder.GetStates();

            if (states != null)
            {
                _metadata = _builder.GetMetadata <HierarchicalStateMachineBuilderMetadata>(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 (HierarchicalStateMachineBuilderHelper.AreEquals(_metadata.StateNodesMetadata[j].StateId, current.StateId))
                        {
                            AddNodeFrom(states[i], _metadata.StateNodesMetadata[j]);
                            break;
                        }
                    }
                }

                var initialNode = StateNodeOf(initialStateId);

                if (initialNode != null)
                {
                    SetInitialStateNode(initialNode);
                }
            }
        }
        private void Load()
        {
            titleContent = new GUIContent("Hierarchical State Machine Builder Window");

            _nodes             = new List <StateNode>();
            _transitions       = new List <TransitionConnection>();
            _parentConnections = new List <ParentConnection>();

            _windowEventHandler = new WindowEventHandler(this);
            _nodeEventHandler   = new StateNodeEventHandler(this);
            _transitionConnectionEventHandler = new TransitionConnectionEventHandler(this);
            _parentConnectionEventHandler     = new ParentConnectionEventHandler(this);
            _metadata        = new HierarchicalStateMachineBuilderMetadata();
            _inspectorDrawer = new InspectorDrawer();

            LoadBuilder();

            _builderSettingsDrawer = new BuilderSettingsDrawer(_builder);
            _builderSettingsDrawer.OnStateIdTypeChanged += OnStateIdTypeChanged;
            _builderSettingsDrawer.OnTriggerTypeChanged += OnTriggerTypeChanged;

            Undo.undoRedoPerformed += Reload;
        }