Hey all, I have a very simple task but can’t seem to find the Answer any where.
I need to pass the total amount of money remaining from the shopping GUI display into the Money HUD (guiLabel) display.
The Shop display is on a different script then the HUD display.
.It is this way because the shopping display only displays when you enter a shop, and the Money HUD display is always visible, so that you can always know how much money you have.
I need for the shop total to dynamically update the Money HUD total when ever i go shopping.
The shopping total is a labeld display and the Money Hud is also a labeled display.
enter code here
public int Shoppingtotal;
GUI.Label(new Rect(150,80,700,20),“”+Shopping total); // i need this total to dynamically update
into
;
;
public int MoneyHUD;
GUI.Label(new Rect(150,80,700,20),“”+MoneyHUD); // into this total which is found in another script.
So one script needs to know about the other. The simplest way (and also the cleanest way from an architectural point of view) is to have an explicit reference which you can set, so in Shopping.cs:
public Money money;
Drag the GameObject with the Money script on it to this variable in the inspector. Then Shoppibg can talk to Money:
money.MoneyHUD -= ShoppingTotal;
Or whatever interaction it is that you need to have between the scripts,
But your descriptions of the problem as well as the reference material, are all simply to vague and without the amount of detail that one would need to actually implement your remedies. Could you both or at least one of you be way more descriptive and a bit less short ended?
Thanks again.
~K