Showing different objects OnMouseDown
Hiya,
I’m looking to make a game where you would have a model of a house, and you can walk around and change different elements when clicked.
For example lets say there was a sofa and when clicked it could change to a different model.
Another idea I had was to have the different objects priced individually, and when the object was visible it would change a total price GUI score.
I’ve managed to cycle through different materials but I cant figure out how to do Game objects.
Anyone able to point me in the right direction?
Thank you
Answer by Cuttlas-U · Apr 09, 2017 at 05:09 PM
hi; when the object visible means when it is Active and by that u can use OnEnable() function . this happens when an object activated;
then u can add an script to your object and it sends the variable to the total price gui script that has a function and change the it;
for example in your objects script :
int myPrice = 50;
void OnEnable()
{
GameObject.Find("Manager").GetComponent<manager>().setvalue(myPrice);
}
then in your manager script :
int totalPrice;
public setvalue(myPrice)
{
totalPrice += myPrice;
// show on gui
}
Sorry i left it so long!
I manged to get the objects looping fine but I'm still having some trouble with the score. Any more tips?
Sorry I'm fairly new to this.