You can use this function to get the Layer ID that the given element is on. You supply the unique element ID value (for example, as returned the function that created the element or from the room editor) and the function will return the unique ID of the layer that the element is found on. If the element ID given is not a valid one, then the function will return -1.
layer_get_element_layer(element_id)
参数 描述 element_id The unique ID value of the element to get the layer of
Layer ID or -1 if the element is invalid (ie: does not exist)
element = layer_get_element_layer(asset_1);
The above code gets layer ID for the element with the ID stored in the variable "asset_1" and stores it in a variable.