I’ve been struggling to get public variables to show in the unity inspector – public Materials are showing, but not doubles, floats, ints, etc.

Any advice would be much appreciated – I’m quite new to Unity, but I’ve gone through many other posts on this topic and haven’t found any solution that works here!

Hi @matpug3
First make sure your script doesn’t have any compile errors.
You need to attach your script to a game object in order to see doubles, floats, ints…
but if not attached to a game object, you’ll only see variables that can be stored as assets like materials, audio clips, gameobjects, etc (basically anything that inherits UnityEngine.Object).

To learn more about inheritance click here.

If you check Unity’s doc for material you’ll see that material inherits UnityEngine.Object, as seen in below picture.

Also in the next picture you can see an example


here’s the code for the script

using UnityEngine;
public class test : MonoBehaviour
{
    public float a; // won't show in inspector since it doesn't inherit UnityEngine.Object

    public Material material;
    public AudioClip audioClip;

    public UnityEngine.Object obj;
 
    
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}