public override void OnInspectorGUI()
        {
            bool     flag1  = this.targets.Length > 1;
            Animator target = this.target as Animator;

            this.serializedObject.UpdateIfDirtyOrScript();
            this.UpdateShowOptions();
            EditorGUI.BeginChangeCheck();
            RuntimeAnimatorController animatorController = EditorGUILayout.ObjectField("Controller", (UnityEngine.Object)target.runtimeAnimatorController, typeof(RuntimeAnimatorController), false, new GUILayoutOption[0]) as RuntimeAnimatorController;
            bool flag2 = EditorGUI.EndChangeCheck();

            EditorGUILayout.PropertyField(this.m_Avatar);
            if (target.supportsOnAnimatorMove && !flag1)
            {
                EditorGUILayout.LabelField("Apply Root Motion", "Handled by Script", new GUILayoutOption[0]);
            }
            else
            {
                EditorGUILayout.PropertyField(this.m_ApplyRootMotion, AnimatorInspector.styles.applyRootMotion, new GUILayoutOption[0]);
                if (Event.current.type == EventType.Layout)
                {
                    this.m_IsRootPositionOrRotationControlledByCurves = target.isRootPositionOrRotationControlledByCurves;
                }
                if (!this.m_ApplyRootMotion.boolValue && this.m_IsRootPositionOrRotationControlledByCurves)
                {
                    EditorGUILayout.HelpBox("Root position or rotation are controlled by curves", MessageType.Info, true);
                }
            }
            target.updateMode = (AnimatorUpdateMode)EditorGUILayout.EnumPopup("Update Mode", (Enum)target.updateMode, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_CullingMode, AnimatorInspector.styles.cullingMode, new GUILayoutOption[0]);
            if (!flag1)
            {
                EditorGUILayout.HelpBox(target.GetStats(), MessageType.Info, true);
            }
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowWarningMessage.faded))
            {
                EditorGUILayout.HelpBox(this.WarningMessage, MessageType.Warning, true);
            }
            EditorGUILayout.EndFadeGroup();
            this.serializedObject.ApplyModifiedProperties();
            if (!flag2)
            {
                return;
            }
            Undo.RecordObject((UnityEngine.Object)target, "Changed AnimatorController");
            target.runtimeAnimatorController = animatorController;
            AnimationWindowUtility.ControllerChanged();
        }
        public override void OnInspectorGUI()
        {
            bool     flag   = base.targets.Length > 1;
            Animator target = this.target as Animator;

            base.serializedObject.UpdateIfDirtyOrScript();
            this.UpdateShowOptions();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(this.m_Controller, new GUILayoutOption[0]);
            bool flag2 = EditorGUI.EndChangeCheck();

            EditorGUILayout.PropertyField(this.m_Avatar, new GUILayoutOption[0]);
            if (target.supportsOnAnimatorMove && !flag)
            {
                EditorGUILayout.LabelField("Apply Root Motion", "Handled by Script", new GUILayoutOption[0]);
            }
            else
            {
                EditorGUILayout.PropertyField(this.m_ApplyRootMotion, styles.applyRootMotion, new GUILayoutOption[0]);
                if (Event.current.type == EventType.Layout)
                {
                    this.m_IsRootPositionOrRotationControlledByCurves = target.isRootPositionOrRotationControlledByCurves;
                }
                if (!this.m_ApplyRootMotion.boolValue && this.m_IsRootPositionOrRotationControlledByCurves)
                {
                    EditorGUILayout.HelpBox("Root position or rotation are controlled by curves", MessageType.Info, true);
                }
            }
            EditorGUILayout.PropertyField(this.m_UpdateMode, styles.updateMode, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_CullingMode, styles.cullingMode, new GUILayoutOption[0]);
            if (!flag)
            {
                EditorGUILayout.HelpBox(target.GetStats(), MessageType.Info, true);
            }
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowWarningMessage.faded))
            {
                EditorGUILayout.HelpBox(this.WarningMessage, MessageType.Warning, true);
            }
            EditorGUILayout.EndFadeGroup();
            base.serializedObject.ApplyModifiedProperties();
            if (flag2)
            {
                AnimationWindowUtility.ControllerChanged();
            }
        }
Beispiel #3
0
        public override void OnInspectorGUI()
        {
            bool     flag     = base.targets.Length > 1;
            Animator animator = base.target as Animator;

            base.serializedObject.UpdateIfRequiredOrScript();
            this.UpdateShowOptions();
            EditorGUI.BeginChangeCheck();
            RuntimeAnimatorController runtimeAnimatorController = EditorGUILayout.ObjectField("Controller", animator.runtimeAnimatorController, typeof(RuntimeAnimatorController), false, new GUILayoutOption[0]) as RuntimeAnimatorController;

            if (EditorGUI.EndChangeCheck())
            {
                UnityEngine.Object[] targets = base.targets;
                for (int i = 0; i < targets.Length; i++)
                {
                    Animator animator2 = (Animator)targets[i];
                    Undo.RecordObject(animator2, "Changed AnimatorController");
                    animator2.runtimeAnimatorController = runtimeAnimatorController;
                }
                AnimationWindowUtility.ControllerChanged();
            }
            EditorGUILayout.PropertyField(this.m_Avatar, new GUILayoutOption[0]);
            if (animator.supportsOnAnimatorMove && !flag)
            {
                EditorGUILayout.LabelField("Apply Root Motion", "Handled by Script", new GUILayoutOption[0]);
            }
            else
            {
                EditorGUILayout.PropertyField(this.m_ApplyRootMotion, AnimatorInspector.styles.applyRootMotion, new GUILayoutOption[0]);
                if (Event.current.type == EventType.Layout)
                {
                    this.m_IsRootPositionOrRotationControlledByCurves = animator.isRootPositionOrRotationControlledByCurves;
                }
                if (!this.m_ApplyRootMotion.boolValue && this.m_IsRootPositionOrRotationControlledByCurves)
                {
                    EditorGUILayout.HelpBox("Root position or rotation are controlled by curves", MessageType.Info, true);
                }
            }
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(this.m_UpdateMode, AnimatorInspector.styles.updateMode, new GUILayoutOption[0]);
            bool flag2 = EditorGUI.EndChangeCheck();

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(this.m_CullingMode, AnimatorInspector.styles.cullingMode, new GUILayoutOption[0]);
            bool flag3 = EditorGUI.EndChangeCheck();

            if (!flag)
            {
                EditorGUILayout.HelpBox(animator.GetStats(), MessageType.Info, true);
            }
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowWarningMessage.faded))
            {
                EditorGUILayout.HelpBox(this.WarningMessage, MessageType.Warning, true);
            }
            EditorGUILayout.EndFadeGroup();
            base.serializedObject.ApplyModifiedProperties();
            UnityEngine.Object[] targets2 = base.targets;
            for (int j = 0; j < targets2.Length; j++)
            {
                Animator animator3 = (Animator)targets2[j];
                if (flag3)
                {
                    animator3.OnCullingModeChanged();
                }
                if (flag2)
                {
                    animator3.OnUpdateModeChanged();
                }
            }
        }
        public override void OnInspectorGUI()
        {
            bool isEditingMultipleObjects = targets.Length > 1;

            bool cullingModeChanged = false;
            bool updateModeChanged  = false;

            Animator firstAnimator = target as Animator;

            serializedObject.UpdateIfRequiredOrScript();

            UpdateShowOptions();

            EditorGUI.BeginChangeCheck();
            //Collect the previous AnimatorControllers

            EditorGUILayout.ObjectField(m_Controller);


            var controller = m_Controller.objectReferenceValue as RuntimeAnimatorController;

            if (EditorGUI.EndChangeCheck())
            {
                var controllers = new List <RuntimeAnimatorController>();
                foreach (Animator animator in targets)
                {
                    controllers.Add(animator.runtimeAnimatorController);
                }
                serializedObject.ApplyModifiedProperties();
                AnimationWindowUtility.ControllerChanged();
            }

            EditorGUILayout.PropertyField(m_Avatar);
            if (firstAnimator.supportsOnAnimatorMove && !isEditingMultipleObjects)
            {
                EditorGUILayout.LabelField("Apply Root Motion", "Handled by Script");
            }
            else
            {
                EditorGUILayout.PropertyField(m_ApplyRootMotion, styles.applyRootMotion);

                // This might change between layout & repaint so we have local cached value to only update on layout
                if (Event.current.type == EventType.Layout)
                {
                    m_IsRootPositionOrRotationControlledByCurves = firstAnimator.isRootPositionOrRotationControlledByCurves;
                }

                if (!m_ApplyRootMotion.boolValue && m_IsRootPositionOrRotationControlledByCurves)
                {
                    EditorGUILayout.HelpBox("Root position or rotation are controlled by curves", MessageType.Info, true);
                }
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_UpdateMode, styles.updateMode);
            updateModeChanged = EditorGUI.EndChangeCheck();


            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_CullingMode, styles.cullingMode);
            cullingModeChanged = EditorGUI.EndChangeCheck();


            if (!isEditingMultipleObjects)
            {
                EditorGUILayout.HelpBox(firstAnimator.GetStats(), MessageType.Info, true);
            }

            if (EditorGUILayout.BeginFadeGroup(m_ShowWarningMessage.faded))
            {
                EditorGUILayout.HelpBox(WarningMessage, MessageType.Warning, true);
            }
            EditorGUILayout.EndFadeGroup();


            serializedObject.ApplyModifiedProperties();

            foreach (Animator animator in targets)
            {
                if (cullingModeChanged)
                {
                    animator.OnCullingModeChanged();
                }

                if (updateModeChanged)
                {
                    animator.OnUpdateModeChanged();
                }
            }
        }