Handling Scripts and Unity3D properties?

0

Good afternoon everyone!

Next, I'm having a problem. I am developing a game where there is a script called PlayerModel, which when starting the Battle, it comes with data that was pre-defined in the Model script, however, when finishing the battle and trying to access a menu where it has a HUD, I am not able to bring the data (name, level, exp, etc). If I use a GameObject and give it a " gameObject.GetComponent < > () ", considering that it has a player object in Hierarchy, it works. However, if I try to do the same without having the GameObject, whether trying to use the AddComponent () or the GetComponent () , it comes with empty values! Could anyone tell me how to pass parameters, or use static / global parameters effectively?

Edit: another thing is that when I enter the battle, I go out and enter again, it comes back as if it was the first time, it is "resetting" the statuses.

Thank you!

    
asked by anonymous 06.12.2017 / 22:24

1 answer

0

One way to keep this data global is to use PlayerPrefs with it you value values and take values from anywhere in your game.

Follow the documentation link: link

    
07.12.2017 / 14:21