Example #1
0
        /************************************************************************************************************************/

        /// <summary>
        /// Draws the <see cref="Animator.cullingMode"/> field.
        /// </summary>
        private void DoCullingModeGUI()
        {
            if (_CullingMode == null)
            {
                return;
            }

            var label = AnimancerGUI.TempContent("Culling Mode",
                                                 "Controls what is updated when the object has been culled (when it is not being rendered by a Camera)");

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(_CullingMode, label);

            if (EditorGUI.EndChangeCheck())
            {
                _OnEndGUI += () =>
                {
                    for (int i = 0; i < Targets.Length; i++)
                    {
                        var animator = _Animators[i];
                        if (animator != null)
                        {
                            AnimancerEditorUtilities.Invoke(animator, "OnCullingModeChanged");
                        }
                    }
                };
            }
        }
Example #2
0
        private void DoRootMotionGUI()
        {
            if (_RootMotion == null)
            {
                return;
            }

            var text = AnimancerGUI.GetNarrowText("Apply Root Motion");

            var animator = _Animators[0];

            if (_Animators.Length == 1 && (bool)AnimancerEditorUtilities.Invoke(animator, "get_supportsOnAnimatorMove"))
            {
                EditorGUILayout.LabelField(text, "Handled by Script");
            }
            else
            {
                EditorGUILayout.PropertyField(_RootMotion, AnimancerGUI.TempContent(text,
                                                                                    "If enabled, the Animator will automatically move the object using the root motion from the animations"));

                if (Event.current.type == EventType.Layout)
                {
                    _IsRootPositionOrRotationControlledByCurves =
                        (bool)AnimancerEditorUtilities.Invoke(animator, "get_isRootPositionOrRotationControlledByCurves");
                }

                if (_IsRootPositionOrRotationControlledByCurves && !_RootMotion.boolValue)
                {
                    EditorGUILayout.HelpBox("Root position or rotation are controlled by curves", MessageType.Info, true);
                }
            }
        }
Example #3
0
        /************************************************************************************************************************/

        /// <summary>
        /// Draws the <see cref="Animator.updateMode"/> field with any appropriate warnings.
        /// </summary>
        private void DoUpdateModeGUI(bool showWithoutWarning)
        {
            if (_UpdateMode == null)
            {
                return;
            }

            var label = AnimancerGUI.TempContent("Update Mode",
                                                 "Controls when and how often the animations are updated");

            var initialUpdateMode = Targets[0].InitialUpdateMode;
            var updateMode        = (AnimatorUpdateMode)_UpdateMode.intValue;

            EditorGUI.BeginChangeCheck();

            if (!EditorApplication.isPlaying || !AnimancerPlayable.HasChangedToOrFromAnimatePhysics(initialUpdateMode, updateMode))
            {
                if (showWithoutWarning)
                {
                    EditorGUILayout.PropertyField(_UpdateMode, label);
                }
            }
            else
            {
                GUILayout.BeginHorizontal();

                var color = GUI.color;
                GUI.color = AnimancerGUI.WarningFieldColor;
                EditorGUILayout.PropertyField(_UpdateMode, label);
                GUI.color = color;

                label = AnimancerGUI.TempContent("Revert", "Revert to initial mode");
                if (GUILayout.Button(label, EditorStyles.miniButton, AnimancerGUI.DontExpandWidth))
                {
                    _UpdateMode.intValue = (int)initialUpdateMode.Value;
                }

                GUILayout.EndHorizontal();

                EditorGUILayout.HelpBox(
                    "Changing to or from AnimatePhysics mode at runtime has no effect when using the" +
                    " Playables API. It will continue using the original mode it had on startup.",
                    MessageType.Warning);

                if (AnimancerGUI.TryUseClickEventInLastRect())
                {
                    EditorUtility.OpenWithDefaultApp(Strings.DocsURLs.UpdateModes);
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                _OnEndGUI += () =>
                {
                    for (int i = 0; i < _Animators.Length; i++)
                    {
                        var animator = _Animators[i];
                        if (animator != null)
                        {
                            AnimancerEditorUtilities.Invoke(animator, "OnUpdateModeChanged");
                        }
                    }
                };
            }
        }