Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

i need help making a idea of a script a script

Discussion in 'Editor & General Support' started by whycantipickaname, May 24, 2020.

  1. whycantipickaname

    whycantipickaname

    Joined:
    Feb 21, 2020
    Posts:
    14
    how do i make this script make text pop up when IsReloading = true
    if (isReloading = true) { enable text(Reloading) }
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,120
    Have a canvas with a text element in it in your scene, and set the text's content? Have you looked into very basic UI stuff in Unity?
     
  3. whycantipickaname

    whycantipickaname

    Joined:
    Feb 21, 2020
    Posts:
    14
    little late reply but i got the text to pop up but now it doesnt go away can u help me
    (script)
    if (isReloading == true)
    {
    Reloading.text = "Reloading";
    }
    else
    {
    Reloading.text = "";
    idk how to make the Reloading text go away it goes away if i shoot because it knows im not reloading
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,120
    Well, you're setting "isReloading" to true at some point. You just need to set it to false at some other point. If you want an action to be performed over a span of time (Like showing a "Reloading" message, followed by reloading, followed by hiding the "Reloading" message) you might want to look into using Coroutines to break an action out over time.
     
  5. whycantipickaname

    whycantipickaname

    Joined:
    Feb 21, 2020
    Posts:
    14
    yeah i have it so if its set to true put the text Reloading on the screen but when it goes back to false the text stays and i think thats bc i dont have a text to delete the text can you help me make one?
     
  6. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,120
    I don't know what that's supposed to mean. But from your code, if "isReloading" is false, it should be clearing the text. So that should work fine, as long as you're actually setting isReloading to false.
     
  7. whycantipickaname

    whycantipickaname

    Joined:
    Feb 21, 2020
    Posts:
    14
    Ok so i did a coroutine but idk what the script is to delete text
    (code)
    IEnumerator DeleteText()
    {
    yield return new WaitForSeconds(1);
    }
     
  8. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,120
    You literally have it in your earlier post:

    Reloading.text = "";
     
  9. whycantipickaname

    whycantipickaname

    Joined:
    Feb 21, 2020
    Posts:
    14
    that doesnt do it tho btw i got it done it took its own script