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); }
public void CheckResultFrames() { LimitedAnimationController controller = new LimitedAnimationController(true, numFramesToHold: 3, frameOffset: 0); Assert.AreEqual(0, controller.Apply(1)); Assert.AreEqual(0, controller.Apply(2)); Assert.AreEqual(3, controller.Apply(3)); controller.SetFrameOffset(2); Assert.AreEqual(2, controller.Apply(1)); Assert.AreEqual(2, controller.Apply(2)); Assert.AreEqual(2, controller.Apply(3)); Assert.AreEqual(2, controller.Apply(4)); Assert.AreEqual(5, controller.Apply(5)); }
//---------------------------------------------------------------------------------------------------------------------- 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; }