Enable Disable Mesh Renderer

Hello,

I created an object whose mesh renderer is disabled, I want it to be Enabled when mouse goes on it and disable when mouse goes out, can you help me pls :frowning: ?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DeactivateScript : MonoBehaviour
{
public GameObject PLS ;(

void OnMouseEnter()
{

}

void OnMouseExit()
{

}

void OnMouseOver()
{

}
}

pls reply, its important for me :confused:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DeactivateScript : MonoBehaviour
{
public MeshRenderer PLS;

void OnMouseEnter()
{
PLS.enabled=true;
}

void OnMouseExit()
{
PLS.enabled=false;
}

void OnMouseOver()
{

}
}
11 Likes

Thanks bro Aily, it works excellent, thank you so much :]

Thank you for your help Much appreciated :slight_smile:

2 Likes

that is so useful tysm

Thx for the basic information of the MeshRenderer because now I can just change the MeshRenderer into BoxCollider and have a moving/disapearing door that I can put in my level

this was really helpful thx

yeah

8888898--1215498--avatar_m.png
8888898--1215498--avatar_m.png
8888898--1215498--avatar_m.png
8888898--1215498--avatar_m.png
8888898--1215498--avatar_m.png