Prefabricated Object (Button) Scripts

Asked 2 years ago, Updated 2 years ago, 82 views

It's only been 5 days since I started Unity.I'm sorry for the rudimentary content, but could you tell me about the prefabricated content?

Is it normal to create a click event on a button, inspect a script, and then prefabricate that button, and then the event or script disappears?
 
If prefabricated is a reusable part, I thought scripts would be included in the prefabricated...

Thank you for your guidance.

unity3d ugui

2022-09-29 22:34

1 Answers

You may not know exactly what's going on, but I guess it's probably because the prefabricated GameObject with the script attached is not included.

If you include a GameObject with a script attached in the prefabrication, such as attaching a script to the button itself or attaching a GameObject with the script to the child of the button (nested), it will be solved.

I have confirmed that the simple project on hand will cause the problem and that the above method will solve the problem.Please try it if you like.


2022-09-29 22:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.