Пример #1
0
 void addIconObject(GameObject gameObjectSlot, Texture2D iconSlot, Color color, bool addBox)
 {
     if (nData != null)
     {
         Undo.RecordObject(nData, "database");
         Undo.RegisterCompleteObjectUndo(nData, "databaseC");
         // Must call before making changes on scriptableObject
         EditorUtility.SetDirty(nData);
         // Add dummy icon data script!!!
         gameObjectSlot.AddComponent <IconData>().id = gameObjectSlot.GetInstanceID();
         HierarchyIcon h = new HierarchyIcon(gameObjectSlot.GetInstanceID(), color, iconSlot, addBox);
         if (isObjectInsideDatabase(h.objectId))
         {
             gameObjectSlot = null;
             EditorApplication.Beep();
             return;
         }
         nData.hierarchyIcon.Add(h);
         // repaint our hierarcy view to see the icon immediatly
         EditorApplication.RepaintHierarchyWindow();
     }
     else
     {
         isDatabaseSet = false;
     }
 }
Пример #2
0
 public PickIconWindow(HierarchyIcon hierarchyIcon) : this(new SerializedObject(hierarchyIcon).FindProperty("icon"))
 {
     if (m_iconProperty == null)
     {
         Debug.LogError("'icon' property not found in the HierarchyIcon script.");
     }
 }
Пример #3
0
 void OnEnable()
 {
     m_iconProperty      = serializedObject.FindProperty("icon");
     m_tooltipProperty   = serializedObject.FindProperty("tooltip");
     m_positionProperty  = serializedObject.FindProperty("position");
     m_directionProperty = serializedObject.FindProperty("direction");
     m_hierarchyIcon     = target as HierarchyIcon;
 }
Пример #4
0
    /// <summary>
    /// change the visual of the editor config for this object
    /// </summary>
    /// <param name="selectedObject"></param>
    /// <param name="iconType"></param>
    /// <param name="_IsIconRecursive"></param>
    /// <param name="coreBackground"></param>
    /// <param name="_IsBackgroundRecursive"></param>
    public static void AddCustomEditorToObject(GameObject selectedObject, bool create = true,
                                               HierarchyIcon iconType = HierarchyIcon.None,
                                               bool _IsIconRecursive  = false,
                                               Borodar.RainbowCore.CoreBackground coreBackground = Borodar.RainbowCore.CoreBackground.None,
                                               bool _IsBackgroundRecursive = false)
    {
        GameObject           hierarchy            = GameObject.Find("RainbowHierarchyConf");
        HierarchySceneConfig hierarchySceneConfig = hierarchy.GetComponent <HierarchySceneConfig>();

        if (hierarchySceneConfig)
        {
            HierarchyItem newItem = hierarchySceneConfig.GetItem(selectedObject);
            if (newItem == null)
            {
                if (!create)
                {
                    return;
                }

                newItem = new HierarchyItem(HierarchyItem.KeyType.Object, selectedObject, selectedObject.name)
                {
                    IconType              = HierarchyIcon.None,
                    IsIconRecursive       = false,
                    BackgroundType        = Borodar.RainbowCore.CoreBackground.ClrIndigo,
                    IsBackgroundRecursive = false,
                };
                hierarchySceneConfig.AddItem(newItem);
            }
            else
            {
                if (!create)
                {
                    hierarchySceneConfig.RemoveAll(selectedObject, HierarchyItem.KeyType.Object);
                }
                else
                {
                    hierarchySceneConfig.RemoveAll(selectedObject, HierarchyItem.KeyType.Object);
                    newItem = new HierarchyItem(HierarchyItem.KeyType.Object, selectedObject, selectedObject.name)
                    {
                        IconType              = HierarchyIcon.None,
                        IsIconRecursive       = false,
                        BackgroundType        = Borodar.RainbowCore.CoreBackground.ClrIndigo,
                        IsBackgroundRecursive = false,
                    };
                    hierarchySceneConfig.AddItem(newItem);
                }
            }
        }
    }
    static void GetComponentsAndPrintThem(GameObject obj, Rect selectionRect)
    {
        HierarchyIcon HierarchyIcon = obj.GetComponent <HierarchyIcon>();

        if (HierarchyIcon != null)
        {
            if (HierarchyIcon.Icons == null)
            {
                return;
            }

            for (int ib = 0; ib < HierarchyIcon.Icons.Count && ib < 5; ib++)
            {
                if (HierarchyIcon.Icons[ib] == null)
                {
                    continue;
                }

                Rect r = new Rect(selectionRect);
                r.x     = r.width - ((ib + 1) * 12);
                r.width = 18;
                GUI.Label(r, new GUIContent(HierarchyIcon.Icons[ib]));
            }
        }
        HierarchyIcon[] HierarchyIcons = obj.GetComponentsInChildren <HierarchyIcon>();
        for (int i = 0; i < HierarchyIcons.Length; i++)
        {
            for (int ic = 0; ic < HierarchyIcons[i].Icons.Count && ic < 10; ic++)
            {
                if (HierarchyIcons[i].Icons[ic] == null)
                {
                    continue;
                }

                Rect r = new Rect(selectionRect);
                r.x     = r.width - ((ic + 1) * 8);
                r.width = 9;
                GUI.Label(r, new GUIContent(HierarchyIcons[i].Icons[ic]));
            }
        }
    }