Variables inside class not showing up in Inspector C#.

All right, I have a Capsule with rigidbody and a c# script “Walk”.

Inside walk, I want to make a public class whose contents can be edited in the Inspector.

It goes like this :

using UnityEngine;
using System.Collections;

public class Walk : MonoBehaviour {

public AnimationClip walk;

[System.Serializable]	
public class Props {
	public float maxSpeed;
}

Animation _animator;

// Use this for initialization
void Start () {

	_animator = gameObject.GetComponent();
	
}

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

	if (Input.GetAxis("Vertical") == 1){
		rigidbody.AddRelativeForce(transform.forward *100);
		_animator.CrossFade (walk.name);
	}
}

}

However, neither the class nor the contents show up in the Inspector. Can anyone help?

You have to create an instance of the class first, so basically just making a variable of type “your class”

For example, your code should look like this:

public AnimationClip walk;
public Props props; // Add this line in here

[System.Serializable]   
public class Props {
    public float maxSpeed;
}

This way there is a variable of your class, which will show in the inspector, including all of it’s contents.

You need to either create a custom editor for your class or create a serialized field of the inner class in order to show it on the inspector.

Try this:

	[SerializeField]
	Props props = new Props();
	
    [System.Serializable]
    public class Props {
    	public float maxSpeed;
    }