- Home /
Question by
MasterChameleonGames · Jun 09, 2019 at 11:29 PM ·
classinitialization
Initialize Class Set as Serializable and Set in the Inspector as a Variable
If I have a class set as serializable and its instance is edited in the inspector, is there any way to get an initializing function to be called on it without calling it from another class?
For example,
[Serializable]
public class Character {
public string name;
}
public class CharacterHandler : Monobehaviour {
public Character John;
}
// I want to somehow initialize John
// But not like this
public class CharacterHandler : Monobehaviour {
void Start() {
John.InitializeInstance();
}
}
public class John {
Initializeinstance() {
}
}
Also, can't use ScriptableObjects, the class will have references to other GameObjects.
Comment