コード例 #1
0
        private void DisplayPreview(SimpleAnimation animation)
        {
            UnityEngine.Object animatedObject = animation.GetAnimatedObject(false);
            if (animatedObject == null)
            {
                return;
            }
            int oldIndentLevel = UnityEditor.EditorGUI.indentLevel;

            UnityEditor.EditorGUI.indentLevel = 1;
            EditorGUILayout.BeginHorizontal();
            float oldLabelWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 75;
            EditorGUILayout.LabelField("Animation preview");
            EditorGUIUtility.labelWidth = oldLabelWidth;
            EditorGUI.BeginChangeCheck();
            float animProgression = animation.progress;

            // Glitch to fix: The slider is not set to the proper value by default (after opening the scene, all the sliders are at 0, not at the proper value)
            //animProgression = EditorGUILayout.Slider(animProgression, animation.mirror?1f:0f, animation.mirror?0f:1f);
            animProgression = EditorGUILayout.Slider(animProgression, 0f, 1f);
            if (EditorGUI.EndChangeCheck())
            {
                if (animatedObject != null)
                {
                    Undo.RecordObject(animatedObject, "Changed animation progress (Animated Object)");
                }
                Undo.RecordObject(simpleAnimationsManager, "Changed animation progress (Simple Animation Manager)");
                animation.SetProgress(animProgression);
            }
            EditorGUILayout.EndHorizontal();
            UnityEditor.EditorGUI.indentLevel = oldIndentLevel;
        }
コード例 #2
0
 /// <summary>
 /// Sets the animation at the given progress.
 /// </summary>
 /// <param name="animation">The animation in the 'SimpleAnimationsManager' that is wanted to be updated with the new progress.</param>
 /// <param name="progress">The progress of the animation [0,1]</param>
 public void SetProgress(SimpleAnimation animation, float progress)
 {
     animation.SetProgress(progress);
 }