Hello,
I want to call some object’s some function which can be assigned in inspector in my C# script.
It’s perfect if I can assign object and function just like Button UI’s OnClick stuff.
How can I do that? Any idea will be appreciated.
Hello,
I want to call some object’s some function which can be assigned in inspector in my C# script.
It’s perfect if I can assign object and function just like Button UI’s OnClick stuff.
How can I do that? Any idea will be appreciated.
Add a UnityEvent property to your script.
public class ExampleClass : MonoBehaviour
{
public UnityEvent myEvent;
void Start()
{
myEvent.Invoke();
}
}
If you want to support an argument then do this: Unity - Scripting API: UnityEvent<T0>
Wow! That’s exactly what I wanted. Thank you very much!
I was searching for this simple thing for far too long. Thank you.
That was exactly what i was looking for.
nice thanks man ![]()
thank you
This is so useful
Can you please tell me how to launch this type of function in unity script