- Home /
Getting variable data from Parent
Hi everyone im kinda new to Unity, im trying to edit a variable in a parent with a child. I put the "Main Account Variables" in the parent object, consists of # of cubes and money stuff like that. I have a Gui object with children of different Gui menus, like a store ans builder. I want to access the money from one of the children. Currently im just trying to get it to post the amount
Debug.Log(this.transform.parent.GetComponent("Account").Mu));
Mu is money Units
once i figure out how to GET the info, i can run with it, its just a matter of getting it. I have searched the web for answers, but nothing seems to work for me, sorry if this has been said elsewhere i just cant seem to find it
Answer by YoungDeveloper · Jun 27, 2014 at 06:56 PM
Use GetComponent to access other script, I've explained it very clearly here:
http://answers.unity3d.com/questions/550578/cant-understand-getcomponent-c.html
http://answers.unity3d.com/questions/597617/how-do-i-addsubtract-variables-between-two-differe.html