using UnityEngine; using UnityEditor; namespace BioIK { [CustomEditor(typeof(BioIK))] public class BioIKEditor : Editor { public BioIK Target; public Transform TargetTransform; private Color Color1 = Color.white; //private Color Color2 = Color.black; private Color Color3 = new Color(0.6f, 0.6f, 0.6f, 1f); private Color Color4 = new Color(0.3f, 0.8f, 0.8f, 1f); private Color Color5 = new Color(1f, 0.7f, 0.3f, 1f); private Color Color6 = new Color(0.9f, 0.3f, 0.9f, 1f); private Color Color7 = new Color(1.0f, 0.3f, 0.3f, 1f); private Color Color8 = new Color(0.3f, 0.6f, 0.6f, 1f); private Color Color9 = new Color(0.4f, 0.9f, 0.4f, 1f); //private Color Color10 = new Color(1f, 0.5f, 1f, 1f); private Color Color11 = new Color(0.3f, 0.3f, 0.3f, 1f); //private Color Color12 = new Color(0.9f, 0.6f, 0.9f, 1f); private Color Color13 = new Color(0.5f, 0.5f, 0.5f, 1f); private Color Color14 = new Color(0.75f, 0.75f, 0.75f, 1f); private bool ChosingObjectiveType = false; private bool IsPlaying = false; private bool IsEnabled = false; private int DoF; void Awake() { EditorApplication.playmodeStateChanged += PlaymodeStateChanged; Target = (BioIK)target; TargetTransform = Target.transform; Target.Refresh(false); DoF = 0; //MakeVisible(TargetTransform); //MakeInvisible(TargetTransform); } void OnEnable() { IsEnabled = true; } void OnDisable() { IsEnabled = false; } private void MakeVisible(Transform t) { if(t.GetComponent()) { t.GetComponent().hideFlags = HideFlags.None; } foreach(BioObjective o in t.GetComponents()) { o.hideFlags = HideFlags.None; } if(t.GetComponent()) { t.GetComponent().hideFlags = HideFlags.None; } for(int i=0; i()) { t.GetComponent().hideFlags = HideFlags.HideInInspector; } foreach(BioObjective o in t.GetComponents()) { o.hideFlags = HideFlags.HideInInspector; } if(t.GetComponent()) { t.GetComponent().hideFlags = HideFlags.HideInInspector; } for(int i=0; i 0) { SetGUIColor(Color13); using(new EditorGUILayout.VerticalScope ("Box")) { int width = 10*(indent-1); EditorGUILayout.LabelField("", GUILayout.Width(width)); } } } GUI.skin.button.alignment = TextAnchor.MiddleLeft; if(segment == Target.SelectedSegment) { SetGUIColor(Color5); } else { SetGUIColor(Color.Lerp(Color4, Color8, (float)indent / (float)maxIndent)); } if(GUILayout.Button(segment.Transform.name, GUILayout.Height(25f), GUILayout.ExpandWidth(true))) { if(Target.SelectedSegment == segment) { Target.SelectedSegment = null; ChosingObjectiveType = false; } else { Target.SelectedSegment = segment; } } EditorGUILayout.EndHorizontal(); if(Target.SelectedSegment == segment) { InspectSegment(segment); } else { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if(segment.Joint != null) { SetGUIColor(Color6); GUILayout.Box(" Joint "); } foreach(BioObjective objective in segment.Objectives) { SetGUIColor(Color9); GUILayout.Box(" " + objective.GetObjectiveType().ToString() + " "); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } } for(int i=0; i