How to customize editor to show, in an array of scriptA within scriptB, the public vars of each scriptA[n] element?

Hey y’all,

I was wondering if it was possible to customize the editor in such a way that, given an array of script (a) in script (b), I could edit each iteration of script (a)'s public variables.

To exemplify, let’s say we have these two scripts:


//testScript.js

var stringVar : String;
var intVar : Int; 

function Start(){
//...
}

function Update(){
//...
}

//TestScriptEditor.js
var intArray : int[]; var scriptArray : TestScript[];

function Start () {
//...
}

Normally, I’d get something like this out of that:
15931-shot2.png

I was curious of how to get it to behave like this (masterful MS Paint skills):

I took a bit of time last week to learn a bit about custom editor GUIs, but don’t know quite enough to handle this. I do feel like it’s possible (and probably common). Of course, using straight up “TestScript” is most likely bad form since the editor is expecting there to be an object with the script I think, but maybe I’m wrong.

Any thoughts? I’d love to hear from the community!

You will get this functionality if you have your class derive from System.Object. In UnityScript:

//TestScript.js
#pragma strict

@SerializeField
public class TestScript {
/*implementation*/
}

The reason you don’t get this with scripts derived from MonoBehaviours is that they are already attached to a GameObject (somewhere, unless the developer is breaking the rules), and it would be redundant (possibly even dangerous) to be able to modify them in two places.