private static AnimatorInterface WizardAnimationPopupMecanim(string _title, ICECreatureControl _control, AnimatorInterface _animator_data)
        {
            Animator m_animator = _control.GetComponent <Animator>();

            if (m_animator != null && m_animator.enabled == true && m_animator.runtimeAnimatorController != null && m_animator.avatar != null)
            {
                if (!EditorApplication.isPlaying)
                {
                    _animator_data.Type = AnimatorControlType.DIRECT;

                    ICEEditorLayout.BeginHorizontal();
                    _animator_data.Index = AnimationEditor.AnimatorIntPopupBase(m_animator, _animator_data.Index, _title);
                    ICEEditorLayout.EndHorizontal();

                    if (AnimationTools.GetAnimationClipCount(m_animator) == 0)
                    {
                        Info.Warning(Info.BEHAVIOUR_ANIMATION_ANIMATOR_ERROR_NO_CLIPS);
                    }
                    else
                    {
                        AnimationClip _animation_clip = AnimationTools.GetAnimationClipByIndex(m_animator, _animator_data.Index);
                        if (_animation_clip != null)
                        {
                            if (_animator_data.Name != _animation_clip.name)
                            {
                                _animator_data.Init();
                            }


                            _animation_clip.wrapMode = WrapMode.Loop;
                            _animation_clip.legacy   = false;

                            _animator_data.StateName          = AnimationEditor.GetAnimatorStateName(m_animator, _animation_clip.name);
                            _animator_data.Name               = _animation_clip.name;
                            _animator_data.Length             = _animation_clip.length;
                            _animator_data.Speed              = 1;
                            _animator_data.TransitionDuration = 0.05f;
                        }
                    }
                }
                else
                {
                    ICEEditorLayout.Label("Name", "Animation name.", _animator_data.Name);
                }
            }
            else
            {
            }
            return(_animator_data);
        }
Ejemplo n.º 2
0
        private static AnimatorInterface DrawBehaviourAnimationAnimatorData(ICEWorldBehaviour _control, AnimatorInterface _animator_data)
        {
            Animator m_animator = _control.GetComponentInChildren <Animator>();

            if (m_animator != null && m_animator.enabled == true && m_animator.runtimeAnimatorController != null && m_animator.avatar != null)
            {
                if (!EditorApplication.isPlaying)
                {
                    string _help_control_type = Info.ANIMATION_ANIMATOR_CONTROL_TYPE_DIRECT;

                    if (_animator_data.Type == AnimatorControlType.ADVANCED)
                    {
                        _help_control_type = Info.ANIMATION_ANIMATOR_CONTROL_TYPE_ADVANCED;
                    }

                    _animator_data.Type = (AnimatorControlType)ICEEditorLayout.EnumPopup("Control Type", "", _animator_data.Type, _help_control_type);

                    if (_animator_data.Type == AnimatorControlType.DIRECT)
                    {
                        _animator_data.Index = AnimatorIntPopup(m_animator, _animator_data.Index);

                        if (AnimationTools.GetAnimationClipCount(m_animator) == 0)
                        {
                            Info.Warning(Info.ANIMATION_ANIMATOR_ERROR_NO_CLIPS);
                        }
                        else
                        {
                            AnimationClip _animation_clip = AnimationTools.GetAnimationClipByIndex(m_animator, _animator_data.Index);

                            if (_animation_clip != null)
                            {
                                if (_animator_data.Name != _animation_clip.name)
                                {
                                    _animator_data.Init();
                                }

                                _animation_clip.legacy = false;
                                //_animation_clip.wrapMode = (WrapMode)ICEEditorLayout.EnumPopup( "WarpMode", "Determines how time is treated outside of the keyframed range of an AnimationClip or AnimationCurve.", _animation_clip.wrapMode );

                                _animator_data.StateName = AnimationEditor.GetAnimatorStateName(m_animator, _animation_clip.name);
                                _animator_data.Name      = _animation_clip.name;
                                _animator_data.Length    = _animation_clip.length;

                                //_animation_clip.wrapMode = DrawBehaviourAnimationWrapMode( _animation_clip.wrapMode  );
                                DrawBehaviourAnimationData(ref _animator_data.Speed, ref _animator_data.AutoSpeed, ref _animator_data.TransitionDuration, ref _animator_data.AutoTransitionDuration);

                                if (_animator_data.AutoTransitionDuration)
                                {
                                    _animator_data.TransitionDuration = _animator_data.Length * 0.25f;
                                }


                                _animator_data.ApplyRootMotion = ICEEditorLayout.Toggle("Apply Root Motion", "", _animator_data.ApplyRootMotion);

                                if (m_animator.hasRootMotion)
                                {
                                    Info.Warning("The current rig has Root Motions");
                                }



                                _animator_data.ShowDetails = ICEEditorLayout.Foldout(_animator_data.ShowDetails, "Animation Details", false);
                                if (_animator_data.ShowDetails)
                                {
                                    AnimationClipSettings _animation_clip_settings = AnimationUtility.GetAnimationClipSettings(_animation_clip);

                                    EditorGUI.indentLevel++;

                                    ICEEditorLayout.MiniLabelLeft("Length \t\t\t\t" + (_animation_clip_settings.stopTime - _animation_clip_settings.startTime).ToString() + " secs.");

                                    ICEEditorLayout.MiniLabelLeft("WrapMode \t\t\t" + _animation_clip.wrapMode.ToString());

                                    EditorGUILayout.Separator();
                                    ICEEditorLayout.MiniLabelLeft("Loop Time \t\t\t" + _animation_clip_settings.loopTime.ToString());
                                    ICEEditorLayout.MiniLabelLeft("\tLoop Pose \t\t" + _animation_clip_settings.loopBlend.ToString());
                                    ICEEditorLayout.MiniLabelLeft("\tCycle Offset \t\t" + _animation_clip_settings.cycleOffset.ToString());

                                    EditorGUILayout.Separator();
                                    ICEEditorLayout.MiniLabelLeft("Root Transform Rotation");
                                    ICEEditorLayout.MiniLabelLeft("\tBake Into Pose \t\t" + _animation_clip_settings.loopBlendOrientation.ToString());
                                    ICEEditorLayout.MiniLabelLeft("\tOriginal Orientation \t" + _animation_clip_settings.keepOriginalOrientation.ToString());
                                    ICEEditorLayout.MiniLabelLeft("\tOffset \t\t\t" + _animation_clip_settings.orientationOffsetY.ToString());

                                    EditorGUILayout.Separator();
                                    ICEEditorLayout.MiniLabelLeft("Root Transform Position (Y)");
                                    ICEEditorLayout.MiniLabelLeft("\tBake Into Pose \t\t" + _animation_clip_settings.loopBlendPositionY.ToString());
                                    ICEEditorLayout.MiniLabelLeft("\tOriginal Position (Y) \t" + _animation_clip_settings.keepOriginalPositionY.ToString());
                                    ICEEditorLayout.MiniLabelLeft("\tOffset \t\t\t" + _animation_clip_settings.level.ToString());

                                    EditorGUILayout.Separator();
                                    ICEEditorLayout.MiniLabelLeft("Root Transform Position (XZ)");
                                    ICEEditorLayout.MiniLabelLeft("\tBake Into Pose \t\t" + _animation_clip_settings.loopBlendPositionXZ.ToString());
                                    ICEEditorLayout.MiniLabelLeft("\tOriginal Position (XZ) \t" + _animation_clip_settings.keepOriginalPositionXZ.ToString());

                                    ICEEditorLayout.MiniLabelLeft("Mirror \t\t\t\t" + _animation_clip_settings.mirror.ToString());


                                    /*
                                     *
                                     *      ICEEditorLayout.MiniLabelLeft( "Height From Feet \t\t\t" +  _animation_clip_settings.heightFromFeet );
                                     *
                                     *      ICEEditorLayout.MiniLabelLeft( "Start Time \t\t\t" + _animation_clip_settings.startTime.ToString() );
                                     *      ICEEditorLayout.MiniLabelLeft( "Stop Time \t\t\t" + _animation_clip_settings.stopTime.ToString() );
                                     *
                                     *      //ICEEditorLayout.MiniLabelLeft( "Additive Reference Pose Clip \t\t" + _animation_clip_settings.additiveReferencePoseClip.ToString() );
                                     *      ICEEditorLayout.MiniLabelLeft( "Additive Reference Pose Time \t" + _animation_clip_settings.additiveReferencePoseTime.ToString() );
                                     *      ICEEditorLayout.MiniLabelLeft( "Has Additive Reference Pose \t" + _animation_clip_settings.hasAdditiveReferencePose.ToString() );
                                     *
                                     *      //AnimationUtility.SetAnimationClipSettings( _animation_clip, _animation_clip_settings );
                                     *
                                     */

                                    EditorGUILayout.HelpBox("Please note: To adapt the above-listed values please open the animation clip settings or the import settings " +
                                                            "of the selected object. In order to avoid problems with incorrect adapted animations, it is recommended to check and adjust the motion sequences and " +
                                                            "settings at an early stage.", MessageType.None);

                                    EditorGUI.indentLevel--;
                                }
                            }
                        }
                    }
                    else if (_animator_data.Type == AnimatorControlType.ADVANCED)
                    {
                        //EditorGUI.BeginDisabledGroup( _control.gameObject.GetComponent<Rigidbody>() == null && _control.gameObject.GetComponent<CharacterController>() == null );
                        _animator_data.ApplyRootMotion = ICEEditorLayout.Toggle("Apply Root Motion", "", _animator_data.ApplyRootMotion);
                        //EditorGUI.EndDisabledGroup();

                        //if( _control.gameObject.GetComponent<Rigidbody>() == null && _control.gameObject.GetComponent<CharacterController>() == null )
                        //_animator_data.ApplyRootMotion = false;

                        DrawBehaviourAnimationAnimatorParameterData(_control, _animator_data.Parameters);
                    }
                }
                else
                {
                    if (_animator_data.Type == AnimatorControlType.DIRECT)
                    {
                        ICEEditorLayout.Label("Name", "Animation name.", _animator_data.Name);
                        ICEEditorLayout.Label("Length", "Animation length in seconds.", _animator_data.Length.ToString() + " secs.");
                        ICEEditorLayout.Label("Speed", "Determines how time is treated outside of the keyframed range of an AnimationClip.", _animator_data.Speed.ToString());
                        ICEEditorLayout.Label("Transition Duration", "Determines how time is treated outside of the keyframed range of an AnimationClip.", _animator_data.TransitionDuration.ToString());
                        ICEEditorLayout.Label("Root Motion", "Determines how potential Root Motions will be handled for this Behaviour Rule.", _animator_data.ApplyRootMotion.ToString());

                        //_animator_data.Speed = ICEEditorLayout.AutoSlider("Speed", "", _animator_data.Speed, 0.01f, -5, 5, ref _animator_data.AutoSpeed, 1 );
                        //_animator_data.TransitionDuration = ICEEditorLayout.AutoSlider( "Transition Duration", "", _animator_data.TransitionDuration, 0.01f, 0, 10, ref _animator_data.AutoTransitionDuration, 0.25f  );

                        //DrawBehaviourAnimationData( ref _animator_data.Speed, ref _animator_data.AutoSpeed, ref _animator_data.TransitionDuration, ref _animator_data.AutoTransitionDuration );
                    }
                    else if (_animator_data.Type == AnimatorControlType.ADVANCED)
                    {
                        foreach (AnimatorParameterObject _parameter in _animator_data.Parameters)
                        {
                            switch (_parameter.Type)
                            {
                            case AnimatorControllerParameterType.Bool:
                                EditorGUILayout.LabelField(_parameter.Name, "(BOOLEAN) " + _parameter.BooleanValue.ToString());
                                break;

                            case AnimatorControllerParameterType.Int:
                                EditorGUILayout.LabelField(_parameter.Name, "(INTEGER) " + _parameter.IntegerValue.ToString());
                                break;

                            case AnimatorControllerParameterType.Float:
                                EditorGUILayout.LabelField(_parameter.Name, "(FLOAT) " + (_parameter.UseDynamicValue?_control.GetDynamicFloatValue(_parameter.FloatValueType):_parameter.FloatValue));
                                break;

                            case AnimatorControllerParameterType.Trigger:
                                EditorGUILayout.LabelField(_parameter.Name, "(TRIGGER)");
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                if (m_animator != null)
                {
                    if (m_animator.enabled == false)
                    {
                        EditorGUILayout.HelpBox("Sorry, your Animator Component is disabled!", MessageType.Warning);

                        ICEEditorLayout.BeginHorizontal();
                        EditorGUILayout.LabelField("Enable Animator Component", EditorStyles.boldLabel);
                        m_animator.enabled = ICEEditorLayout.EnableButton("Enables/disables the Animator Component", m_animator.enabled);
                        ICEEditorLayout.EndHorizontal();
                    }
                    else if (m_animator.runtimeAnimatorController == null)
                    {
                        EditorGUILayout.HelpBox("Sorry, there is no Runtime Animator Controller!", MessageType.Warning);

                        ICEEditorLayout.BeginHorizontal();
                        EditorGUILayout.LabelField("Enable Animator Component", EditorStyles.boldLabel);
                        m_animator.enabled = ICEEditorLayout.EnableButton("Enables/disables the Animator Component", m_animator.enabled);
                        ICEEditorLayout.EndHorizontal();
                    }
                    else if (m_animator.avatar == null)
                    {
                        EditorGUILayout.HelpBox("Sorry, there is no Avatar asigned to your Animator Component!", MessageType.Warning);

                        ICEEditorLayout.BeginHorizontal();
                        EditorGUILayout.LabelField("Enable Animator Component", EditorStyles.boldLabel);
                        m_animator.enabled = ICEEditorLayout.EnableButton("Enables/disables the Animator Component", m_animator.enabled);
                        ICEEditorLayout.EndHorizontal();
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Sorry, there is no Animator Component!", MessageType.Warning);

                    ICEEditorLayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Add Animator Component", EditorStyles.miniLabel);
                    if (ICEEditorLayout.AddButton("Add Animator Component"))
                    {
                        m_animator = _control.gameObject.AddComponent <Animator>();
                    }
                    ICEEditorLayout.EndHorizontal();
                }
            }
            return(_animator_data);
        }