Skip to content

Conversation

@marklundin
Copy link
Member

Adds support for enum attributes by reference. Fixes #12 .

Both the following using literal and reference are now supported. Tests updated to include both use cases.

import { Script } from 'playcanvas'

/** @enum {number} */
const Lights = {
    ON: 1,
    OFF: 0,
    UNKNOWN: 0.5
}

class Hack extends Script {
    /**
     * @attribute
     * @type {Lights}
     */
    ambient = Lights.OFF
    
    /**
     * @attribute
     * @type {Lights}
     */
    spec = 0
}

export { Hack };

@marklundin marklundin added the enhancement New feature or request label Sep 18, 2024
@marklundin marklundin self-assigned this Sep 18, 2024
@marklundin marklundin merged commit dc778d5 into main Sep 18, 2024
@marklundin marklundin deleted the fix-enum branch September 18, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enum constants not evaluated

3 participants