コード例 #1
0
        private static void DrawColoredBackground(Rect selectionRect, Folder folder)
        {
            var color = folder.folderColor;

            color.a = 0.3f;
            EditorGUIHelper.SaveGUIColor(color);
            GUI.Box(selectionRect, string.Empty);
            EditorGUIHelper.RestoreGUIColor();
        }
コード例 #2
0
        private static void OnHierarchyGUI(int instanceID, Rect selectionRect)
        {
            // Get icon if it unassigned
            if (hNote16 == null)
            {
                hNote16 = EditorGUIUtility.Load(ICON_16_PATH) as Texture2D;
            }

            var obj = EditorUtility.InstanceIDToObject(instanceID) as GameObject;

            if (obj == null)
            {
                return;
            }
            var note = obj.GetComponent <Note>();

            if (note != null || obj.GetComponentInChildren <Note>() != null)
            {
                var parents      = GetParents(obj.transform);
                var noteIconRect = new Rect(selectionRect);
                noteIconRect.x     = (selectionRect.width - 18) + (parents.Length * 14);
                noteIconRect.width = 20;

                var maxCharacters = 200;
                var text          = string.Empty;

                if (note != null)
                {
                    text = note.text.Length > maxCharacters?note.text.Substring(0, maxCharacters - 3) + "..." : note.text;
                }
                else
                {
                    text = string.Format("Child '{0}' has note", obj.GetComponentInChildren <Note>().name);
                    EditorGUIHelper.SaveGUIColor(new Color(1f, 1f, 1f, 0.4f));
                }

                if (GUI.Button(noteIconRect, new GUIContent(hNote16, text), GUIStyle.none) && note == null)
                {
                    Selection.activeObject = obj.GetComponentInChildren <Note>();
                    EditorGUIUtility.PingObject(Selection.activeObject);
                }

                if (note == null)
                {
                    EditorGUIHelper.RestoreGUIColor();
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Draws folder icon at full opacity.
        /// </summary>
        private static void DrawFolderIcon(Rect selectionRect, Folder folder, int parentCount)
        {
            var color = folder.folderColor;

            color.a = 1f;
            EditorGUIHelper.SaveGUIColor(color);

            var folderIconRect = new Rect(selectionRect);

            // tab size == HIERARCHY_LEVEL * 7
            // Root level object would have tab of 0 * 7 == 0
            // First level object would have tab of 1 * 7 == 7
            // etc...
            folderIconRect.x = (selectionRect.width - 2) + (parentCount * 14);

            folderIconRect.width = 20;

            GUI.Label(folderIconRect, hFolder16);
            EditorGUIHelper.RestoreGUIColor();
        }