How do I make a property to allow multiple selections from the available engine and custom layers in typescript (3.8.5)?

Hi. I’d like to be able to have a component property that allows multiple selections in the Inspector. For some physics settings, I’ve managed to create a dropdown to allow me to pick a layer from those listed in the Node layer manager but I’m struggling when it comes to allowing the user to select multiple layers (like you can in the inspector for the Camera component’s Visibility property). Once I have this, it is easy to know which layers I can use for specific raycasts etc.

I’ve tried to make custom property drawers with help from the docs and other online sources but none of these work (some even give examples which register the drawer to the Editor module using Editor.addPropertyDrawer but I cannot locate the Editor module in CC3.8.5 as it’s not listed in the Project Settings, Preferences or the Extension Manager).

In Unity, I can just use a LayerMask but there doesn’t seem to be an equivalent in CC. Any help or guidance would be most welcome as I’m new to Cocos.

I just look up engine source code of Camera component, maybe this could help you:

@property({serializable: true})
_visibility: number = pipeline.CAMERA_DEFAULT_MASK
@type(Layers.BitMask)
get visibility () {
    return this._visibility
}
set visibility (val) {
    this._visibility = val;
}

and don’t forget to import:

import { _decorator, Component, Layers, pipeline } from 'cc';
const { ccclass, property, type } = _decorator;

Thank you so much, that worked perfectly! I had tried the Layers.BitMask approach but it would only ever display as a number in the Inspector. I only had a quick look at the definition files for the Camera component, not the full source code on GitHub, so never spotted the use of @type before the property get/set. I’m not used to having full source code access to an engine so will note this for future problems.

just so you know, engine source code is available at C:\ProgramData\cocos\editors\Creator (default installation)

Thanks once again! Beats trawling GitHub 8)