So I’m new to Unity, and I’m trying to get a manager component to enable and disable other components, but I’m having difficulty in actually running the other components’ code.
I was initially believing that the enable variable had a custom setter and getter that would call OnEnable() if set to true, but I was proved wrong (so I’ll have to change the above code to reflect my findings). What is the correct way to coax the other MonoBehaviour-derived component to call their OnEnable() functions? Also, on a side note: I’ve noticed that public variables in a class do not reflect those variables in the Inspector if they have a custom setter and getter. Why is this so? Example:
All right. After getting a little more familiar with Unity I realized that I had not instantiated the components because they were sitting in a prefab, and after instantiating my ServerObject and ClientObject into the scene, I then linked the appropriate gameObjects into the NetworkBehaviour instance, and it worked perfectly.
So a little lesson on those of you new to Unity: If something’s not working, make sure it and its dependencies are instantiated in the scene.