/// <summary>
        /// Drawing markers to be visible in editor window to help place bones correctly
        /// </summary>
        public void DrawMarkers(Transform[] markers)
        {
            if (markers == null)
            {
                return;
            }

            for (int i = 0; i < markers.Length; i++)
            {
                Gizmos.color = FColorMethods.ChangeColorAlpha(GetBoneIndicatorColor(i, markers.Length), GizmoAlpha);

                Vector3 targetPosition = markers[i].position;
                Vector3 previousPos    = targetPosition;
                if (i > 0)
                {
                    previousPos = markers[i - 1].position;
                }

                Gizmos.DrawWireSphere(targetPosition, GizmoSize);

                Gizmos.color = FColorMethods.ChangeColorAlpha(GetBoneIndicatorColor(i, markers.Length, 1f, 1f), GizmoAlpha * 0.8f);
                Gizmos.DrawSphere(targetPosition, GizmoSize * 0.7f);

                Gizmos.color = new Color(0.6f, 0.1f, 0.1f, GizmoAlpha * 1.3f);
                Gizmos.DrawLine(previousPos + transform.right * GizmoSize, targetPosition + transform.right * GizmoSize);
                Gizmos.DrawLine(previousPos - transform.right * GizmoSize, targetPosition - transform.right * GizmoSize);

                Gizmos.color = FColorMethods.ChangeColorAlpha(Color.blue, GizmoAlpha * 1.2f);
                Gizmos.DrawLine(targetPosition, targetPosition + markers[i].forward * GizmoSize);

                previousPos = targetPosition;
            }
        }
Example #2
0
        public override void OnInspectorGUI()
        {
            FJiggling_Grow targetScript = (FJiggling_Grow)target;

            DrawDefaultInspector();

            GUILayout.Space(10f);

            if (!Application.isPlaying)
            {
                GUI.color = FColorMethods.ChangeColorAlpha(GUI.color, 0.45f);
            }
            if (GUILayout.Button("Animate Growing"))
            {
                if (Application.isPlaying)
                {
                    targetScript.StartGrowing();
                }
                else
                {
                    Debug.Log("You must be in playmode to run this method!");
                }
            }
            if (GUILayout.Button("Animate Shrink"))
            {
                if (Application.isPlaying)
                {
                    targetScript.StartShrinking();
                }
                else
                {
                    Debug.Log("You must be in playmode to run this method!");
                }
            }
        }
        private void Update()
        {
            Color newColor = RendererMaterial.GetColor(shaderParamName);

            newColor = FColorMethods.ChangeColorAlpha(newColor, newColor.a - Time.deltaTime * FadeSpeed);

            RendererMaterial.SetColor(shaderParamName, newColor);

            if (newColor.a <= 0f)
            {
                GameObject.Destroy(gameObject);
            }
        }
Example #4
0
        /// <summary>
        /// Drawing markers to be visible in editor window to help place bones correctly
        /// </summary>
        public void DrawMarkers(Transform[] markers)
        {
            if (markers == null)
            {
                return;
            }

            for (int i = 0; i < markers.Length; i++)
            {
                Gizmos.color = FColorMethods.ChangeColorAlpha(GetBoneIndicatorColor(i, markers.Length), GizmoAlpha);

                Vector3 targetPosition = markers[i].position;
                Vector3 previousPos    = targetPosition;
                if (i > 0)
                {
                    previousPos = markers[i - 1].position;
                }

                Gizmos.DrawWireSphere(targetPosition, GizmoSize);

                Gizmos.color = FColorMethods.ChangeColorAlpha(GetBoneIndicatorColor(i, markers.Length, 1f, 1f), GizmoAlpha * 0.8f);
                Gizmos.DrawSphere(targetPosition, GizmoSize * 0.7f);

                Gizmos.DrawRay(targetPosition, markers[i].up * GizmoSize * 1.1f);
                Gizmos.DrawRay(targetPosition, -markers[i].up * GizmoSize * 1.1f);
                Gizmos.DrawRay(targetPosition, markers[i].right * GizmoSize * 1.1f);
                Gizmos.DrawRay(targetPosition, -markers[i].right * GizmoSize * 1.1f);

                Vector3 targetPoint;
                if (i < markers.Length - 1)
                {
                    targetPoint = markers[i + 1].position;
                }
                else
                {
                    targetPoint = markers[i].position + (markers[i].position - markers[i - 1].position);
                }

                Gizmos.DrawLine(targetPosition + markers[i].up * GizmoSize * 1.1f, targetPoint);
                Gizmos.DrawLine(targetPosition - markers[i].up * GizmoSize * 1.1f, targetPoint);
                Gizmos.DrawLine(targetPosition + markers[i].right * GizmoSize * 1.1f, targetPoint);
                Gizmos.DrawLine(targetPosition - markers[i].right * GizmoSize * 1.1f, targetPoint);

                previousPos = targetPosition;
            }
        }
Example #5
0
        protected override void UpdateIn()
        {
            base.UpdateIn();

            if (Holding)
            {
                canvasGroup.alpha = 0f;

                KnobValue  = Mathf.Clamp(YValue, 0f, 100f);
                KnobValue /= 100f;

                UpdatePullableOrientation();
            }

            if (mouseEntered)
            {
                FColorMethods.LerpMaterialColor(markerMaterial, "_Color", Color.green);
            }
            else
            {
                FColorMethods.LerpMaterialColor(markerMaterial, "_Color", Color.black);
            }
        }
        public override void OnInspectorGUI()
        {
            FJiggling_SimpleBones targetScript = (FJiggling_SimpleBones)target;

            DrawDefaultInspector();

            GUILayout.Space(10f);

            if (!Application.isPlaying)
            {
                GUI.color = FColorMethods.ChangeColorAlpha(GUI.color, 0.45f);
            }
            if (GUILayout.Button("Jiggle It"))
            {
                if (Application.isPlaying)
                {
                    targetScript.StartJiggle();
                }
                else
                {
                    Debug.Log("You must be in playmode to run this method!");
                }
            }
        }
Example #7
0
    //private SerializedProperty sp_sep;

    //private void OnEnable()
    //{
    //    sp_sep = serializedObject.FindProperty("SeparatedCalculations");
    //}

    public override void OnInspectorGUI()
    {
        FJiggling_Multi targetScript = (FJiggling_Multi)target;

        DrawDefaultInspector();

        GUILayout.Space(5);

        GUILayout.BeginVertical(EditorStyles.helpBox);

        Color preCol = GUI.color;

        GUI.color = new Color(0.5f, 1f, 0.5f, 0.9f);

        var drop = GUILayoutUtility.GetRect(0f, 22f, new GUILayoutOption[1] {
                GUILayout.ExpandWidth(true)
            });

        GUI.Box(drop, "Drag & Drop your GameObjects here", new GUIStyle(EditorStyles.helpBox)
            {
                alignment = TextAnchor.MiddleCenter, fixedHeight = 22
            });
        var dropEvent = Event.current;

        GUILayout.Space(3);

        GUILayout.BeginHorizontal();

        EditorGUIUtility.labelWidth        = 166;
        targetScript.ShowIndividualOptions = EditorGUILayout.Toggle(new GUIContent(" Show Individual Options", "If single stimulated transforms don't have animated tracks from individual tracks like rotation or scale, also with this you can chcange intensity of effect for each element separately"), targetScript.ShowIndividualOptions);
        EditorGUIUtility.labelWidth        = 0;
        EditorGUI.indentLevel++;

        if (ActiveEditorTracker.sharedTracker.isLocked)
        {
            GUI.color = new Color(0.44f, 0.44f, 0.44f, 0.8f);
        }
        else
        {
            GUI.color = preCol;
        }
        if (GUILayout.Button(new GUIContent("Lock Inspector", "Locking Inspector Window to help Drag & Drop operations"), new GUILayoutOption[2] {
                GUILayout.Width(106), GUILayout.Height(16)
            }))
        {
            ActiveEditorTracker.sharedTracker.isLocked = !ActiveEditorTracker.sharedTracker.isLocked;
        }

        GUI.color = preCol;

        GUILayout.EndHorizontal();

        GUILayout.Space(5);

        switch (dropEvent.type)
        {
        case EventType.DragUpdated:
        case EventType.DragPerform:
            if (!drop.Contains(dropEvent.mousePosition))
            {
                break;
            }

            DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

            if (dropEvent.type == EventType.DragPerform)
            {
                DragAndDrop.AcceptDrag();

                foreach (var dragged in DragAndDrop.objectReferences)
                {
                    GameObject draggedObject = dragged as GameObject;

                    if (draggedObject)
                    {
                        targetScript.AddNewElement(new FJiggling_Multi.FJiggling_Element(draggedObject.transform));
                        EditorUtility.SetDirty(target);
                    }
                }
            }

            Event.current.Use();
            break;
        }

        if (targetScript.ToJiggle == null)
        {
            targetScript.ToJiggle = new List <FJiggling_Multi.FJiggling_Element>();
        }

        GUILayout.BeginHorizontal();
        showTransforms = EditorGUILayout.Foldout(showTransforms, "To Stimulate (" + targetScript.ToJiggle.Count + ")", true);

        if (GUILayout.Button("All", new GUILayoutOption[2] {
                GUILayout.MaxWidth(48), GUILayout.MaxHeight(14)
            }))
        {
            targetScript.ToJiggle.Clear();

            foreach (Transform tr in FTransformMethods.FindComponentsInAllChildren <Transform>(targetScript.transform))
            {
                targetScript.AddNewElement(new FJiggling_Multi.FJiggling_Element(tr));
            }

            EditorUtility.SetDirty(target);
        }

        if (GUILayout.Button("+", new GUILayoutOption[2] {
                GUILayout.MaxWidth(28), GUILayout.MaxHeight(14)
            }))
        {
            targetScript.AddNewElement(new FJiggling_Multi.FJiggling_Element(null));
            EditorUtility.SetDirty(target);
        }

        if (GUILayout.Button("-", new GUILayoutOption[2] {
                GUILayout.MaxWidth(28), GUILayout.MaxHeight(14)
            }))
        {
            if (targetScript.ToJiggle.Count > 0)
            {
                targetScript.RemoveElement(targetScript.ToJiggle.Count - 1);
                EditorUtility.SetDirty(target);
            }
        }

        if (GUILayout.Button("C", new GUILayoutOption[2] {
                GUILayout.MaxWidth(28), GUILayout.MaxHeight(14)
            }))
        {
            targetScript.ClearElements();
            EditorUtility.SetDirty(target);
        }

        GUILayout.EndHorizontal();
        GUI.color = preCol;

        if (showTransforms)
        {
            GUILayout.Space(3);

            if (!targetScript.ShowIndividualOptions)
            {
                for (int i = 0; i < targetScript.ToJiggle.Count; i++)
                {
                    GUILayout.BeginHorizontal();

                    string name;
                    if (!targetScript.ToJiggle[i].Transform)
                    {
                        name      = "Assign Object";
                        GUI.color = new Color(0.9f, 0.4f, 0.4f, 0.9f);
                    }
                    else
                    {
                        name = targetScript.ToJiggle[i].Transform.name;
                        if (name.Length > 12)
                        {
                            name = targetScript.ToJiggle[i].Transform.name.Substring(0, 7) + "...";
                        }
                    }

                    targetScript.ToJiggle[i].Transform = (Transform)EditorGUILayout.ObjectField("  [" + i + "] " + name, targetScript.ToJiggle[i].Transform, typeof(Transform), true);

                    GUI.color = preCol;
                    if (GUILayout.Button("X", new GUILayoutOption[2] {
                            GUILayout.Width(20), GUILayout.Height(14)
                        }))
                    {
                        targetScript.ToJiggle.RemoveAt(i);
                        EditorUtility.SetDirty(target);
                    }

                    GUILayout.EndHorizontal();
                }
            }
            else
            {
                for (int i = 0; i < targetScript.ToJiggle.Count; i++)
                {
                    GUILayout.BeginHorizontal();

                    string name;
                    if (!targetScript.ToJiggle[i].Transform)
                    {
                        name      = "Assign Object";
                        GUI.color = new Color(0.9f, 0.4f, 0.4f, 0.9f);
                    }
                    else
                    {
                        name = targetScript.ToJiggle[i].Transform.name;
                        if (name.Length > 12)
                        {
                            name = targetScript.ToJiggle[i].Transform.name.Substring(0, 7) + "...";
                        }
                    }

                    targetScript.ToJiggle[i].Transform = (Transform)EditorGUILayout.ObjectField("  [" + i + "] " + name, targetScript.ToJiggle[i].Transform, typeof(Transform), true);
                    GUI.color = preCol;

                    if (GUILayout.Button("X", new GUILayoutOption[2] {
                            GUILayout.Width(20), GUILayout.Height(14)
                        }))
                    {
                        targetScript.ToJiggle.RemoveAt(i);
                        EditorUtility.SetDirty(target);
                    }

                    GUILayout.EndHorizontal();

                    targetScript.ToJiggle[i].RotationAxesMul = EditorGUILayout.Vector3Field(new GUIContent("     Rot. Mul.", "Individual Rotation Axes Multiplier"), targetScript.ToJiggle[i].RotationAxesMul);
                    targetScript.ToJiggle[i].ScaleAxesMul    = EditorGUILayout.Vector3Field(new GUIContent("     Scale Mul.", "Individual Rotation Axes Multiplier"), targetScript.ToJiggle[i].ScaleAxesMul);

                    GUILayout.Space(7);
                }
            }
        }

        EditorGUI.indentLevel--;
        GUILayout.EndVertical();

        GUILayout.Space(5f);

        if (!Application.isPlaying)
        {
            GUI.color = FColorMethods.ChangeColorAlpha(GUI.color, 0.45f);
        }
        else
        {
            GUI.color = preCol;
        }
        if (GUILayout.Button("Jiggle It"))
        {
            if (Application.isPlaying)
            {
                targetScript.StartJiggle();
            }
            else
            {
                Debug.Log("You must be in playmode to run this method!");
            }
        }
    }
        protected override void UpdateIn()
        {
            base.UpdateIn();

            transform.localRotation = Quaternion.Slerp(transform.localRotation, initialRotation * offsetRotation, Time.deltaTime * 9f * rotationIncreaser);

            float angleDiff = Quaternion.Angle(transform.localRotation, offsetRotation);

            if (Holding)
            {
                Vector3 forwardA = transform.localRotation * Vector3.forward;
                Vector3 forwardB = (initialRotation * offsetRotation) * Vector3.forward;
                float   angleA   = Mathf.Atan2(forwardA.x, forwardA.z) * Mathf.Rad2Deg;
                float   angleB   = Mathf.Atan2(forwardB.x, forwardB.z) * Mathf.Rad2Deg;
                float   diff     = -Mathf.DeltaAngle(angleA, angleB);
                if (ReversePull)
                {
                    diff = -diff;
                }

                if (YValue < 0f)
                {
                    YValue = 0f;
                }
                if (YValue > 100f)
                {
                    YValue = 100f;
                }

                velocity = Mathf.Lerp(velocity, diff, Time.deltaTime * 9f);
            }
            else
            {
                velocity = Mathf.Lerp(velocity, 0f, Time.deltaTime * Deceleration);
                //YValue += velocity * 0.5f;
                //PullValue += (velocity / 100f) * 0.5f;
                float yAdd = velocity * 2.5f; // * Mathf.Abs(RotationRanges.x - RotationRanges.y)
                YValue += yAdd * Time.deltaTime * 12f;

                if (YValue < 0f)
                {
                    YValue = 0f;
                }
                if (YValue > 100f)
                {
                    YValue = 100f;
                }

                PullValue = YValue / 100f;
                //PullValue += yAdd / 100f;

                float range = Mathf.Lerp(RotationRanges.x, RotationRanges.y, PullValue);
                offsetRotation = Quaternion.Euler(range * RotationAxis.x, range * RotationAxis.y, range * RotationAxis.z);
            }

            rotationIncreaser = Mathf.Lerp(rotationIncreaser, Mathf.Lerp(2f, 4f, Mathf.InverseLerp(5f, 45f, angleDiff)), Time.deltaTime * 10f);

            if (angleDiff < 0.01f && velocity < 0.01f)
            {
                animationFinished = true;
            }
            else
            {
                animationFinished = false;
            }

            if (Holding)
            {
                canvasGroup.alpha = 0f;
                Sensitivity       = startSensitivity;
                if (ReversePull)
                {
                    Sensitivity *= -1f;
                }

                // Checking if pull should behave in reverse way
                if (EnteredTransform)
                {
                    if (lookDot < 0f)
                    {
                        Sensitivity *= -1f;
                    }
                }

                PullValue  = Mathf.Clamp(YValue, 0f, 100f);
                PullValue /= 100f;

                UpdatePullableOrientation();
            }
            else
            {
                if (animationFinished)
                {
                    conditionalExit = false;
                }
            }

            if (ToEmmit)
            {
                if (mouseEntered)
                {
                    FColorMethods.LerpMaterialColor(ToEmmit.material, "_EmissionColor", Color.white * 0.3f);
                }
                else
                {
                    FColorMethods.LerpMaterialColor(ToEmmit.material, "_EmissionColor", Color.black);
                }
            }
        }
Example #9
0
    void DrawOldGUI()
    {
        GUILayout.Space(5f);
        Color preCol = GUI.color;

        EditorGUILayout.BeginVertical(FEditor_Styles.Style(FColorMethods.ChangeColorAlpha(Color.white, 0.25f)));
        EditorGUI.indentLevel++;

        drawMain = EditorGUILayout.Foldout(drawMain, "Main Parameters", true);


        #region Main Tab

        if (drawMain)
        {
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            if (Get.SpineBones == null || Get.SpineBones.Count < 1)
            {
                GUILayout.BeginHorizontal(FEditor_Styles.YellowBackground);
                EditorGUILayout.HelpBox("Put here two marginal bones from hierarchy and click 'Get' to create spine chain of section you want to animate with spine animator", MessageType.Info);
                GUILayout.EndHorizontal();
            }

            EditorGUILayout.BeginVertical(FEditor_Styles.LGrayBackground);

            if (Get.SpineBones == null || Get.SpineBones.Count < 1)
            {
                GUIStyle smallStyle = new GUIStyle(EditorStyles.miniLabel)
                {
                    fontStyle = FontStyle.Italic, fontSize = 9
                };
                GUI.color = new Color(1f, 1f, 1f, 0.7f);
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("             Enter for tooltip", "If you rigging quadroped or other animal, start bone should be pelvis bone with back legs and tail inside the hierarchy"), smallStyle);
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent("Enter for tooltip                       ", "If you rigging quadroped or other animal, end bone should be chest bone / neck bone or head bone, depends of your needs and model structure"), smallStyle);
                EditorGUILayout.EndHorizontal();
                GUILayout.Space(1f);
            }

            EditorGUILayout.BeginHorizontal();
            int wrong = 0;
            if (Get.SpineBones != null)
            {
                if (Get.SpineBones.Count < 2)
                {
                    wrong = 2;
                }
                else
                {
                    if (startBone != Get.SpineBones[0].transform || endBone != Get.SpineBones[Get.SpineBones.Count - 1].transform)
                    {
                        wrong = 3;
                    }
                }
            }
            else
            {
                wrong = 1;
            }

            if (wrong == 1)
            {
                GUI.color = new Color(1f, 0.3f, 0.3f, 0.85f);
            }
            if (wrong == 2)
            {
                GUI.color = new Color(1f, 0.7f, 0.2f, 0.85f);
            }

            EditorGUI.indentLevel--;

            EditorGUIUtility.labelWidth = 42f;
            startBone = Get._gizmosEditorStartPreview;
            endBone   = Get._gizmosEditorEndPreview;
            if (startBone == null)
            {
                TryFindStartBone();
            }
            if (endBone == null)
            {
                TryFindEndBone();
            }

            startBone = (Transform)EditorGUILayout.ObjectField(new GUIContent("Start", "Put here first bone in hierarchy depth for automatically get chain of bones to end one"), startBone, typeof(Transform), true);
            endBone   = (Transform)EditorGUILayout.ObjectField(new GUIContent("End", "Put here last bone in hierarchy depth for automatically get chain of bones from start one"), endBone, typeof(Transform), true);

            EditorGUIUtility.labelWidth = 0f;

            if (GUILayout.Button(new GUIContent("L", "Automatically get last bone in hierarchy - it depends of children placement, then sometimes last bone can be found wrong, whne you have arms/legs bones inside, if they're higher, algorithm will go through them"), new GUILayoutOption[2] {
                GUILayout.MaxWidth(24), GUILayout.MaxHeight(14)
            }))
            {
                GetLastBoneInHierarchy();
            }

            if (wrong == 3)
            {
                GUI.color = new Color(0.2f, 1f, 0.4f, 0.85f);
            }
            if (startBone != null && endBone != null)
            {
                GUI.color = new Color(0.3f, 1f, 0.4f, 0.8f);

                if (Get.SpineBones != null)
                {
                    if (Get.SpineBones.Count > 0)
                    {
                        if (startBone != Get.SpineBones[0].transform || endBone != Get.SpineBones[Get.SpineBones.Count - 1].transform)
                        {
                            wrong = 3;
                        }
                        else
                        {
                            GUI.color = FColorMethods.ChangeColorAlpha(preCol, 0.7f);
                        }
                    }
                }
            }

            if (GUILayout.Button(new GUIContent("Get"), new GUILayoutOption[2] {
                GUILayout.MaxWidth(36), GUILayout.MaxHeight(14)
            }))
            {
                Get.CreateSpineChain(Get._gizmosEditorStartPreview, Get._gizmosEditorEndPreview);
                //GetBonesChainFromStartToEnd();
                //Get.TryAutoCorrect(null, false);
                EditorUtility.SetDirty(target);
            }


            GUI.color = preCol;

            EditorGUILayout.EndHorizontal();


            if (Get.SpineBones == null || Get.SpineBones.Count < 1)
            {
                GUIStyle smallStyle = new GUIStyle(EditorStyles.miniLabel)
                {
                    fontStyle = FontStyle.Italic, fontSize = 9
                };
                GUI.color = new Color(1f, 1f, 1f, 0.7f);
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("        Pelvis bone with Legs", "If you rigging quadroped or other animal, start bone should be pelvis bone with back legs and tail inside the hierarchy"), smallStyle);
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent("Chest/Neck/Head bone             ", "If you rigging quadroped or other animal, end bone should be chest bone / neck bone or head bone, depends of your needs and model structure"), smallStyle);
                EditorGUILayout.EndHorizontal();
                GUILayout.Space(1f);
            }


            EditorGUILayout.EndVertical();
            EditorGUI.indentLevel++;

            if (Get.SpineBones == null || Get.SpineBones.Count < 1)
            {
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndVertical();
                return;
            }

            EditorGUIUtility.labelWidth = 148f;
            EditorGUILayout.PropertyField(sp_forw);
            EditorGUIUtility.labelWidth = 0;

            if (Get.SpineBones.Count < 1)
            {
                EditorGUILayout.BeginVertical(FEditor_Styles.GrayBackground);
            }
            //EditorGUILayout.BeginHorizontal(FEditor_Styles.Style(new Color32(99, 50, 166, 45)));
            else
            {
                EditorGUILayout.BeginVertical(FEditor_Styles.LGrayBackground);
            }
            //EditorGUILayout.BeginHorizontal(FEditor_Styles.Style(new Color32(10, 66, 175, 25)));

            //EditorGUILayout.PropertyField(sp_spines, true);

            drawSpineTransforms = EditorGUILayout.Foldout(drawSpineTransforms, new GUIContent("Spine Transforms", "Spine chain transforms"), true, new GUIStyle(EditorStyles.foldout)
            {
                fontStyle = FontStyle.Bold
            });

            if (drawSpineTransforms)
            {
                EditorGUIUtility.labelWidth = 120;
                for (int i = 0; i < Get.SpineBones.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();

                    GUI.enabled = false;
                    EditorGUILayout.ObjectField("Spine Bone [" + i + "]", Get.SpineBones[i].transform, typeof(Transform), true);
                    if (i != 0 && i != Get.SpineBones.Count - 1)
                    {
                        GUI.enabled = true;
                    }

                    if (GUILayout.Button("X", new GUILayoutOption[2] {
                        GUILayout.Width(20), GUILayout.Height(14)
                    }))
                    {
                        Get.SpineBones.RemoveAt(i);
                        EditorUtility.SetDirty(target);
                        break;
                    }

                    GUI.enabled = true;
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUIUtility.labelWidth = 0;
            }

            EditorGUILayout.EndVertical();

            EditorGUIUtility.labelWidth = 124f;
            EditorGUI.indentLevel--;

            EditorGUILayout.BeginVertical(FEditor_Styles.Style(new Color32(0, 200, 100, 22)));
            EditorGUILayout.BeginVertical(FEditor_Styles.Style(new Color32(0, 200, 100, 0)));
            GUILayout.Space(2f);
            EditorGUILayout.PropertyField(sp_SpineAnimatorAmount, true);
            GUILayout.Space(3f);

            EditorGUIUtility.labelWidth = 128f;

            GUI.color = new Color(0.3f, 1f, 0.4f, 0.8f);
            EditorGUILayout.PropertyField(sp_LastBoneLeading, true);
            GUI.color = preCol;

            GUILayout.Space(2f);

            //bool animatorDetected = CheckForAnimator(Get);
            //if (!animatorDetected && Get.SyncWithAnimator) GUI.color = new Color(1f, 0.2f, 0.2f, 0.8f);
            //else if (animatorDetected && Get.SyncWithAnimator == false) GUI.color = new Color(1f, 1f, 0.35f, 0.8f);

            //EditorGUIUtility.labelWidth = 163f;
            //EditorGUILayout.PropertyField(sp_SyncWithAnimator, true);
            GUI.color = preCol;

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

            EditorGUIUtility.labelWidth = 0f;

            EditorGUILayout.EndVertical();
            EditorGUI.indentLevel++;
        }

        #endregion

        #region Animation Options

        EditorGUILayout.BeginVertical(FEditor_Styles.LGrayBackground);
        drawAnimationOptions = EditorGUILayout.Foldout(drawAnimationOptions, "Animation Options", true);

        if (drawAnimationOptions)
        {
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            EditorGUI.indentLevel--;
            GUI.color = new Color(0.55f, 0.75f, 0.9f, 0.85f);

            GUILayout.BeginVertical(FEditor_Styles.Style(new Color32(33, 130, 200, 24)));

            EditorGUIUtility.labelWidth = 105f;
            GUILayout.Space(4f);

            Color preCc = GUI.color;

            if (Get.UseCollisions)
            {
                if (Get.UseTruePosition)
                {
                    if (Get.PosSmoother < 0.075f)
                    {
                        GUI.color = new Color(0.9f, 0.5f, 0.5f);
                    }
                    else if (Get.PosSmoother < 0.225f)
                    {
                        GUI.color = Color.Lerp(new Color(0.9f, 0.6f, 0.6f), preCc, Mathf.InverseLerp(0.075f, 0.225f, Get.PosSmoother));
                    }
                }
            }

            EditorGUILayout.PropertyField(sp_PositionsSmoother, true);
            GUI.color = preCc;

            EditorGUILayout.PropertyField(sp_RotationsSmoother, true);
            if (Get.PosSmoother > 0.1f || Get.Springiness > 0f)
            {
                EditorGUILayout.PropertyField(sp_MaxStretching, true);
            }
            GUILayout.Space(5f);

            EditorGUILayout.EndVertical();

            GUILayout.BeginVertical(FEditor_Styles.Style(new Color32(33, 130, 230, 58)));

            EditorGUILayout.PropertyField(sp_AngleLimit, true);
            EditorGUILayout.PropertyField(sp_LimitingAngleSmoother, true);

            EditorGUILayout.EndVertical();

            GUILayout.BeginVertical(FEditor_Styles.Style(new Color32(33, 130, 230, 58)));

            EditorGUIUtility.labelWidth = 120f;
            EditorGUILayout.PropertyField(sp_StraighteningSpeed, true);
            EditorGUIUtility.labelWidth = 0f;

            if (Get.StraightenSpeed > 0f)
            {
                EditorGUI.indentLevel++;
                EditorGUIUtility.labelWidth = 121f;
                EditorGUILayout.PropertyField(sp_TurboStraighten, true);
                EditorGUI.indentLevel--;
                GUILayout.Space(3f);
                EditorGUIUtility.labelWidth = 105f;
            }

            EditorGUILayout.EndVertical();

            GUILayout.BeginVertical(FEditor_Styles.LBlueBackground);

            EditorGUIUtility.labelWidth = 105f;

            if (!Get.LastBoneLeading)
            {
                if (Get.Springiness > 0)
                {
                    if (Get.GoBackSpeed <= 0)
                    {
                        GUI.color = new Color(0.55f, 0.9f, 1f, 1f);
                    }
                }
            }
            EditorGUILayout.PropertyField(sp_GoBackSpeed, true);
            EditorGUILayout.PropertyField(sp_Slithery, true);

            GUI.color = new Color(0.55f, 0.75f, 0.9f, 0.85f);


            if (!Get.LastBoneLeading)
            {
                if (Get.Springiness <= 0)
                {
                    if (Get.GoBackSpeed > 0.15f)
                    {
                        GUI.color = new Color(0.55f, 0.9f, 1f, 0.95f);
                    }
                }

                EditorGUILayout.PropertyField(sp_Springiness, true);
            }


            EditorGUILayout.EndVertical();

            EditorGUIUtility.labelWidth = 0f;
            EditorGUILayout.EndVertical();
            GUILayout.Space(5f);
            EditorGUI.indentLevel++;

            GUI.color = preCol;
        }

        EditorGUILayout.EndVertical();

        #endregion

        #region Basic Correction

        EditorGUILayout.BeginVertical(FEditor_Styles.LGrayBackground);

        EditorGUILayout.BeginHorizontal();
        drawQuickCorrection = EditorGUILayout.Foldout(drawQuickCorrection, "Main Tuning Options", true);

        GUI.color = preCol;

        EditorGUILayout.EndHorizontal();

        if (drawPreciseAutoCorr)
        {
            EditorGUILayout.BeginHorizontal();

            EditorGUI.indentLevel--;
            EditorGUIUtility.labelWidth = 74f;

            if (!headBone)
            {
                GUI.color = new Color(0.9f, 0.3f, 0.3f, 0.9f);
            }
            headBone  = (Transform)EditorGUILayout.ObjectField(new GUIContent("Head bone", "Head bone or some bone before, it's important to be in front of spine and not included in spine animator's chain"), headBone, typeof(Transform), true);
            GUI.color = preCol;

            EditorGUI.indentLevel++;
            EditorGUIUtility.labelWidth = 0f;

            EditorGUILayout.EndHorizontal();
        }

        if (drawQuickCorrection)
        {
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Space(3f);

            EditorGUIUtility.labelWidth = 146f;

            if (!Application.isPlaying)
            {
                EditorGUILayout.PropertyField(sp_StartAfterTPose, true);
            }

            GUILayout.Space(3f);
            EditorGUILayout.PropertyField(sp_MainPivotOffset, true);

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

            EditorGUILayout.EndVertical();
        }

        EditorGUILayout.EndVertical();

        #endregion

        #region Advanced correction

        EditorGUILayout.BeginVertical(FEditor_Styles.LGrayBackground);
        drawAdvancedCorrection = EditorGUILayout.Foldout(drawAdvancedCorrection, "Advanced Options", true);

        if (drawAdvancedCorrection)
        {
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            GUILayout.Space(4f);
            EditorGUIUtility.labelWidth = 144f;
            if (!Application.isPlaying)
            {
                EditorGUILayout.PropertyField(sp_PhysicalClock, true);
            }
            EditorGUILayout.PropertyField(sp_DeltaType);

            EditorGUIUtility.labelWidth = 166f;

            if (Get.AnchorRoot && !Get.UpdateAsLast)
            {
                GUI.color = new Color(0.5f, 1f, 0.65f, 0.85f);
            }

            if (!Application.isPlaying)
            {
                EditorGUILayout.PropertyField(sp_UpdateAsLast, true);
            }
            GUI.color = preCol;

            FEditor_Styles.DrawUILine(new Color(0.6f, 0.6f, 0.6f, 0.4f));

            GUILayout.BeginVertical(FEditor_Styles.Style(new Color32(33, 200, 130, 24)));
            EditorGUILayout.PropertyField(sp_LeadBoneRotationOffset, true);

            serializedObject.ApplyModifiedProperties();

            GUILayout.EndVertical();

            GUILayout.Space(4f);

            FEditor_Styles.DrawUILine(new Color(0.6f, 0.6f, 0.6f, 0.4f));

            EditorGUILayout.PropertyField(sp_SegmentsPivotOffset, true);
            EditorGUILayout.PropertyField(sp_DistancesMul, true);

            FEditor_Styles.DrawUILine(new Color(0.6f, 0.6f, 0.6f, 0.4f));

            GUILayout.Space(3f);
            EditorGUI.indentLevel++;

            EditorGUILayout.PropertyField(sp_ManualAffects, true);
            GUILayout.Space(5f);
            EditorGUI.indentLevel--;

            EditorGUIUtility.labelWidth = 0f;
            EditorGUILayout.EndVertical();
        }

        EditorGUILayout.EndVertical();

        #endregion


        #region Debug Options

        EditorGUILayout.BeginVertical(FEditor_Styles.LGrayBackground);
        drawDebug = EditorGUILayout.Foldout(drawDebug, "Debugging", true);

        if (drawDebug)
        {
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            GUILayout.BeginHorizontal(FEditor_Styles.LBlueBackground);
            EditorGUILayout.HelpBox("When 'DrawDebug' is toggled, you can use button '~' to instantly deactivate SpineAnimator's motion for time you hold this button (not on build)", MessageType.None);
            GUILayout.EndHorizontal();

            GUILayout.Space(5f);
            GUILayout.Space(5f);

            EditorGUIUtility.labelWidth = 0f;
            EditorGUILayout.EndVertical();
        }

        EditorGUILayout.EndVertical();

        #endregion


        EditorGUILayout.EndVertical();
        EditorGUI.indentLevel--;

        DrawPhysicalOptionsTab(Get);
    }
Example #10
0
        protected override void UpdateIn()
        {
            base.UpdateIn();

            Vector3 startPos  = transform.localPosition;
            Vector3 startPosW = transform.position;

            transform.localPosition = Vector3.Lerp(transform.localPosition, initialLocalPosition + transform.TransformVector(targetPositionOffset), Time.deltaTime * 7f * translationIncreaser);
            Vector3 postPosW = transform.position;

            float diff = Vector3.Distance(transform.localPosition, initialLocalPosition + transform.TransformVector(targetPositionOffset));

            translationIncreaser = Mathf.Lerp(translationIncreaser, Mathf.Lerp(1f, 3f, Mathf.InverseLerp(0.001f, 0.3f, diff)), Time.deltaTime * 8f);

            if (diff < 0.005f && velocity < 0.005f)
            {
                animationFinished = true;
            }
            else
            {
                animationFinished = false;
            }

            if (Holding)
            {
                canvasGroup.alpha = 0f;

                Sensitivity = -startSensitivity;

                if (ReversePull)
                {
                    Sensitivity *= -1f;
                }

                if (EnteredTransform)
                {
                    if (lookDot > 0f)
                    {
                        Sensitivity *= -1f;
                    }
                }

                PullValue  = Mathf.Clamp(YValue, 0f, 100f);
                PullValue /= 100f;

                if (YValue < 0f)
                {
                    YValue = 0f;
                }
                if (YValue > 100f)
                {
                    YValue = 100f;
                }

                UpdatePullableOrientation();

                float diffVel;
                if (NoDiffVelo)
                {
                    //Debug.Log("PRe pos, now pos: " + startPos + " , " + transform.position + " sum = " + SumVector(startPos) + " , " + SumVector(transform.position) + " diff = " + ((SumVector(startPos) - SumVector(transform.position))));
                    diffVel = diff * Mathf.Sign((initialLocalPosition - transform.localPosition).magnitude - targetPositionOffset.magnitude);
                }
                else
                {
                    //diffVel = diff * Mathf.Sign(SumVector(transform.position - startPos));
                    diffVel = diff * Mathf.Sign(SumVector(transform.InverseTransformVector(postPosW) - transform.InverseTransformVector(startPosW)));
                }

                //if (!ReversePull) diffVel = -diffVel;
                velocity = Mathf.Lerp(velocity, diffVel, Time.deltaTime * 12f);
            }
            else
            {
                velocity = Mathf.Lerp(velocity, 0f, Time.deltaTime * Deceleration);
                YValue  += velocity * (40 / DrawedPositionOffset.magnitude) * Time.deltaTime * 12f;

                if (YValue < 0f)
                {
                    YValue = 0f;
                }
                if (YValue > 100f)
                {
                    YValue = 100f;
                }

                PullValue = Mathf.Clamp(YValue, 0f, 100f);
                PullValue = YValue / 100f;

                targetPositionOffset = Vector3.Lerp(Vector3.zero, DrawedPositionOffset, PullValue);

                if (animationFinished)
                {
                    conditionalExit = false;
                }
            }

            if (ToEmmit)
            {
                if (mouseEntered)
                {
                    FColorMethods.LerpMaterialColor(ToEmmit.material, "_EmissionColor", Color.white * 0.3f);
                }
                else
                {
                    FColorMethods.LerpMaterialColor(ToEmmit.material, "_EmissionColor", Color.black);
                }
            }
        }