public void AutoUpdateFields()
        {
            LimitedAnimationController controller = new LimitedAnimationController(true, numFramesToHold: 3, frameOffset: 0);

            AssertLimitedAnimationControllerFields(controller, 3, 0);

            controller.SetFrameOffset(2);
            AssertLimitedAnimationControllerFields(controller, 3, 2);

            controller.SetNumFramesToHold(2);
            AssertLimitedAnimationControllerFields(controller, 2, 1);
        }
Exemplo n.º 2
0
//----------------------------------------------------------------------------------------------------------------------    
    
    internal static bool DrawLimitedAnimationGUI(LimitedAnimationController ctrl, 
        Object target, SceneCachePlayer sc) 
    {
        bool         changed   = false;
        const string UNDO_TEXT = "SceneCache: Limited Animation";
        
        //Limited Animation
        changed |= EditorGUIDrawerUtility.DrawUndoableGUI(target, UNDO_TEXT,
            guiFunc: () => (EditorGUILayout.Toggle("Limited Animation", ctrl.IsEnabled())),
            updateFunc: (bool limitedAnimation) => {
                ctrl.SetEnabled(limitedAnimation);
                SceneCachePlayerEditorUtility.RefreshSceneCache(sc);
            });

        ++EditorGUI.indentLevel;
        using (new EditorGUI.DisabledScope(!ctrl.IsEnabled())) {
            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(target, UNDO_TEXT,
                guiFunc: () => (
                    EditorGUILayout.IntField("Num Frames to Hold", ctrl.GetNumFramesToHold())
                ),
                updateFunc: (int frames) => {
                    ctrl.SetNumFramesToHold(frames);
                    SceneCachePlayerEditorUtility.RefreshSceneCache(sc);
                });
            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(target, UNDO_TEXT,
                guiFunc: () => (
                    EditorGUILayout.IntField("Frame Offset", ctrl.GetFrameOffset())
                ),
                updateFunc: (int offset) => {
                    ctrl.SetFrameOffset(offset);
                    SceneCachePlayerEditorUtility.RefreshSceneCache(sc);
                });
        }

        --EditorGUI.indentLevel;

        EditorGUILayout.Space();
        return changed;
    }