How to make so that in the inspector I chose what method to me to use?
How to make so that in the inspector I chose what method to me to use?
Script has two methods. How to make so that in the inspector I chose what method to me to use.
public void PrintHello()
Debug.Log("Hello");
public void PrintHowAreYou()
Debug.Log("How are you?");
these methods I wrote as an example.
1 Answer
1
You can use UnityEvent to allow you pick a function from the Editor Inspector tab.
UnityEvent
Declare it as:
public UnityEvent method;
From the Editor, you can select the GameObject this script is attached to, the name of the script then the function.
If you need to call that method, it is really easy to do:
void Start()
method.Invoke();
You're welcome. Don't forget to accept this answer by clicking on the check-mark image on the left side of it. See this post for more information
– Programmer
Aug 29 at 16:40
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Thanks very much!
– StackBeginner
Aug 25 at 21:55