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
marcel
(marwi)
January 19, 2023, 12:00am
2
Sure.
@serializable()
myStrings?: string[];
@serializable(Object3D)
myObjects?: Object3D[];
for custom types:
class MyClass {
@serializable()
myField:string;
}
@serializable(MyClass)
myClasses?: MyClass[];
marcel
(marwi)
January 19, 2023, 12:00am
3
Note that custom classes that are not components will not be automatically generated
marcel
(marwi)
January 19, 2023, 12:00am
4
so they either already exist in Unity or you need them in a C# script manually:
public class MyClass {
public string myField;
}
marcel
(marwi)
January 19, 2023, 12:00am
5
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
marcel
(marwi)
January 19, 2023, 12:00am
9
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;
marcel
(marwi)
January 19, 2023, 12:00am
10
and in c# you just have the enum type
public enum EffectEnum = { Powerup = 0 }