Is it possible to create other List field than EventList?

Hello !

I would like to create a custom script to add Effects easily to my scene.
For that I would like to use List of string (To choice an effect) but I found only EventList, and display dynamically the parameters fields on my component on Unity. (unstead of making one script by effect, which I can make too if it’s not possible)

Is it possible ?

Original Post on Discord

by user 224464722878005248

Sure.

@serializable()
myStrings?: string[];

@serializable(Object3D)
myObjects?: Object3D[];

for custom types:

class MyClass {
  @serializable()
  myField:string;
}

@serializable(MyClass)
myClasses?: MyClass[];

Note that custom classes that are not components will not be automatically generated

so they either already exist in Unity or you need them in a C# script manually:

public class MyClass {
  public string myField;
}

Does that answer your question?

Not completely, but in part
In fact I used the wrong word, it’s not a “list” but a drop down menu like it :

by user 224464722878005248

by user 224464722878005248

For example Effect type : GlitchEffect
And the parameters of the glitchEffect appear

by user 224464722878005248

That’s just an enum. Same with classes, you need to have the enum declared in C# but then you can use it like this:

public enum EffectEnum = { Powerup = 0 }

//@type Namespace.EffectEnun
@serializable()
myEffect : EffectEnum = 0;

and in c# you just have the enum type

public enum EffectEnum = { Powerup = 0 }