- Home /
Function that triggers something as soon as Object is "Set Active"
Start() doesnt work for this and I dont think Awake() does either. Anybody know something that does?
Answer by Rawkjs · Sep 02, 2013 at 07:15 PM
I think you could use the OnEnable hook on the Monobehaviour. It gets called when an object is set active or your component is enabled.
void OnEnable ()
{
Gun.Instance.ResetGuns();
Debug.Log("Reset Guns");
}
Like this? Because then it doesn't work unfortunately.
Answer by DDP · Sep 02, 2013 at 06:51 PM
What about making your own function in a component, and call gameObject.SetActive() in that function? Then you can use delegates or whatever.
Well I have a function called "Spawn" where the object is set Active, but apparently you cant call functions in an RPC, which is why I am asking.
Answer by jmschuaquico · Sep 03, 2013 at 04:18 AM
OnEnable() is the one triggered then setting an object active.
Do you know how I could get this to work on C#? Because I already tried (if you look at previous answers) and it didn't work with a simple "void". I don't really need it anymore though, I'm just curious.