Beispiel #1
0
    /// <summary>
    /// A template can change since it was selected.
    /// This method refreshes the UI to reflect any changes
    /// while keeping any variable overrides that the use has made
    /// </summary>
    void RefreshTemplate()
    {
        if (fsmTemplate == null || Application.isPlaying)
        {
            return;
        }

        // we want to keep the existing overrides
        // so we copy the current FsmVariables

        var currentValues = new FsmVariables(fsmComponent.Fsm.Variables);

        // then we update the template

        fsmComponent.SetFsmTemplate(fsmTemplate);

        // finally we apply the original overrides back to the new FsmVariables

        fsmComponent.Fsm.Variables.OverrideVariableValues(currentValues);

        // and refresh the UI

        BuildFsmVariableList();

        FsmEditor.RefreshInspector();
    }
    private void SelectTemplate(FsmTemplate template)
    {
        if (template == fsmComponent.FsmTemplate)
        {
            return; // don't want to lose overridden variables
        }

        UndoUtility.RegisterUndo(fsmComponent, "PlayMaker : Set FSM Template");
        fsmComponent.SetFsmTemplate(template);
        fsmTemplate = template;
        BuildFsmVariableList();
        EditorUtility.SetDirty(fsmComponent);

        FsmEditor.RefreshInspector(); // Keep Playmaker Editor in sync
    }