- Home /
Loading data before CustomEditor
Hi all,
I am trying to write a custom unit editor, so I could customise the unit to be inserted into different levels.
[Problem]
I have already written a class LoadData to load different data from text files and stores them in Config (Singleton class), which is currently only runs during Play. Now I wish to customise them in custom editor and add them to the scene. But since the data is loaded during runtime, they cannot be access in the CustomEditor... I have tried adding [ExecuteInEditMode]
in the LoadData class... (Should be wrong?)
[ExecuteInEditMode]
public Class LoadDataClass: MonoBehaviour
void LoadData(){
Read ( skillsCVS, ref Config.SKILLS );
Read ( minionsCVS, ref Config.MINIONS );
Read ( heroesCVS, ref Config.HEROES );
}
void Read( TextAsset txtFile, ref List<Unit> list ){
[Code to read data and add to list]
}
}
Should I shift the data loading code somewhere else? Or is there a better way of doing it? Appreciated if someone could guide me in some way? BTW, I'm a Unity noob, using 4.6.1
You should always post relevant code, this will make it easier to help you.
Your answer
Follow this Question
Related Questions
Strategy for 'recording' data 2 Answers
Developing a 3d data editor 3 Answers
Some Text crash after few force closing of Unity Editor 2 Answers
How to store data in an object in a scene (in the editor) 1 Answer