private void DrawSkeleton(BioSegment segment)
 {
     if (!StopDraw(segment))
     {
         if (segment.Parent != null)
         {
             DrawLine(segment.Parent.GetAnchoredPosition(), segment.GetAnchoredPosition(), 5f, Color.cyan);
         }
         for (int i = 0; i < segment.Childs.Length; i++)
         {
             DrawSkeleton(segment.Childs[i]);
         }
     }
 }
        private void DrawSegment(BioSegment segment, bool final)
        {
            Vector3 P = segment.GetAnchoredPosition();

            if (Target.SelectedSegment == segment && final)
            {
                DrawSphere(P, 0.25f, new Color(0f, 0f, 0f, 0.4f));
                DrawSphere(P, 0.02f, Color5);
            }
            else if (Target.SelectedSegment != segment)
            {
                DrawSphere(P, 0.02f, Color.cyan);
            }
            if (segment.Joint != null)
            {
                DrawJoint(segment.Joint, final);
            }
            for (int i = 0; i < segment.Objectives.Length; i++)
            {
                DrawObjective(segment.Objectives[i], final);
            }
        }
        private void InspectSegment(BioSegment segment)
        {
            Undo.RecordObject(segment, segment.name);

            SetGUIColor(Color13);
            using (new EditorGUILayout.VerticalScope("Box")) {
                SetGUIColor(Color4);
                Vector3 A = segment.Parent == null?segment.GetAnchoredPosition() : segment.Parent.GetAnchoredPosition();

                Vector3 B = segment.GetAnchoredPosition();
                EditorGUILayout.HelpBox("Link Length: " + Vector3.Distance(A, B), MessageType.None);

                SetGUIColor(Color6);
                using (new EditorGUILayout.VerticalScope("Box")) {
                    if (segment.Joint == null)
                    {
                        GUI.skin.button.alignment = TextAnchor.MiddleCenter;
                        SetGUIColor(Color1);
                        if (GUILayout.Button("Add Joint"))
                        {
                            segment.AddJoint();
                        }
                    }
                    else
                    {
                        InspectJoint(segment.Joint);
                    }
                }
            }

            for (int i = 0; i < segment.Objectives.Length; i++)
            {
                SetGUIColor(Color13);
                using (new EditorGUILayout.VerticalScope("Box")) {
                    SetGUIColor(Color9);
                    using (new EditorGUILayout.VerticalScope("Box")) {
                        InspectObjective(segment.Objectives[i]);
                    }
                }
            }

            SetGUIColor(Color13);
            using (new EditorGUILayout.VerticalScope("Box")) {
                SetGUIColor(Color9);
                using (new EditorGUILayout.VerticalScope("Box")) {
                    GUI.skin.button.alignment = TextAnchor.MiddleCenter;
                    SetGUIColor(ChosingObjectiveType ? Color14 : Color1);
                    if (GUILayout.Button("Add Objective"))
                    {
                        ChosingObjectiveType = !ChosingObjectiveType;
                    }
                    if (ChosingObjectiveType)
                    {
                        SetGUIColor(Color8);
                        using (new EditorGUILayout.VerticalScope("Box")) {
                            int      count = System.Enum.GetValues(typeof(ObjectiveType)).Length;
                            string[] names = System.Enum.GetNames(typeof(ObjectiveType));
                            for (int i = 0; i < count; i++)
                            {
                                SetGUIColor(Color1);
                                if (GUILayout.Button(names[i]))
                                {
                                    ChosingObjectiveType = false;
                                    segment.AddObjective((ObjectiveType)i);
                                }
                            }
                        }
                    }
                }
            }

            if (segment != null)
            {
                EditorUtility.SetDirty(segment);
            }
        }