#How to assign variables in game to a prefab in assets folder
49 messages · Page 1 of 1 (latest)
here
okay , so you got 2 choices
first -> spawn the border and getting reference for the spawned perfab not the original prefab
Second -> making the border a child for the item and simply deactivate it or activate it
i suggest watching this videos :
https://www.youtube.com/watch?v=dtv7mjj_iog
https://www.youtube.com/watch?v=ymq2AUckws0
PSA: The "Unit" class is a simple class I created to represent a unit in my game. It's NOT an inbuilt class. Sorry for the confusion.
As a new dev, keeping references to game objects you need can be a little confusing. Learn how to store game objects for later use as well as allowing external scripts access to your goodies.
Instead of trying ...
Check out the Course: https://bit.ly/3i7lLtH
Learn 5 different ways you can connect your gameobjects in Unity. Ranging from direct references & singletons to scriptableobjects and injection.
More Info: https://unity3d.college - (and where you can submit your own questions)
Join the group: http://unity3d.group
and i suggest that you start by watching someone making a full inventory system instead of making your own , it will save you time and headache and you have some guidelines to follow
for the second: yeah i could create a slotBorder but i wanted to try having only one slotBorder, nv i will do as you said
for the first choiche: in this way i have to assign the variable manually no?
thanks
thats why i suggested for you this videos , you will create one border , from my guessing its the border that appear on the item to show which item is currently selected , so simply u will create a SelectionBorder in Inventroy Canves and simply getting reference for it for example with tag and control its position
👍 problem border solved, now how can i do for the script and the other game object?
As you can see in the video there are 3 variables that the prefab need when it enter the game: the script "EquippableItemUI", the slotBorder and another game object that is the 3d version of him
i don't know how to reference them in the prefab non manually
i cant really give you solution because i need more info , but as i suggested try to watch a full inventory series because inventories is not an easy topic
arabs always on the top
حبيبي يا باشا 😅 ❤️
We are an English community around English content with English speaking moderation team. Everyone here understands English, other languages not so much.
I saw these videos and solved the problem of the 3d version of the item and for the slotBorder. The only problem now is setting the equippableItemUI as reference non manually
(regarding the video i sent) : As you can see if an Item spawn in the scene it have all it need to work except for the equippableItemUI script that I have to assign manually. Do you know how can i do without using the Find?
If someone know a solution it is really appreciated 
The error is pretty obvious
You can't edit the prefab during runtime
slotBorder.transform.SetParent(transform.parent);
slotBorder.transform.localPosition = new Vector3(0, 0, 0);
slotBorder.SetActive(true);
These 3 lines are attempting to edit the prefab
now i deleted these 3 lines because i improved the script but how can them edit the prefab if they are regarding the slotBorder variable?
One second i'll try again now that i deleted this part
As you can see the code works fine when the reference for the "EquippableItemUI" variable is the gameObject in the scene, but when this reference is the prefab from the assets folder then it doesn't works
One second i'll share the codes
a powerful website for storing and sharing text and code snippets. completely free and open source.
the error was in the EquippableItemUI script
brother , 2 gameObjects to be able to talk together must be in a scene
you should consider any prefab as a Template or a Blueprint , its a thing that others inhert from
And how can i do if during the game a monster drops an item and the player pick it up?
the player can't assign thr variable manually
🏗 @TamaraMakesGames building system video: https://youtu.be/G2w78Xk6UhU
🏞 FREE assets download: https://www.patreon.com/posts/72631393?s=yt
🎁 Support me and DOWNLOAD Unity project: https://www.patreon.com/posts/72632413?s=yt
This tutorial guide will show you how to create a full inventory system with draggable items, bottom toolbar, full inven...
its a problem in the design of the inventory system
when i have time i'll try to watch other videos
its okay , we all have the motivation to make our own systems 
but we firstly must see how other people did it so we can see reference and a plan to the system , so we decrease the working time and debugging time 
yeah i was teying to do it all alone to see if i could and i did (even if much optimizable) until this problem 
Thanks for the advices 
np wishing you all luck ❤️
🥰

Just so you know i did it!
I'm really happy of that :))
It surely is an improvable script but i like that i did it alone
'll improve it when i will learn about instances, "this", get; set; and other things (if my script need these)
wow thats amazing!