Field types
Basic Types
Type | Description |
---|---|
boolean | Holds a true or false value; both zero and the empty string are considered true. |
float | Represents floating-point numbers, i.e., numbers with decimal points. |
integer | Represents whole numbers without decimal points. |
string | Represents a sequence of characters, typically used to store text. |
Vector2 | Stores a two-dimensional vector, typically used to represent positions or directions in a 2D space. |
Vector3 | Stores a three-dimensional vector, commonly used for positions or directions in a 3D space. |
GameObject | YahahaObject, an object within the game scene that can be manipulated or interacted with. |
Prefab | A predefined object that can be instantiated within the game scene. |
AnimationClip | Contains animation data used to create visual effects and character movements. |
AudioClip | Stores audio data, such as sound effects or background music. |
Texture2D | Represents a 2D image or texture, often used for rendering sprites and other graphical elements. |
Color | Stores color information, such as RGB or RGBA values. |
File | Represents a generic file, which can be used for various purposes within the game. |
Class Type
A class type field consists of several fields of different types. Here's an example of how to define and use a Class Type field:
local InnerClass = {
type = "object",
fields = {
{ name = "innerClassName", type = "string" },
{ name = "innerClassValue", type = "integer" },
},
}
local OuterClass = {
type = "object",
fields = {
{ name = "outerClassName", type = "string" },
{ name = "outerClassValue", type = "float" },
{ name = "innerClassField", type = InnerClass },
},
}
local fieldDefs = {
---Define your Property window fields here.
{
name = "outerClassField",
type = OuterClass
}
}
script.DefineFields(fieldDefs)
The Properties window will show below:
In the Property window, you will see the outerClassField displaying the defined OuterClass properties. The field value structure is as follows:
{
['outerClassField'] = {
['outerClassValue'] = 0,
['outerClassName'] = '',
['innerClassField'] = {
['innerClassName'] = '',
['innerClassValue'] = 0
}
}
}
List Type
A list type field represents a variable-length list of a specified type. Here's an example demonstrating the use of a List Type field:
local FloatList = {
type = "list",
items = {
type = "float"
}
}
local PlayerClass = {
type = "object",
fields = {
{
name = "playerName",
type = "string"
}
}
}
local PlayerList = {
type = "list",
items = {
type = PlayerClass
}
}
local fieldDefs = {
---Define your Property window fields here.
{
name = "floatList",
type = FloatList
},
{
name = "playerList",
type = PlayerList
}
}
script.DefineFields(fieldDefs)
The Property window will show like below:
The Property window will display the floatList and playerList fields with their respective value structures, as shown below:
{
['playerList'] = {
[1] = {
['playerName'] = ''
}
},
['floatList'] = {
[1] = 0
}
}