Can we change the script attributes by the type of an enum?

In the video in Unity, I set the enum to a certain type and also change the interface. Can I do this in PlayCanvas too?

Not sure what you mean here? You can have predefined dropdowns like this:

Kapture 2022-05-24 at 15.21.11

i wish that in the exaple that you send te atlas split disapear when the pcf3 is selected and wil reapeer with 4 more variables if the pcf5 is selected

in my exaple you can see that float and int is changing these are variables in the inspector

Sorry, it’s not clear what is happening in the video?

It sounds like you want to change the data type of value that can be entered?

You can do this without editor validation by having a dropdown of types and at runtime, parse the value by the data type selected (eg int would be using JavaScript parseInt() Method)

@yaustar I believe he wants to change what attributes are visible, based on the selection.
@Timme_Kingma this is currently not possible.

Related issue:

1 Like

yeah exactly that would help me in some general script like an transition script that can switch between int and trigger and will allow me to hide the int value :sweat_smile:

Is there any news on this situation?
I have an enumeration, that I would like to be hidden from the inspector, it’s an inGame variable, not something I would choose from the inspector.

@Dava Not 100% sure what you mean here. Are you asking to hide an entry of the enum list or the whole attribute? If the whole attribute, why is it an attribute if it’s not used by the Editor?

I would like to keep my code organized in the JSON form, but some elements to not be visible in the inspector, in other words, I would like to hide some attributes from the inspector

In which case, no you can’t hide that.

But at the same time, it doesn’t need to be there as properties can be added to JS objects at any time.

You can do the following instead:

CharacterController.attributes.add('movement', {
    type: 'json',
    schema: [{
        name: 'positions',
        type: 'entity',
        array: true,
        title: 'Lerp positions'
    }, {
        name: 'currentPosition',
        type: 'number',
        enum: [
            { 'Left': 0 },
            { 'Middle': 1 },
            { 'Right': 2 }

CharacterController.prototype.initialize = function () {
    this.movement.transitionTime = 0.2;

transitionTime is still part of this.movement JSON object and it’s not shown in the Editor.