Material Property Definition

Developers use the Editor module to customize material properties bound to this Shader. The Galacean editor automatically reflects these material properties to the Inspector panel of the material asset.

Editor Module Syntax Skeleton

Editor {
    Properties {
        material_BaseColor("Offset unit scale", Color) = (1,1,1,1);
        ...
 
        Header("Emissive")
        {
            material_EmissiveColor("Emissive color", Color) = (1,1,1,1);
            ...
        }
        ...
    }
 
    ...
 
    Macros {
        [On] UV_OFFSET("UV Offset", Range(1,100)) = 10;
        ...
 
        Header("") {
            SOME_MACRO("label", Int) = 1;
        }
    }
 
    ...
 
    // Specifies the path to the UIScript project in the editor.
    UIScript "./shaderScript.ts";
}

Material Property Definition

/**
 * @language zh
 * Comments description
 */
 
/**
 * @language en
 * 注释描述
 */
propertyName("Description", EditType) = [DefaultValue];
  1. Use the Header directive to group related properties. The Inspector panel will reflect this hierarchy:
Header("Emissive") {
    material_EmissiveColor("Emissive color", Color) = (1,1,1,1);
    ...
}
  1. Use comments to specify hover tooltips in the Inspector. The @language directive supports multilingual annotations.

The supported EditType list is as follows:

EditTypeExample
BoolpropertyName("Property Description", Boolean) = true;
IntpropertyName("Property Description", Int) = 1;
propertyName("Property Description", Range(0,8)) = 1
propertyName("Property Description", Enum(Item1: 1, Item2: 2, Item3: 3)) = 1 // Enum
FloatpropertyName("Property Description", Float) = 0.5;
propertyName("Property Description", Range(0.0, 1.0)) = 0.5;
propertyName("Property Description", Enum(Item1: 1.0, Item2: 2.0, Item3: 3.0)) = 1.0; // Enum
Texture2DpropertyName("Property Description", Texture2D);
TextureCubepropertyName("Property Description", TextureCube);
ColorpropertyName("Property Description", Color) = (0.25, 0.5, 0.5, 1);
Vector2propertyName("Property Description", Vector2) = (0.25, 0.5);
Vector3propertyName("Property Description", Vector3) = (0.25, 0.5, 0.5);
Vector4propertyName("Property Description", Vector4) = (0.25, 0.5, 0.5, 1.0);

Enum Type

propertyName("Property Description", Enum(Item1: 1, Item2: 2, Item3: 3)) = 1;

Only Int and Float types support enums currently. Mixed type enums (e.g., combining Int and Float) are not supported. The following example will not be parsed correctly:

propertyName("Property Description", Enum("Item1":1, "Item2":2.0, "Item3": 3)) = 2.0;

Material Macro Property Definition

Used to reflect macros used in the Shader to the Inspector, enabling flexible adjustments to Shader-dependent macros in the editor.

// Enabled/Disabled
[On/Off]macroName("MacroLabel", EditType) = [DefaultValue];

The [On/Off] directive specifies the macro's default state. The editor currently supports the following macro types:

TypeExample
No-Value MacromacroName("Macro Description");
BoolmacroName("Macro Description", Boolean) = true;
IntmacroName("Macro Description", Int) = 1;
macroName("Macro Description", Range(0,8)) = 1;
FloatmacroName("Macro Description", Float) = 0.5;
macroName("Macro Description", Range(0.0, 1.0)) = 0.5;
ColormacroName("Macro Description", Color) = (0.25, 0.5, 0.5, 1);
Vector2macroName("Macro Description", Vector2) = (0.25, 0.5);
Vector3macroName("Macro Description", Vector3) = (0.25, 0.5, 0.5);
Vector4macroName("Macro Description", Vector4) = (0.25, 0.5, 0.5, 1.0);

Was this page helpful?