When i Want to Change my Text String it is saying This Text (UnityEngine.UI.Text) in The text String

using System.Collections;
using UnityEngine.UI;
using UnityEngine;

public class Item_Sysem : MonoBehaviour {

    [Header("Color's")]
    public Color Danger_Color;
    public Color Save_Color;
    public float DangerZone_C = 1;
    public float SecBeforeDestroy = 2f;
    public GameObject NotEnoughObject;

    [Header("Cloth")]
    public float Current_Cloth;
    public Text Cloth_T;

    [Header("Bandage")]
    public float AmountHealthAdd = 5;
    public float Current_Bandage;
    public Text Bandage_T;

    [Header("Sticks")]
    public float Current_Sticks;
    public Text Sticks_T;

    [Header("Metal")]
    public float Current_Metal;
    public Text Metal_T;

    [Header("Koper")]
    public float Current_Koper;
    public Text Koper_T;

    [Header("Stone")]
    public float Current_Stone;
    public Text Stone_T;


    void Start()
    {
        //Sticks
        Sticks_T.text = Sticks_T.ToString();

        //Cloth
        Cloth_T.text = Cloth_T.ToString();

        //Bandage
        Bandage_T.text = Bandage_T.ToString();

        //Metal
        Metal_T.text = Metal_T.ToString();

        //Koper
        Koper_T.text = Koper_T.ToString();

        //Stone
        Stone_T.text = Stone_T.ToString();
    }

    //-----------------------------------------------------------------------------------------------------------------
    //Stone
    public void AddStone(int StoneToAdd)
    {
        if (Current_Stone + StoneToAdd > 0)
        {
            Stone_T.color = Save_Color;
            Current_Stone += StoneToAdd;
            Stone_T.text = Current_Stone.ToString();
        }
    }

    public void SubtractStone(int StoneToSubtract)
    {
        if (Current_Stone - StoneToSubtract < 0)
        {
            Stone_T.text = Current_Stone.ToString();
            StartCoroutine(NotEnoughFromSomething());
        }
        else
        {
            Current_Stone -= StoneToSubtract;
            Stone_T.text = Current_Stone.ToString();
        }

        if (Current_Stone < 1)
        {
            Stone_T.color = Danger_Color;
        }
    }
    //-----------------------------------------------------------------------------------------------------------------
    //Koper
    public void AddKoper(int KoperToAdd)
    {
        if (Current_Koper + KoperToAdd > 0)
        {
            Koper_T.color = Save_Color;
            Current_Koper += KoperToAdd;
            Koper_T.text = Current_Koper.ToString();
        }
    }

    public void SubtractKoper(int KoperToSubtract)
    {
        if (Current_Koper - KoperToSubtract < 0)
        {
            Koper_T.text = Current_Koper.ToString();
            StartCoroutine(NotEnoughFromSomething());
        }
        else
        {
            Current_Koper -= KoperToSubtract;
            Koper_T.text = Current_Koper.ToString();
        }

        if (Current_Koper < 1)
        {
            Koper_T.color = Danger_Color;
        }
    }
    //-----------------------------------------------------------------------------------------------------------------
    //Metal
    public void AddMetal(int MetalToAdd)
    {
        if (Current_Metal + MetalToAdd > 0)
        {
            Metal_T.color = Save_Color;
            Current_Metal += MetalToAdd;
            Metal_T.text = Current_Metal.ToString();
        }
    }

    public void SubtractMetal(int MetalToSubtract)
    {
        if (Current_Metal - MetalToSubtract < 0)
        {
            Metal_T.text = Current_Metal.ToString();
            StartCoroutine(NotEnoughFromSomething());
        }
        else
        {
            Current_Metal -= MetalToSubtract;
            Metal_T.text = Current_Metal.ToString();
        }

        if (Current_Metal < 1)
        {
            Metal_T.color = Danger_Color;
        }
    }
    //-----------------------------------------------------------------------------------------------------------------
    //Sticks
    public void AddSticks(int SticksToAdd)
    {
        if (Current_Sticks + SticksToAdd > 0)
        {
            Sticks_T.color = Save_Color;
            Current_Sticks += SticksToAdd;
            Sticks_T.text = Current_Sticks.ToString();
        }
    }

    public void SubtractSticks(int SticksToSubtract)
    {
        if (Current_Sticks - SticksToSubtract < 0)
        {
            Cloth_T.text = Current_Cloth.ToString();
            StartCoroutine(NotEnoughFromSomething());
        }
        else
        {
            Current_Sticks -= SticksToSubtract;
            Sticks_T.text = Current_Sticks.ToString();
        }

        if (Current_Sticks < 1)
        {
            Sticks_T.color = Danger_Color;
        }
    }
    //-----------------------------------------------------------------------------------------------------------------
    //Cloth
    public void AddCloth(int ClothToAdd)
    {
        if (Current_Cloth + ClothToAdd > 0)
        {
            Cloth_T.color = Save_Color;
            Current_Cloth += ClothToAdd;
            Cloth_T.text = Current_Cloth.ToString();
        }
    }

    public void SubtractCloth(int ClothToSubtract)
    {
        if (Current_Cloth - ClothToSubtract < 0)
        {
            Cloth_T.text = Current_Cloth.ToString();
            StartCoroutine(NotEnoughFromSomething());
        }
        else
        {
            Current_Cloth -= ClothToSubtract;
            Cloth_T.text = Current_Cloth.ToString();
        }

        if (Current_Cloth < 1)
        {
            Cloth_T.color = Danger_Color;
        }
    }
    //-----------------------------------------------------------------------------------------------------------------
    //Bandage
    public void AddBandage(int BandageToAdd)
    {
        if (Current_Bandage + BandageToAdd > 0)
        {
            Bandage_T.color = Save_Color;
            Current_Bandage += BandageToAdd;
            Bandage_T.text = Current_Bandage.ToString();
        }
    }

    public void SubtractBandage(int BandageToSubtract)
    {
        if (Current_Bandage - BandageToSubtract < 0)
        {
            Bandage_T.text = Current_Bandage.ToString();
            StartCoroutine(NotEnoughFromSomething());
        }
        else
        {
            Current_Bandage -= BandageToSubtract;
            Bandage_T.text = Current_Bandage.ToString();
        }

        if (Current_Bandage < 1)
        {
            Bandage_T.color = Danger_Color;
        }
    }
    //-----------------------------------------------------------------------------------------------------------------
    IEnumerator NotEnoughFromSomething()
    {
        NotEnoughObject.SetActive(true);
        yield return new WaitForSeconds(SecBeforeDestroy);
        NotEnoughObject.SetActive(false);
    }
}

Hi,
I want to change the string of the text, But wen i start the game it Is Saying in the Text Component String Text (UnityEngine.UI.Text)

Does someone know what i did wrong in the Code Or is it just s bug or something

All Help Is Welcome!

Using: Unity3D 5.5.0b1

can you post the whole error, it should have a line number at the end…

It’s not an error this what it shows in the text box in the game it self

You are just setting the text to the string message components report in ToString. Try setting the text to the value of Current_Sticks etc. instead.

Oke, but i don’t know how you can put that in code?

 Sticks_T.text = Current_Sticks.ToString();

Just like in your add/subtract methods.

But, i mean how should it be if it was value because he don’t reconize it

I’m sorry, I don’t understand you. That should set the text to be whatever the value currently is, what else do you want?

OOOOOOOOOHH How Can i be that stuppid Thank you so much AHHAHAH!
my fail:face_with_spiral_eyes:

1 Like