コード例 #1
0
        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();
        }
コード例 #2
0
ファイル: IconManager.cs プロジェクト: weichx/SpaceGame
 public static void RemoveIcon(this GameObject gObj)
 {
     IconManager.RemoveIcon(gObj);
 }
コード例 #3
0
ファイル: IconManager.cs プロジェクト: weichx/SpaceGame
 public static void SetIcon(this GameObject gObj, Texture2D texture)
 {
     IconManager.SetIcon(gObj, texture);
 }