Editor.Model.Layer
ClassThe layers within a Editor.Model.LayerSet.
Index
Example
// Put several scene objects on the same Layer as an orthographic camera so
// that camera renders them. A SceneObject is only drawn by a camera when
// their layer sets intersect — make sure the target camera's renderLayer
// includes the layer used here, otherwise the objects will not be visible.
const model = this.pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
const scene = model.project.scene;
// Orthographic camera. Its renderLayer starts at the default set that
// covers Editor.Model.LayerId.Default.
const camObj = scene.createSceneObject('OrthoCamera');
const camera = camObj.addComponent('Camera') as Editor.Components.Camera;
camera.cameraType = Editor.Components.CameraType.Orthographic;
// Build a matching LayerSet from the id the camera uses, then assign it
// to each new object so the ortho camera will include them in rendering.
const layerId = Editor.Model.LayerId.Default;
const targetSet = Editor.Model.LayerSet.fromId(layerId);
camera.renderLayer = targetSet;
const objects = [
scene.createSceneObject('UiPanel'),
scene.createSceneObject('UiButton'),
scene.createSceneObject('UiLabel'),
];
for (const o of objects) {
o.layers = targetSet;
}
console.log(`Placed ${objects.length} objects on the same layer as the ortho camera.`);
Properties
id
id:
LayerId
The id of this layer.
name
name:
string
The name of the layer.