Пример #1
0
        private static void OnHierarchyGUI(int instanceID, Rect selectionRect)
        {
            var obj  = EditorUtility.InstanceIDToObject(instanceID) as GameObject;
            var note = obj.GetAsNote();

            if (obj == null)
            {
                return;
            }

            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();
                }
            }
        }
Пример #2
0
        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();
        }