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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Setting the Sprite Renderer off and on of a secific object

Discussion in 'Scripting' started by Zero101, Apr 22, 2015.

  1. Zero101

    Zero101

    Joined:
    Apr 18, 2015
    Posts:
    14
    I need to make like a pause menu but I need to turn off the sprite renderer of an object that DOESN'T have this script on it. I have just got some pice of script done but I still need help whit a variable, to turn off the sprite render of an object that I can type in his name in (P.S. the name is Live1Icon and it is in Start so don't worry about computer power)


    Code (CSharp):
    1.  
    2. else {
    3.          GetComponent(MeshRenderer) = false;
    4. }
    5.            
     
  2. vothka

    vothka

    Joined:
    Mar 27, 2015
    Posts:
    59
    yes sure, and a SpriteRenderer is not a Meshrenderer

    Code (CSharp):
    1. GameObject.Find("Live1Icon").GetComponent<SpriteRenderer>().enabled = false;
     
  3. Zero101

    Zero101

    Joined:
    Apr 18, 2015
    Posts:
    14
    Thank you so much !