First of all, i’ve been reading the forums for a while now but this is my first ever post. So i hope i did everything okay.
So i’m running into a problem. How would i make a system that changes a active prefab through buttons?
For example: you have 8 tree’s and you have a function that instantiates a tree at your position. But now you want to switch between these tree’s (though UI Buttons). So if i click button 2 it needs to instantiate tree 2 when i click, and if i click button 6 it needs to instantiate tree 6 when i click. Etc.
Some basic techniques or guidelines would be really nice. So i atleast can get this system going.
Sorry mybad, its a runtime tool. The player starts the game is able to place an object and has multiple buttons on the left side through which he/she should be able to switch between the right object to place down. It’s for a Mobile AR app using the Google Tango. It’s about placing furniture inside of your living room etc. So you should be able to place like 9 different beds for example
I know what you mean, that might help indeed thankyou! Will look into it right away. But doesnt that require me to make a huge amount of code still? I’m trying to code as little and as nice as possible. But my understandig is, i should change the gameobject (for example treeSource) through the Resources.Load and than just always instantiate TreeSource?
So i got the following working: standard the object is set in start void. when i click the button it changes to object 2. But how would i go and code the other objects. Without using an ugly amount of code. I need some sort of way to say when i click this button resources.load is the following. And i got this working but only for 1 object atm. How would i nicely code it for multi objects? I got this atm:
Thankyou for your help! However i already found another way. Using a seperate script which changes the activeobject (object to be place down) with it’s own gameobject. I put this scrip on every button and drag in the right prefab and onclick it changes. This way everytime i make a new button al i have to do is drag the script on and drag the prefab in. Later on i will make it so it loads in from a database. Thanks anwyay! Hope other people who find this thread will use your solution.