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();





Thanks very much!
– StackBeginner
Aug 25 at 21:55





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.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

Node.js puppeteer - Use values from array in a loop to cycle through pages