Best way to show a script in the Inspector

Hi Unity users. I am just learning C# and Unity and I want to create the interface for a script , I mean how the script will look in the Inspector (not custom Editor). What I have is a mesh, plane, which will be used as part of GUI and animations (player, enemy) on a mobile device. So I just want to have a list of all states of a mesh. For instance, in the case of Player, the states could be walking, running, etc. and each state could have properties like first frame, last frame, animation time, etc.

My question: is this the best way to do it?

Script to show in the Inspector

public class Player : MonoBehaviour {
	public Animations[] animationList;
	
void Start () {
		Debug.Log(animationList[0].lastFrame);
	}
}

Script to handle animation

[System.Serializable]
public class Animations
{
	public float firstFrame;
	public float lastFrame;
	public float animationTime;
}

Thanks in advance for your help

Learner

The you should probably need to make use of the custom editor classes. You said you don’t want to but there’s no other way to customize how a script looks like in the inspector.

But, if you just need to display some information about a component state, you could use enums (which is the same as ints but you refere to them as words instead of numbers)

Thanks Hasho. I am not considering editor class becasue I do not know how to use it. I have not found a tutorial for a newbie like me.

About enum, I did not get it. enum is used for constant values and in my case I want the option to choose the values in the editor. Graphically what I want it is really simple, something like this:

Animation List
  Size 2
     Animation 1
         Name Walking        
         First Frame  0
         Last frame 9
         Animation Time 1.5
     Animation 2
         Name Idle        
         First Frame  10
         Last frame 13
         Animation Time 1

I think you’ll be hard pressed to find tutorials on editor scripts (but most concepts are the same on both sides of the mirror).

I don’t know if it’s the best way of doing it, but as the saying goes “if it works, don’t try to fix it” :slight_smile:

Oh I see. Then you can use inner classes to make it work. I don’t know C#, so I’ll post the code in US, but the idea is basically the same:

// make an inner class like the following:
class AnimationList
{
    var name : String;
    var firstFrame : int;
    var lastFrame : int;
    var animTime : float;
}

// declare an array variable with type of AnimationList:
var animationListArray : AnimationList[1];

And that’s pretty much everything. I’m not sure whether the array declaration is correct (I haven’t tested the code) but you may get the idea.

By doing so, the inspector will prompt the animationListArray variable with a size field. Then you just have to fill the values for every index of the array.

Thanks Tobias and Hasho. My concern was about using that approach on mobiles.

Gracias