So this shows the different parts of the array depending on what part you want.
Now, if you are adding level on and level has a value, then you’ll have it added on, but I’d have to see more code to understand what value you should be seeing in your textbox.
so what needs to happen is Level: is displayed in the first part and after : it needs to display the int level inside of the current level text box
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
public class Levelup : MonoBehaviour {
private int points;
private int level;
public GameObject canvas;
private bool canspend;
public GameObject Dashstatplus;
public GameObject Dashstatminus;
public GameObject Strengthplus;
public GameObject Strengthminus;
public GameObject Movementplus;
public GameObject movementminus;
public GameObject staminaplus;
public GameObject staminaminus;
public GameObject vitalityplus;
public GameObject vitalityminus;
public GameObject levelup;
public Text currentlevel;
public string mystring;
// Use this for initialization
void experincefull()
{
if(GetComponent<Battler>().xpgained >= GetComponent<Battler>().nextlevelxp)
{
level += 1;
GetComponent<Battler>().xpgained = 0;
GetComponent<Battler>().nextlevelxp *= 3;
if (level == 1)
{
points += 10;
string myString = "Level:";
string[] myStringSplit = myString.Split(':');
currentlevel.text = myStringSplit[0] + level ;
canspend = true;
levelup.SetActive(true);
}
}
}
Ok, but from what I’m seeing, why do you need to split?
You could just do
currentLevel.text = "Level: " + level;
But that being said, what result are you getting? Does level actually == 1 for the code to run? Are you starting at level 0?
Edit: I think you were splitting because you were taking the old text and splitting off the word Level, but that isn’t really needed if the first part of the text never changes.