Display dynamic (non built in) arrays in the inspector

Hi

I want to have an array that I can fill in in the inspector. However I need to be able to add and remove elements to this array.
How can I do this?

Ideally I would use a .net generic list. However how would I get the inspector to display it?

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class LevelObjects : MonoBehaviour 
{
	public Transform[] objectsToFind;
public List<Transform> mlist = new List<Transform>();  // DOES NOT SHOW UP

void RemoveFromListOfObjectsToFind(Transform o)
	{
		objectsToFind.Remove(o); // DOES NOT WORK
	}
}

Thanks

You could make a custom inspector for your script to access a generic list, though this is admittedly less than ideal and probably more work than it’s worth. I hope I’m not overstepping my boundaries here, but generic lists show up just as arrays do in the inspector in version 2.6.

I will defenitely look into creating custom inspectors.

For now I resorted to :

  • keep the static array to allow me to setup my level in unity editor
  • In the start method, I copy all the data to an internal dynamic array.
  • All my functions operate on that dynamic array.

It is a little bit wasteful but for now it will do.

I did not even now that a version 2.6 was out. I am using 2.5.1

thanks!

It’s not out. Anybody with access to 2.6 should not be saying anything without permission.

–Eric

+1 on the above.

Matthew: keep your 2.6 experiences under wraps until we release please. :slight_smile: