Parameters
Parameters let one Block do slightly different things for different callers, the way a function takes arguments. For example, a "Deal Damage" Block with an Amount parameter, or a "Set Lamp" Block with Color and Intensity.
Adding parameters
- Under Parameters, click Add Parameter.... The searchable type window opens, like Add Instruction.
- Pick a type (Number, Color, Game Object, and so on).
- Open the new parameter to set its name and default value.
Each parameter row shows its name and, on the right, its type and default value, for example Amount Number = 10.
Parameter names are unique within a Block. A repeated name becomes "Name (1)" when you finish editing it.
Built-in types
Every Visual Script Get value can be a parameter. With Visual Script alone, that's:
Animation Clip, Audio Resource, Bool, Color, Game Object, Integer, Material, Number, Quaternion, Scene, Scriptable Object, Sprite, String, Texture, Vector 2 and Vector 3.
Get values from other packages and from your own scripts are added automatically. See Parameter types and your own values.
Reading a parameter inside a Block
In any field of an instruction or condition inside the Block:
- Click the field's value dropdown.
- Choose Parameters > Block Parameter.
- Pick the parameter from the list.
The field then shows the parameter's name, and at run time it gets the value the call passed in.
- Block Parameter only appears while you're editing a Block.
- The list only shows parameters the field can read. A Number field lists Number and Integer parameters, a Game Object field lists Game Object parameters, and so on.
- A few conversions are allowed:
- Text (String) fields can also read Number and Bool parameters.
- Vector 2 and Vector 3 fields can read each other.
- The list updates as you add, rename or remove parameters.