Is it possible for enumeration attributes to have arbitrary values?

Is it possible to specify values which otherwise start from 0 in enumeration attributes?

Referring to http://developer.playcanvas.com/en/api/pc.script.html#attribute

pc.script.attribute('spellType', 'enumeration', 0, {
    enumerations: [{
       name: "Fire",
       value: 0
    }, {
       name: "Ice",
       value: 1
    }]
 });

We see that Fire === 0 and Ice === 1.
But what if I want Fire to be = 8 and Ice to be 3.

pc.script.attribute('spellType', 'enumeration', 0, {
    enumerations: [{
       name: "Fire",
       value: 8
    }, {
       name: "Ice",
       value: 3
    }]
 });

This doesn’t seem to work, when choosing Fire or Ice in the Editor attribute dropdown, Fire is always 0 and Ice is always 1.

It is possible to have values other than 0 , 1 etc in enumerations. The reason why this doesn’t work for you is probably because you changed the enumeration options in your code and hit refresh in the script attributes in the Editor, but due to a bug the Editor did not refresh the possible enumeration values. Try removing and adding the script again on that Entity and it should work.

I will log the bug in our bug tracker in the meantime.

Thanks Vaios - I’ll see if that solves the problem! :smiley: