Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Make an object invisible from script

Discussion in 'Scripting' started by v_chs, Sep 21, 2020.

  1. v_chs

    v_chs

    Joined:
    Dec 11, 2019
    Posts:
    55
    Is it possible to make a game object invisible? I tried to change the opacity of the material's color but it still appears in the scene.
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    1,666
    To make a gameobject invisible you can disable its renderer component. If you dont need the object in the scene right now (including script functionality) you may also just disable the entire gameobject.
     
    v_chs likes this.
  3. cate5171

    cate5171

    Joined:
    Jan 5, 2020
    Posts:
    94
    One way you could do it is to deactivate the game-object during the script so it doesn't appear in the scene:
    Code (CSharp):
    1. public GameObject OBJECT1;
    2.  
    3. void Update();
    4. {
    5.  // Collision/Way to Trigger
    6.   OBJECT1.SetActive(false);
    7.     }
    8. }
     
    v_chs likes this.
  4. v_chs

    v_chs

    Joined:
    Dec 11, 2019
    Posts:
    55
    I want to make it invisible but listen to onTriggerEnter events.
     
  5. v_chs

    v_chs

    Joined:
    Dec 11, 2019
    Posts:
    55
    I want to make it invisible but listen to onTriggerEnter events.
     
  6. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    1,666
    v_chs likes this.
unityunity