Exemplo n.º 1
0
        void createNewWeaponDB()
        {
            // 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;
            weaponDB  = CreateInstance <WeaponDatabase>();
            string destintation = dir + "WeaponDB.asset";

            AssetDatabase.CreateAsset(weaponDB, destintation);
            AssetDatabase.SaveAssets();
            if (weaponDB)
            {
                weaponDB.weapons = new List <WeaponData>();
                string relPath = AssetDatabase.GetAssetPath(weaponDB);
                EditorPrefs.SetString("WeaponsPath", relPath);
                EditorUtility.FocusProjectWindow();
                Selection.activeObject = weaponDB;
            }
        }
Exemplo n.º 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");
            }
        }