示例#1
0
    void OnGUI()
    {
        GUILayout.Space(15);

        // An example of an action class with a GUI attached, we are calling the
        // Gui component of the action. No need to worry about the logic part as it is already
        // wired up with the view part by definition
        _radialSpreadAction.OnGUI();

        GUILayout.Space(15);

        // Example of action's which don't have GUI/View's attached
        if (GUILayout.Button("Some Action Class", GUILayout.ExpandWidth(true)))
        {
            SomeActionClass someAction = this.GetInstance <SomeActionClass>(_actionRecorder);

            _actionResult = _actionRecorder.PerformAction(someAction); //Action's supply back an enumerable result?
        }

        if (GUILayout.Button("Fail Undo Action", GUILayout.ExpandWidth(true)))
        {
            FailUndoAction action = this.GetInstance <FailUndoAction>(_actionRecorder);

            _actionResult = _actionRecorder.PerformAction(action);
        }

        if (GUILayout.Button("Fail Redo Action", GUILayout.ExpandWidth(true)))
        {
            FailRedoAction action = this.GetInstance <FailRedoAction>(_actionRecorder);

            _actionResult = _actionRecorder.PerformAction(action);
        }



        // -----------------------
        // Display Built in UndoRedoGUI in the Action Recorder
        _actionRecorder.UndoRedoGUI(this.position);
    }
    private void OnEventRaised()
    {
        //Debug.Log("Event raised");

        // First clear the response object
        ActionRecorder.Response.Clear();

        //Check if we are in Edit mode, if we aren't send back a failed response object
        if (!ActionRecorder.InEditMode(ref ActionRecorder.Response))
        {
            return;
        }

        // Get new model instance
        _actionLogic = ActionLogicBase.GetInstance <T>(ActionRecorder);

        // Passing Data from View to Model
        ViewToModelParams(_actionLogic);

        // Perform the action
        ActionRecorder.PerformAction(_actionLogic);
    }