Topic: How to access the Character Stats

I would like to display the character stats during the character select screen. I located the character info under the characterinfo.cs file  but I am not sure how to make it visible on the select screen. Any help would be great.

Re: How to access the Character Stats

There are multiple ways to do it.

Basically I presume you know where in the DefaultCharacterSelectionScreen.cs file it gets the highlighted character?

CharacterInfo character = this.selectableCharacters[characterIndex];

From there you'd just get or set the properties as you see fit.
For example, if you want to show their blood type in a text box on the gui, start by adding a new public instance field that you can drag and drop the UI element from the hierarchy to. Then in the code you'll just reference that item.

public Text bloodTypePlayer1;
public Text bloodTypePlayer2;

Then, in the code after you get the character, in the if check for each player you'd just add a line to populate that object's text value with the character's blood type. Something like this:

 if (this.bloodTypePlayer1 != null) {
this.bloodTypePlayer1 = character.bloodType;
}

Share

Thumbs up Thumbs down

Re: How to access the Character Stats

Thank you for the response. Even at my level of programming, which is very low I was able to follow your instructions. While I did not pull any errors I was not able to see the bloodtype displayed on the character select screen. I have images below showing what I did and where I add the code snippets that you recommended. Thanks again for your help.
Here is where I placed the public instance field here:
PunBB bbcodetest

and the If statement here:

PunBB bbcodetest

Re: How to access the Character Stats

Did you do the UI work to add the text element for which you want to populate with the blood type?

You would open the character select screen from the global options, create the player1 and player2 text boxes in the canvas hierarchy, then click and drag those into the screen's inspector which should have the "Blood Type Player 1" and "Blood Type Player 2" values currently marked as none.

From there, it's a matter of setting up the font type and color in each text area to make sure you can see the text value when running the game. Any values you save in the screen editor won't be displayed when running the game unless it's not updating the text box.

Share

Thumbs up Thumbs down

Re: How to access the Character Stats

So I've gone ahead and created the Text objects for the Bloodtype by duplicating the Name_Player objects and just renaming them. The problem I am running into is the BLoodtype game object does not show up under the DefaultCharacterSelectionsScreen script in the inspector.  It does show BLoodtype Text box in the inspector window if I select the DefaultCharacterSelectionsScreen script in the project view. I am not sure what I am doing wrong.

Re: How to access the Character Stats

I'll try reproducing my suggestion to verify i gave you the right tutorial later today and will let you know.

Share

Thumbs up Thumbs down

Re: How to access the Character Stats

Thank you. I will keep trying and wait until you get back with me.

Re: How to access the Character Stats

Can you show me a screenshot of your hierarchy when editing the screen in Unity?

Share

Thumbs up Thumbs down

Re: How to access the Character Stats

Still have not been able to get this to work. I also want to add a few extra slots once this gets resolved.

https://jbopva.bn1304.livefilestore.com/y4pmIBmUmnqybXb95vG6p0cUpvUt7TTs4_ZU1Y6yGDUZU2asQxZLMsS75yf-RNQV1DjRLawzfC4IS2T_Fo9KQhmqnzU708MpndfFlZ-YSiZqlxfrpDUqL9yUY1Ishs-my5WH1Ri0-g13PuALTR3I9dbC1jv3BvFFGV_iRf1CoJxFKNtGbOzYibCBy2mphlatzNBNjZdzrmiI_bpUOSAVImpoA/2017-11-13.png?psid=1