- Home /
 
               Question by 
               Ambrose998800 · Jan 12, 2017 at 01:57 AM · 
                functionactivate  
              
 
              Function by activate
Is there a function in C# that is called when the object the script is added to is set to active? Without calling it from outside and just called 1x.
Is there a way around fooling with Update()?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Pengocat · Jan 12, 2017 at 02:09 AM
Yes if the script derives from MonoBehaviour you can use OnEnable.
     // This function is called when the object becomes enabled and active
     void OnEnable()
     {
 
     }
Whoa, thanks! Never saw this function, but it will makes so many things easier!
You're welcome. Yes it is very handy indeed. OnDisable is also helpful.
Your answer
 
 
             Follow this Question
Related Questions
Activating function in distant item 0 Answers
Public functions not calling and scripts not being set to active 0 Answers
Unexpected token 0 Answers
Call a function across several objects 1 Answer
Yielding in between functions... 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                