0
votes

So I have a prefab which containcs another prefab with a group of buttons. So in one of the buttons I want to attach on the onClick enviroment a gameObject which is in my scene to get its scripts and finally its methods. I can attach just the script but I cannot find the methods of it(They are public). I can't look into the prefab and at the same time at the game object so that I drag and attach into the onClick button. When I click one the other disappears. Any suggestions?

Here is the picture of the prefab that containts the prefab of the group of buttons. Which has the UI Script (that I dragged and dropped) but doesnt have its functions(Public).

enter image description here

And here is the Canvas(Game object) which has the Script on it (UIManager) that I want the button to get its methods from. But when I click to canvas the prefab dissapears so I cant drag and drop it.

enter image description here

Thank you...

1
Can you post some screens? Your question is not really clear.Saeleas
@saeleas sure. second!Alex Rika
You could try and "lock" the MainMenu prefab using the lock icon in the upper right corner of the inspector tab. Then you can drag the canvas without the prefab disappearing. Still, I don't think you can attach a scene object to a prefab script.Saeleas
yeah wont work...Alex Rika

1 Answers

1
votes

Right click on the Inspector tab label and select Add Tab -> Inspector. Drag the second inspector below the first. Click on your first object, and then click on the little padlock icon in the upper-right of the first Inspector. Now click on the second object. You can now drag-and-drop things between Inspectors.

You can attach objects to the instance in the Hierarchy, regardless of the Hierarchy instance being a prefab. You may want to approach this with some thought as to what constitutes a prefab (read: template) and what is just an object living in the Hierarchy.

You can't attach Scene objects to the prefabs in your Assets.