public static void SetIcon(this GameObject gObj, IconManager.Icon icon) { if (icon == IconManager.Icon.None) { IconManager.RemoveIcon(gObj); } else { IconManager.SetIcon(gObj, icon); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); WaypointPath waypointPath = target as WaypointPath; if (waypointPath == null) { return; } Transform transform = waypointPath.transform; Transform[] children = transform.GetChildren(); int tagColorIdx = Mathf.Clamp(waypointPath.tagColorIndex, -1, 7); int newSelection = EditorGUILayout.IntPopup("Set Tag Color", tagColorIdx, colorNames, colorValues); if (tagColorIdx != newSelection) { waypointPath.tagColorIndex = newSelection; children.ForEach((child) => IconManager.SetIcon(child.gameObject, (IconManager.LabelIcon)newSelection)); } EditorGUILayout.BeginHorizontal(); if (tagColorIdx == -1 && GUILayout.Button("Show Tags")) { children.ForEach((child) => IconManager.SetIcon(child.gameObject, (IconManager.LabelIcon)tagColorIdx)); } else if (tagColorIdx != -1 && GUILayout.Button("Hide Tags")) { children.ForEach((child) => IconManager.SetIcon(child.gameObject, IconManager.LabelIcon.None)); waypointPath.tagColorIndex = -1; } if (GUILayout.Button("Name Children")) { Array.Sort(children, (a, b) => { float aDist = a.DistanceToSquared(transform.position); float bDist = b.DistanceToSquared(transform.position); return(aDist < bDist ? -1 : 1); }); children.ForEachIndex((child, index) => { child.SetSiblingIndex(index); child.name = transform.name + "[" + index + "]"; }); } EditorGUILayout.EndHorizontal(); }
public static void SetIcon(this GameObject gObj, Texture2D texture) { IconManager.SetIcon(gObj, texture); }