How to display additional info of an assigned object in the inspector

Hi, sorry if this question has already been answered but I couldn’t find it anywhere.

I’m using Unity 2019.3.0f6

In the inspector, I can assign a script to a variable but I want to show additional information of that object in the inspector, in this example the object I am assigned has a public property called “Label” and I want to show it.

6120062--666839--Screenshot.png

Under normal circumstances the name of the object containing the script and the type of the script are more than enough for me, but in this case in my object I have:

  • A script that can have assigned one or more scripts to it
  • More scripts that I will assign to that “grouping” script in a specific order
  • Sometimes, more than one “grouping” script

I don’t want to pollute the tree by creating many empty sub objects and have them assigned a script each.

This project is being used by people with little to no coding experience, so I can’t use my normal approach of assigning everything under the hood.

I also thought of using strings directly and using labels of each object, but string comparison is really slow, it would require some sort of search and the level designers could screw up pretty easily.

Thanks in advance

Sounds to me like you probably want to make a custom editor inspector. Google up for some tutorials, it’s pretty simple and lets you limitlessly extend Unity’s basic functionality.

You’d need to write a custom editor for your script, which can read the serialized values of the assigned references and manually display them somewhere.

I’d give an example, but I’m away from my PC at the moment and am typing this with my phone.