0

I have this problem. I wrote a script with a method when interacting with which the player exits the game, but when I wanted to bind it to the button, and I realised that it didn’t work . In the OnClick() component, I attached my script, but for some reason the method is not attached.How can I attach my method?

enter image description here

2
  • Please use the correct tags! Note that [unityscript] is or better was a custom JavaScript flavor-like language used in early Unity versions and is long deprecated by now. Also [unity-container] is completely unrelated! Commented Apr 20, 2022 at 14:01
  • Please provide enough code so others can better understand or reproduce the problem. Commented Apr 20, 2022 at 20:49

1 Answer 1

1

Create an empty GameObject, attach your credits.cs to it then assign this gameobject to the OnClick(), then Credits > (Your method).

Make sure your method is public.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.