- Home /
Question by
adityarocks123456 · May 13, 2021 at 04:26 AM ·
scripting problemprefab
Renderer getting disappeared from the inspector.
My renderer is getting disappear from the inspector when i start the game and then i've to drag it in the prefab.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class skinSelector : MonoBehaviour
{
public Renderer skinRen;
public Material red, green, yellow;
private void Awake()
{
}
private void Start()
{
skinRen = GetComponent<Renderer>();
skinRen.enabled = true;
}
public void equip1()
{
skinRen.sharedMaterial = red;
}
public void equip2()
{
skinRen.sharedMaterial = green;
}
public void equip3()
{
skinRen.sharedMaterial = yellow;
}
}
And i keep getting this message in the inspector
MissingComponentException: There is no 'Renderer' attached to the "GameObject" game object, but a script is trying to access it. You probably need to add a Renderer to the game object "GameObject". Or your script needs to check if the component is attached before using it. skinSelector.Start () (at Assets/Scripts/skinSelector.cs:18)
Comment