Exemple #1
0
        void createNewCharDB()
        {
            // There is no overwrite protection here!
            // There is No "Are you sure you want to overwrite your existing object?" if it exists.
            // This should probably get a string from the user to create a new name and pass it ...
            viewIndex = 1;
            charDB    = CreateInstance <CharacterDatabase>();
            string destintation = dir + "CharDB.asset";

            AssetDatabase.CreateAsset(charDB, destintation);
            AssetDatabase.SaveAssets();
            if (charDB)
            {
                charDB.lists = new List <CharactersInfo>();
                string relPath = AssetDatabase.GetAssetPath(charDB);
                EditorPrefs.SetString("CharPath", relPath);
                EditorUtility.FocusProjectWindow();
                Selection.activeObject = charDB;
            }
        }
Exemple #2
0
        void OnEnable()
        {
            dir       = "Assets/Data/";
            toShow    = SHOW.NOTHING;
            viewIndex = 1;
            EditorPrefs.SetString("ObjectPath", dir);

            if (EditorPrefs.HasKey("SettingsPath"))
            {
                string path = EditorPrefs.GetString("SettingsPath");
                settingsDB = AssetDatabase.LoadAssetAtPath <SettingsDatabase>(path);
            }
            else
            {
                settingsDB = AssetDatabase.LoadAssetAtPath <SettingsDatabase>("Assets/Data/SettingsDB.asset");
            }

            if (EditorPrefs.HasKey("ItemsPath"))
            {
                string path = EditorPrefs.GetString("ItemsPath");
                itemDB = AssetDatabase.LoadAssetAtPath <ItemDatabase>(path);
            }
            else
            {
                itemDB = AssetDatabase.LoadAssetAtPath <ItemDatabase>("Assets/Data/ItemDB.asset");
            }

            if (EditorPrefs.HasKey("WeaponsPath"))
            {
                string path = EditorPrefs.GetString("WeaponsPath");
                weaponDB = AssetDatabase.LoadAssetAtPath <WeaponDatabase>(path);
            }
            else
            {
                weaponDB = AssetDatabase.LoadAssetAtPath <WeaponDatabase>("Assets/Data/WeaponDB.asset");
            }

            if (EditorPrefs.HasKey("EnvPath"))
            {
                string path = EditorPrefs.GetString("EnvPath");
                envDB = AssetDatabase.LoadAssetAtPath <EnvironmentDatabase>(path);
            }
            else
            {
                envDB = AssetDatabase.LoadAssetAtPath <EnvironmentDatabase>("Assets/Data/EnvDB.asset");
            }

            if (EditorPrefs.HasKey("SupplyPath"))
            {
                string path = EditorPrefs.GetString("SupplyPath");
                supplyDB = AssetDatabase.LoadAssetAtPath <SupplyDatabase>(path);
            }
            else
            {
                supplyDB = AssetDatabase.LoadAssetAtPath <SupplyDatabase>("Assets/Data/SupplyDB.asset");
            }

            if (EditorPrefs.HasKey("CharPath"))
            {
                string path = EditorPrefs.GetString("CharPath");
                charDB = AssetDatabase.LoadAssetAtPath <CharacterDatabase>(path);
            }
            else
            {
                charDB = AssetDatabase.LoadAssetAtPath <CharacterDatabase>("Assets/Data/CharDB.asset");
            }
        }