Esempio n. 1
0
        public static void CreateWindow(Vector2 r, CustomIconsDatabase database, string selectedGUID, Object selectedObj)
        {
            if (w != null)
            {
                w.Close();
            }

            w = (CustomIconsWindow)DisplayWizard("Custom Asset Icon", typeof(CustomIconsWindow), "");
            CustomIconsWindow.selectedGUID = selectedGUID;
            CustomIconsWindow.selectedObj  = selectedObj;

            selectedTex    = null;
            selectedTex_16 = null;

            Vector2 size = new Vector2(300, 220);

            Rect correctedRect = new Rect(r.x, r.y, 300, 200);

            correctedRect.y -= correctedRect.size.y + 15;
            correctedRect.x -= 20;
            w.position       = correctedRect;
            w.maxSize        = size;
            w.minSize        = size;

            databaseRef   = database;
            databaseIndex = databaseRef.ContainsGUID(selectedGUID);

            if (databaseRef != null && databaseIndex != -1)
            {
                databaseRef.SetName(databaseIndex, selectedObj.name);
            }

            CreateStyles();
        }
Esempio n. 2
0
        private void OnEnable() //EN CASO DE QUE PIERDA REFS AL RECARGAR
        {
            if (databaseRef == null)
            {
                databaseRef = CustomIconsDrawer.GetDatabase();
            }

            databaseIndex = databaseRef.ContainsGUID(selectedGUID);
            if (databaseIndex != -1)
            {
                databaseRef.SetName(databaseIndex, selectedObj.name);
            }
        }
Esempio n. 3
0
        private static void ItemGUI(string guid, Rect selectionRect)
        {
            if (guid == "")
            {
                return;
            }
            Event e = Event.current;

            if (selectionRect.Contains(e.mousePosition) && e.type == EventType.MouseDown)
            {
                if (e.button == 0)
                {
                    if (e.modifiers == EventModifiers.Alt)
                    {
                        if (databaseRef == null)
                        {
                            if (!FindDatabaseReference())
                            {
                                EditorUtility.DisplayDialog("Custom Icons Error", "No se encontró archivo de configuración de Custom Icons, vaya a Edit->Preferences->CustomIcons y cree o elija uno", "Ok");
                            }
                            return;
                        }
                        Vector2 mousePos = GUIUtility.GUIToScreenPoint(e.mousePosition);
                        OpenConfigWindow(guid, new Vector2(mousePos.x, mousePos.y + 10));
                    }
                }
            }
            if (databaseRef == null)
            {
                FindDatabaseReference(); return;
            }

            int databaseIndex = databaseRef.ContainsGUID(guid);

            if (databaseIndex != -1)
            {
                bool isLarge = IsLargeIcon(selectionRect);
                DrawIcon(selectionRect, isLarge ? databaseRef.GetAssetData(databaseIndex).icon : databaseRef.GetAssetData(databaseIndex).icon_16, isLarge);
            }
            else if (databaseRef.defaultIcon != null)
            {
                var type = File.GetAttributes(AssetDatabase.GUIDToAssetPath(guid));
                if ((type & FileAttributes.Directory) != FileAttributes.Directory)
                {
                    return;
                }
                DrawIcon(selectionRect, databaseRef.defaultIcon, IsLargeIcon(selectionRect));
            }
        }