예제 #1
0
        protected override void OnTailTransformsCountChange()
        {
            base.OnTailTransformsCountChange();

            FTail_AnimatorBlending blending = target as FTail_AnimatorBlending;

            blending.SelectiveRotsNotAnimated = new System.Collections.Generic.List <bool>();
            for (int i = 0; i < blending.TailTransforms.Count; i++)
            {
                blending.SelectiveRotsNotAnimated.Add(true);
            }
        }
        protected override void DrawSpeedSliders(FTail_AnimatorBase tail)
        {
            GUILayout.BeginVertical(FEditor_Styles.LNavy);
            EditorGUILayout.HelpBox("Elasticity Behaviour Parameters", MessageType.None);

            EditorGUILayout.Slider(sp_posSpeeds, 0f, 60f);
            EditorGUILayout.Slider(sp_rotSpeeds, 0f, 60f);

            GUILayout.EndVertical();

            // V1.2
            FTail_Animator         tailSimple   = tail as FTail_Animator;
            FTail_AnimatorBlending tailBlending = tail as FTail_AnimatorBlending;

            if (!tailBlending)
            {
                if (tailSimple != null)
                {
                    EditorGUILayout.BeginVertical(FEditor_Styles.GrayBackground);

                    GUILayout.BeginHorizontal(FEditor_Styles.LBlueBackground);
                    EditorGUILayout.HelpBox("Use late update order for animated objects", MessageType.Info);
                    GUILayout.EndHorizontal();
                    EditorGUILayout.PropertyField(sp_upClock, new GUIContent("Update Order"));
                    EditorGUIUtility.labelWidth = 147;
                    EditorGUILayout.PropertyField(sp_discTransf);
                    EditorGUILayout.PropertyField(sp_queue);
                    EditorGUIUtility.labelWidth = 0;

                    EditorGUILayout.EndVertical();
                }
            }

            GUILayout.Space(1f);

            EditorGUIUtility.labelWidth = 0;
        }
        protected override void DrawSpeedSliders(FTail_AnimatorBase tail)
        {
            base.DrawSpeedSliders(tail);

            EditorGUILayout.BeginVertical(FEditor_Styles.GreenBackground);

            bool connected = false;

            if (!Application.isPlaying)
            {
                if (tail.FullCorrection && tail.AnimateCorrections && tail.RefreshHelpers)
                {
                    connected = true;
                }
            }
            else
            if (tail.FullCorrection && tail.AnimateCorrections)
            {
                connected = true;
            }


            Color preCol = GUI.color;

            if (connected)
            {
                GUI.color = new Color(0.1f, 1f, 0.325f, 0.9f);
            }

            if (GUILayout.Button(new GUIContent("Connect with animator", "This button changing some variables to make component cooperate highly with animator's animation. VARIABLES WHICH ARE CHANGED: RefreshHelpers, FullCorrection, AnimateCorrection"), new GUILayoutOption[1] {
                GUILayout.MaxHeight(18)
            }))
            {
                SwitchConnectWithAnimator(!connected);
            }

            GUI.color = preCol;

            EditorGUILayout.HelpBox("Blending and Animator Help Parameters", MessageType.None);

            FTail_AnimatorBlending tailBlending = (FTail_AnimatorBlending)target;

            EditorGUILayout.Slider(sp_blendOrig, 0f, 1f);

            if (tailBlending.BlendToOriginal > 0f && tailBlending.BlendToOriginal < 1f)
            {
                if (tailBlending.TailTransforms.Count > 0)
                {
                    float height = 16f;
                    Rect  rect   = GUILayoutUtility.GetRect(GUILayoutUtility.GetLastRect().width, height, "TextField");

                    float step = rect.width / (float)tailBlending.TailTransforms.Count;

                    for (int i = 0; i < tailBlending.TailTransforms.Count; i++)
                    {
                        float y = 1 - Mathf.InverseLerp(tailBlending.TailTransforms.Count / 2, tailBlending.TailTransforms.Count + 1, i);

                        float blendValue = 1f;

                        if (tailBlending.BlendChainValue < 1f)
                        {
                            blendValue = Mathf.Clamp(tailBlending.BlendChainValue * (float)tailBlending.TailTransforms.Count - i, 0f, 1f);
                        }

                        EditorGUI.DrawRect(new Rect(rect.x + 2 + i * step, rect.y + (1 - y) * ((height - 1) / 2), step - 2f, height * y), new Color(0.9f, 0.9f, 0.9f, blendValue * 0.78f));
                    }

                    var centered = GUI.skin.GetStyle("Label");
                    centered.alignment = TextAnchor.UpperCenter;
                    GUI.Label(rect, Mathf.Round(tailBlending.BlendChainValue * 100) + "% Source Animation Chain Blend", centered);
                }

                EditorGUILayout.Slider(sp_blendChain, 0f, 1f);
            }
            else
            {
                GUILayout.BeginHorizontal();
                EditorGUILayout.HelpBox("Blend with original for chain blend", MessageType.None);
                GUILayout.EndHorizontal();
            }

            EditorGUIUtility.labelWidth = 147;
            EditorGUILayout.PropertyField(sp_posNotAnim);
            EditorGUILayout.PropertyField(sp_queue);
            EditorGUIUtility.labelWidth = 0;

            EditorGUILayout.EndVertical();
            GUILayout.Space(4f);
        }
예제 #4
0
        protected override void DrawSpeedSliders(FTail_AnimatorBase tail)
        {
            base.DrawSpeedSliders(tail);

            EditorGUILayout.BeginVertical(FEditor_Styles.GreenBackground);

            bool connected = false;

            if (!Application.isPlaying)
            {
                if (tail.FullCorrection && tail.AnimateCorrections && tail.RefreshHelpers)
                {
                    connected = true;
                }
            }
            else
            if (tail.FullCorrection && tail.AnimateCorrections)
            {
                connected = true;
            }

            string preStr = "►";

            if (drawAnimatorOptions)
            {
                preStr = "▼";
            }
            GUILayout.BeginHorizontal(FEditor_Styles.Style(new Color32(255, 225, 255, 35)));
            if (GUILayout.Button(preStr + " Blending and Animator Help Parameters", EditorStyles.miniLabel))
            {
                drawAnimatorOptions = !drawAnimatorOptions;
            }
            GUILayout.EndHorizontal();

            if (drawAnimatorOptions)
            {
                Color preCol = GUI.color;
                if (connected)
                {
                    GUI.color = new Color(0.1f, 1f, 0.325f, 0.9f);
                }

                if (GUILayout.Button(new GUIContent("Connect with animator", "This button changing some variables to make component cooperate highly with animator's animation. VARIABLES WHICH ARE CHANGED: RefreshHelpers, FullCorrection, AnimateCorrection"), new GUILayoutOption[1] {
                    GUILayout.MaxHeight(18)
                }))
                {
                    SwitchConnectWithAnimator(!connected);

                    foreach (var s in Selection.gameObjects)
                    {
                        if (s == tail.gameObject)
                        {
                            continue;
                        }
                        FTail_AnimatorBlending b = s.GetComponent <FTail_AnimatorBlending>();
                        if (b)
                        {
                            bool enabledIs = false;
                            if (b.FullCorrection && b.AnimateCorrections)
                            {
                                enabledIs = true;
                            }

                            if (!enabledIs)
                            {
                                b.FullCorrection     = true;
                                b.AnimateCorrections = true;
                                b.RefreshHelpers     = true;
                            }
                            else
                            {
                                b.FullCorrection     = false;
                                b.AnimateCorrections = false;
                            }
                        }
                    }
                }

                GUI.color = preCol;

                FTail_AnimatorBlending tailBlending = (FTail_AnimatorBlending)target;
                EditorGUILayout.Slider(sp_blendOrig, 0f, 1f);

                if (tailBlending.BlendToOriginal > 0f && tailBlending.BlendToOriginal < 1f)
                {
                    if (tailBlending.TailTransforms.Count > 0)
                    {
                        float height = 16f;
                        Rect  rect   = GUILayoutUtility.GetRect(GUILayoutUtility.GetLastRect().width, height, "TextField");

                        float step = rect.width / (float)tailBlending.TailTransforms.Count;

                        for (int i = 0; i < tailBlending.TailTransforms.Count; i++)
                        {
                            float y = 1 - Mathf.InverseLerp(tailBlending.TailTransforms.Count / 2, tailBlending.TailTransforms.Count + 1, i);

                            float blendValue = 1f;

                            if (tailBlending.BlendChainValue < 1f)
                            {
                                blendValue = Mathf.Clamp(tailBlending.BlendChainValue * (float)tailBlending.TailTransforms.Count - i, 0f, 1f);
                            }

                            EditorGUI.DrawRect(new Rect(rect.x + 2 + i * step, rect.y + (1 - y) * ((height - 1) / 2), step - 2f, height * y), new Color(0.9f, 0.9f, 0.9f, blendValue * 0.78f));
                        }

                        var centered = GUI.skin.GetStyle("Label");
                        centered.alignment = TextAnchor.UpperCenter;
                        GUI.Label(rect, Mathf.Round(tailBlending.BlendChainValue * 100) + "% Source Animation Chain Blend", centered);
                    }

                    EditorGUILayout.Slider(sp_blendChain, 0f, 1f);
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.HelpBox("Blend with original for chain blend", MessageType.None);
                    GUILayout.EndHorizontal();
                }

                EditorGUIUtility.labelWidth = 147;
                EditorGUILayout.PropertyField(sp_posNotAnim);
                EditorGUILayout.PropertyField(sp_rotNotAnim);
                EditorGUIUtility.labelWidth = 0;

                if (tailBlending.RotationsNotAnimated)
                {
                    if (tailBlending.SelectiveRotsNotAnimated.Count == 0)
                    {
                        EditorGUILayout.HelpBox("Hit 'Auto' for this option to work", MessageType.Info);
                    }
                    else
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.PropertyField(sp_rotsSelective, true);
                        EditorGUI.indentLevel--;
                    }
                }

                GUILayout.Space(4f);

                EditorGUIUtility.labelWidth = 147;
                EditorGUILayout.PropertyField(sp_queue);
                EditorGUIUtility.labelWidth = 0;
            }

            EditorGUILayout.EndVertical();
            GUILayout.Space(4f);
        }
예제 #5
0
        protected override void DrawSpeedSliders(FTail_AnimatorBase tail)
        {
            GUILayout.BeginVertical(FEditor_Styles.LNavy);
            //EditorGUILayout.HelpBox("Elasticity Behaviour Parameters", MessageType.None);

            string preStr = "►";

            if (drawAnimOptions)
            {
                preStr = "▼";
            }
            GUILayout.BeginHorizontal(FEditor_Styles.Style(new Color32(255, 225, 255, 35)));
            //GUILayout.BeginHorizontal(FEditor_Styles.Style(new Color(0.8f,0.8f,0.8f, 0.45f) ));
            if (GUILayout.Button(preStr + " Animation & Elasticity Parameters", EditorStyles.miniLabel))
            {
                drawAnimOptions = !drawAnimOptions;
            }
            GUILayout.EndHorizontal();

            if (drawAnimOptions)
            {
                Color preCol = GUI.color;

                GUIStyle smallStyle = new GUIStyle(EditorStyles.miniLabel)
                {
                    fontStyle = FontStyle.Italic
                };
                GUI.color = new Color(1f, 1f, 1f, 0.7f);


                EditorGUILayout.BeginVertical();

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("                                       Smooth", smallStyle);
                GUILayout.FlexibleSpace();
                GUILayout.Label("Rapid                  ", smallStyle);
                EditorGUILayout.EndHorizontal();
                GUILayout.Space(-8f);

                EditorGUIUtility.labelWidth = 115;
                GUI.color = preCol;
                //GUI.color = new Color(0.93f, 1f, 0.93f, 0.9f);
                EditorGUILayout.PropertyField(sp_posSpeeds);

                EditorGUILayout.PropertyField(sp_rotSpeeds);

                GUILayout.Space(2f);
                EditorGUILayout.EndVertical();


                FEditor_Styles.DrawUILine(new Color(0.5f, 0.5f, 0.5f, 0.25f));
                //GUILayout.Space(6f);


                //if ( tail.UseCollision ) if ( tail.LookUpMethod == FTail_AnimatorBase.FELookUpMethod.Parental ) if (tail.Springiness > 0.1f) GUI.color = new Color(0.95f, 0.85f, 0.8f, 0.9f);

                GUI.color = new Color(1f, 1f, 1f, 0.7f);
                EditorGUILayout.BeginVertical();

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("                                       Calm", smallStyle);
                GUILayout.FlexibleSpace();
                GUILayout.Label("Bouncy                  ", smallStyle);
                EditorGUILayout.EndHorizontal();
                GUILayout.Space(-8f);
                GUI.color = preCol;
                EditorGUILayout.PropertyField(sp_Springiness);
                GUI.color = new Color(1f, 1f, 1f, 0.7f);
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical();

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("                                       Stiff", smallStyle);
                GUILayout.FlexibleSpace();
                GUILayout.Label("Wavy                  ", smallStyle);
                EditorGUILayout.EndHorizontal();
                GUI.color = preCol;
                GUILayout.Space(-8f);
                EditorGUILayout.EndVertical();

                if (tail.UseCollision)
                {
                    if (tail.LookUpMethod == FTail_AnimatorBase.FELookUpMethod.Parental)
                    {
                        if (tail.Sensitivity < 0.485f || tail.Sensitivity > 0.75f)
                        {
                            GUI.color = new Color(0.95f, 0.85f, 0.8f, 0.9f);
                        }
                    }
                }
                EditorGUILayout.PropertyField(sp_Sensitivity);
                GUI.color = preCol;

                FEditor_Styles.DrawUILine(new Color(0.5f, 0.5f, 0.5f, 0.25f));

                if ((tail.Springiness > 0.5f && tail.MaxStretching > 0.3f))
                {
                    GUI.color = new Color(0.8f, 1f, 0.8f, 0.9f);
                }
                else
                if ((tail.AngleLimit < 90 && tail.MaxStretching > 0.2f))
                {
                    GUI.color = new Color(1f, 0.8f, 0.8f, 0.9f);
                }

                EditorGUILayout.PropertyField(sp_maxDist);
                GUI.color = preCol;
                //if (tail.AngleLimit >= 180) GUI.color = preCol * new Color(1f, 1f, 1f, 0.6f);
                EditorGUILayout.PropertyField(sp_AngleLimit);
                if (tail.AngleLimit < 90)
                {
                    //EditorGUI.indentLevel++;
                    if (tail.AngleLimitAxis == Vector3.zero)
                    {
                        GUI.color = preCol * new Color(1f, 1f, 1f, 0.6f);
                    }
                    EditorGUILayout.PropertyField(sp_AngleLimitAxis);
                    GUI.color = preCol;

                    if (tail.AngleLimitAxis != Vector3.zero)
                    {
                        if (tail.LimitAxisRange.x == tail.LimitAxisRange.y)
                        {
                            GUI.color = preCol * new Color(1f, 1f, 1f, 0.6f);
                        }
                        EditorGUILayout.MinMaxSlider(new GUIContent("Range", "If you want limit axes symmetrically leave this parameter unchanged, if you want limit one direction of axis more than reversed, tweak this parameter"),
                                                     ref tail.LimitAxisRange.x, ref tail.LimitAxisRange.y, -90f, 90f);
                        //EditorGUILayout.PropertyField(sp_AngleLimitAxisTo);
                        GUI.color = preCol;
                    }

                    EditorGUILayout.PropertyField(sp_LimitSmoothing);

                    //EditorGUI.indentLevel--;
                }

                GUI.color = preCol;

                EditorGUILayout.PropertyField(sp_MotionInfluence);

                EditorGUIUtility.labelWidth = 0;
                GUILayout.Space(5f);

                // V1.2
                FTail_Animator         tailSimple   = tail as FTail_Animator;
                FTail_AnimatorBlending tailBlending = tail as FTail_AnimatorBlending;
                if (!tailBlending)
                {
                    if (tailSimple != null)
                    {
                        EditorGUILayout.BeginVertical(FEditor_Styles.GrayBackground);

                        //GUILayout.BeginHorizontal(FEditor_Styles.LBlueBackground);
                        //if (!Application.isPlaying)
                        //    EditorGUILayout.HelpBox("Use late update order for animated objects", MessageType.Info);
                        //else
                        //EditorGUILayout.HelpBox("  Use late update order for animated objects", MessageType.None);

                        //GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(FEditor_Styles.LBlueBackground);

                        EditorGUIUtility.labelWidth = 97;
                        EditorGUILayout.PropertyField(sp_upClock, new GUIContent("Update Order"));
                        EditorGUIUtility.labelWidth = 0;

                        if (!Application.isPlaying)
                        {
                            if (tail.UpdateClock != EFUpdateClock.LateUpdate)
                            {
                                GUILayout.FlexibleSpace();
                                GUI.color = new Color(1f, 1f, 1f, 0.7f);
                                float width = (float)typeof(EditorGUIUtility).GetProperty("contextWidth", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static).GetValue(null, null);

                                if (width > 375)
                                {
                                    GUILayout.Label(new GUIContent("Use LateUpdate for animated objects", "Use LateUpdate order for animated objects (animated by unity Animator or Animation components) or use FTail_AnimatorBlending component instead of FTail_Animator"), smallStyle);
                                }
                                else if (width > 310)
                                {
                                    GUILayout.Label(new GUIContent("Use LateUpdate for...", "Use LateUpdate order for animated objects (animated by unity Animator or Animation components) or use FTail_AnimatorBlending component instead of FTail_Animator"), smallStyle);
                                }
                                else
                                {
                                    GUILayout.Label(new GUIContent("Put Cursor Here", "(Tooltip) Use LateUpdate order for animated objects (animated by unity Animator or Animation components) or use FTail_AnimatorBlending component instead of FTail_Animator"), smallStyle);
                                }

                                GUI.color = preCol;
                            }
                        }

                        GUILayout.EndHorizontal();

                        if (!Application.isPlaying)
                        {
                            EditorGUIUtility.labelWidth = 147;
                            EditorGUILayout.PropertyField(sp_queue);
                        }
                        EditorGUIUtility.labelWidth = 0;

                        EditorGUILayout.EndVertical();
                    }
                }

                GUILayout.Space(1f);

                EditorGUIUtility.labelWidth = 0;
            }

            GUILayout.EndVertical();
        }