- Home /
Script wont let me drag and drop GameObject Of UI Menu into it?
IM following a tutorial where he makes a simple menu. very straight forward, when you hit a certain key, the menu pop up. For him and Usually for me, he makes a serialized field of the UI var, then inside Unity, drags the UI canvas/images/temnplate/menu into this script. Now ive done this time and time again, with no issues, but this time, when trying to drag this particular gameobject That is basically a canvas of images creating this menu. It will not let me drag it in? It simply has a stop sign emblem basically saying it wont accept? I click the browse button next to it, only to see it says "None" From the list? Why the heck wont my script allow me to add this gameobject? Any help is appreciated, thanks.
The structure goes a such: within my hierarchy: gameObject Parrent Called "UI_Inventory". Within that parent, we have the background which is basically just an image with transparent, the image of a few practice items, the container for the menu itself, etc. Alls is literally hardcoded right now. Meaning.. They are just still images and texts that are not being fed any data yet.
Thats it. All im trying to do, is just simply get this menu/inventory canvas, to just pop open when hitting a certain key. But within my Player Script, within the inspector, the Serialized Field is there waiting to be added, but it just simply wont allow it? X'ed out/Grey'ed out...???
Here is my Code incase that matters?:
[SerializeField] private UI_Inventory uiInventory;
Pic UI_Inventory:
Pic Of Hierarchy:
Pic Of Inspector: WILL NOT ALLOW ME TO DRAG THE UI_INVENTORY onto the SerializedField.: Welp apparently can only do 2. But ya, it wont let me drag it into my script??
Answer by imM4TT · Sep 01, 2020 at 11:58 PM
It may seem silly but you didn't specify it : does your UI_Inventory gameobject has a UI_Inventory script attached to ? If not, this is the issue, what unity editor expect here from you is to drag and drop the UI_Inventory script not a gameobject called such as the class name.
@im$$anonymous$$4 Update: To a certain extent you were correct... What it was (I hate to admit), was I placed the UI_Inventory Script on the player, rather than the UI_Inventory Game Object... UGH.... So misled at times in this rat race of Game Dev lol! Thanks bro!
Your answer
Follow this Question
Related Questions
Simple GameObject Hide/Unhide with bool!!! 0 Answers
All my scripts have suddenly stopped working? 0 Answers
Changing 2 dependent variable at the same time 1 Answer
How would I set up this blend tree for my 2d game 0 Answers
Issue trying to animate multiple models with same controller and script 0 Answers