コード例 #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();
        }
コード例 #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);
            }
        }
コード例 #3
0
        public static string TryFindDefaultDatabase()
        {
            CustomIconsDatabase defaultDb = (CustomIconsDatabase)Resources.Load("DefaultIconsDb");

            if (defaultDb != null)
            {
                return(AssetDatabase.GetAssetPath(defaultDb));
            }
            else
            {
                return("");
            }
        }
コード例 #4
0
ファイル: CustomIconsPref.cs プロジェクト: Mati3694/Final-IA2
        static public void CustomIconsPrefGUI()
        {
            GUILayout.Label("Config file", EditorStyles.boldLabel);

            if (ConfigPathIsSet && configPath != CurrentConfigPath)
            {
                configPath = CurrentConfigPath;
            }

            GUILayout.Label(configPath, EditorStyles.helpBox);

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Load File"))
            {
                string filePath;

                if (configPath != "")
                {
                    string openAtPath = Application.dataPath.Replace("Assets", "") + configPath;
                    openAtPath = Path.GetDirectoryName(openAtPath);
                    filePath   = EditorUtility.OpenFilePanel("Create Custom Icons config file", openAtPath, "asset");
                }
                else
                {
                    filePath = EditorUtility.OpenFilePanel("Create Custom Icons config file", Application.dataPath, "asset");
                }

                if (filePath == "")
                {
                    return;
                }

                string assetPath = "Assets" + filePath.Split(new string[1] {
                    "Assets"
                }, System.StringSplitOptions.None)[1];

                configPath = assetPath;
                SaveConfigPath(configPath);
                CustomIconsDrawer.FindDatabaseReference();
            }

            if (GUILayout.Button("Create File"))
            {
                string filePath;

                if (configPath != "")
                {
                    string openAtPath = Application.dataPath.Replace("Assets", "") + configPath;
                    openAtPath = Path.GetDirectoryName(openAtPath);
                    filePath   = EditorUtility.SaveFilePanelInProject("Create Custom Icons config file", "CustomIconsConfig", "asset", "Select or create a new config file", openAtPath);
                }
                else
                {
                    filePath = EditorUtility.SaveFilePanelInProject("Create Custom Icons config file", "CustomIconsConfig", "asset", "Select or create a new config file", Application.dataPath);
                }

                if (filePath == "")
                {
                    return;
                }

                CustomIconsDatabase file = (CustomIconsDatabase)AssetDatabase.LoadAssetAtPath(filePath, typeof(CustomIconsDatabase));
                if (file == null)
                {
                    file = ScriptableObject.CreateInstance <CustomIconsDatabase>();
                    AssetDatabase.CreateAsset(file, filePath);
                    AssetDatabase.Refresh();
                }

                configPath = filePath;
                SaveConfigPath(configPath);
                CustomIconsDrawer.FindDatabaseReference();
            }

            GUILayout.EndHorizontal();

            if (GUILayout.Button("ERASE PREFS"))
            {
                if (EditorUtility.DisplayDialog("Borrando configuración", "¿Está seguro que desea borrar la configuración de este proyecto? Esta operación es irreversible.", "Sí", "No"))
                {
                    EraseConfigPath();
                    configPath = "";
                }
            }
        }
コード例 #5
0
 public static bool FindDatabaseReference()
 {
     databaseRef = GetDatabase();
     return(databaseRef != null);
 }