#I do have to go though, @RENTΔL † can
1 messages · Page 1 of 1 (latest)
oh boy
im fixin to record a short screen capture that shows the concept of a UIManager script handling multiple TMPro objects
I’ll be on later if yall still haven’t figure it out
if i cant figure out how to update a TMPro element after 4 years imma just quit 🤪
i have no clue how im even progressing lmao, its overly warm, late AF, and im more of the design/ideas guy when it comes to this
so im getting hit wiht a tripple whammy of debuffs trying to progress lol
just try not to bite off more than you can chew as a beginner..
its better to take a bit longer to understand how somethings working in the grand-scheme of things
im going to show an example that has Health.. and Sheild (so two different text elements being updated).. u should be able to take that and expand it however u need... (project is loading up right now.. ⏲️ )
yea sure.. im doing it step by step w/ comments n stuff that way i dont need to explain anything else..
when I tab to Unity from the editor im also Saving ctrl+s if it wasn't obvious.. need to save before the inspector will compile and update the components
and i did the update defaults at the beginning a bit weird cuz i had forgotten 😅 lookin back u could easily just set teh textmeshpro elements to start with 100 in the inspector.. and if not i'd probably pass in the two ints we made in the Player script just so we could change the defaults anytime during development that we wanted and the UIManager just updates using those values instead
{
uiManager.UpdateHealthText(health);
uiManager.UpdateShieldText(shield);
}
``` yea nvm not sure what i was thinking.. we can just use the two methods we already have to set the beginning 100
and the Updating of the Text can just be done inside the Damage and Shield methods..
without all the Keybind test methods it'd be simply
using UnityEngine;
public class Player : MonoBehaviour
{
int health = 100;
int shield = 100;
public UIManager uiManager;
void Start()
{
uiManager.UpdateHealthText(health);
uiManager.UpdateShieldText(shield);
}
public void ModHealth(int damage)
{
health += damage;
uiManager.UpdateHealthText(health);
}
public void ModShield(int damage)
{
shield += damage;
uiManager.UpdateShieldText(shield);
}
}``` for the Player.cs and
```cs
using UnityEngine;
using TMPro;
public class UIManager : MonoBehaviour
{
public TMP_Text healthText;
public TMP_Text shieldText;
public void UpdateHealthText(int newValue)
{
healthText.text = newValue.ToString();
}
public void UpdateShieldText(int newValue)
{
shieldText.text = newValue.ToString();
}
}
``` for the UIManager.cs
I'll get around to testing/trying to impliment this stuff when i'm awake then.
sorry for the extremely late response, my brain is fried and its almost 4am now
in the odd case that i have any questions while following this i will more than likely be asking here, but in the case that i dont, or in the case where you dont see it for some odd reason,
Cheers, thanks for all the info
Ok so I tried to reappropriate the stuff in the vid to suit my purposes.
I have a static enemy which I'm adding more components to, and I have healing orb things.
However, the healing orb things don't update the text, and I did my HP system and damage system a little different I think.
Enemies specify their own damage. HP healing orb things specify their own healing (and cool down);
And I tried to make it so that when you hit an enemy to death (or hit the training dummy in general) that you gain 1 point, but for some reason it isn't working despite the manual add and subtract works
Think I could get some last minute tips before it's too late and I need to crash for the night?
Or are you busy