A
A
Alexander Andropov2018-06-10 18:43:31
Unity
Alexander Andropov, 2018-06-10 18:43:31

How to execute a function (part of code) when an object becomes active?

Good afternoon friends. There are 6 objects of type UI.Panel, each of them has the same script.
They are all disabled by default. When they become active, I need them to perform a function once.
If I throw all this into the Start () method, then only once it happens. And it is necessary for me, when each time there is an activation, that the function was executed. As the action progresses, these panels are activated and deactivated.
Here at each activation how to execute the function? Thanks for your help .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2018-06-10
@LongOf

You need the OnEnable function .
I also highly recommend reading this article.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question