This function can be used to check if the given layer has a shader assigned to it. You supply the layer ID (which you get when you create the layer using layer_create()) or the layer name (as a string - this will have a performance impact), and the function will return either the shader index of the shader assigned, or -1 if no shader is assigned.
layer_get_shader(layer_id)
参数 描述 layer_id The unique ID value of the layer to target (or the layer name as a string)
Shader Index or -1if no shader is assigned
if layer_get_shader(layer) == -1
{
layer_shader(layer, shd_Sepia);
}
The above code will check to see if the layer that the instance running the code has a shader assigned to it and if it doesn't one is assigned.