Asset database creation problem
Hi there,
I've been running into a strange problem which I can't seem to get around. I'm not sure how to explain it clearly but i'll try.
I'm trying to create an asset database which stores data about some 'achievements' in my game. I've already dealt with unity's CreateAssets to build databases once or twice in unity 5.4. This time i'm working on an older project using unity 5.1.
The way I'm doing it is I believe pretty standard : I have an Achievement class :
public class Achievement {
public string _name;
public string _description;
public level _level;
public bool _get;
public AnimationClip _anim;
public Achievement () {
_name = "default"+count;
_description = "no description";
_level = level.None;
_get = false;
}
}
an AchievementLibrary class :
public class AchievementLibrary : ScriptableObject {
public List<Achievement> _achievements = new List<Achievement>();
}
, and a custom editor in an AchievementEditor class. I'm not putting all classes code in detail right now since it does'nt seem like my problem comes from the code. I'll put more if it's needed.
The problem in itself is : when i use my custom editor to create the asset database (same with CreateAssetMenu), the file gets created, but when looking the database file in the inspector, where it should be referencing the AchievementLibrary class (or type ? can't really tell the diference) it says : none (Mono Script). A picture might be clearer but i don't know how to insert one.
Then it gets wierder : Even though the database says it's missing a script, it works fine. There's no error in the console, still none if i open my custom editor window and i can add, remove and edit elements in the database as would seem normal.
If I manually add the corresponding AchievementLibrary script to the database, it takes it in and a warning label says : The associated script can not be loaded. Please fix any compile errors and assign a valid script. But of course, i don't have any compile errors, and if I edit the script by, say, adding or removing useless spaces and save, the warning disapears.
If I then open my custom editor again, the file gets reset (or rather the code fails to load the existing one and overwrites it with a new one). If I leave the application and restart, the same happens, yet I did place EditorUtility.SetDirty() in supposedly the correct places (and, from my research, set dirty should still work in 5.1).
I don't know if it's a bug or what, but I don't get any of it and my database is useless if I can't save it. So if anyone had an explanation and|or a solution to make it work I'd apreciate it quite a lot.