Hello PlayCanvas community! I’m trying to create and expose a custom class in the editor. I have two use cases:
Use case #1
- I want to define a drop down list that can be selected from in the inspector. For example
SomeScript.attributes.add('colorSelection', { type:'dropdown', options:[ 'red', 'blue'] });
In the editor you should be able to drag this script onto an entity, then select the option ‘red’ or ‘blue’ from the dropdown, which could be accessed as print(this.colorSelection) => ‘red’
Use case #2
I want to define a custom class, and expose a new class object to the editor/inspector and be able to set variables there.
var someClass = { color : 'red', quantity : 3}
SomeScript.attributes.add('someNewObjectInstance', { type:'someClass' });
this would enable me to have a dictionary of custom objects that I can define in the editor using the inspector.
Is such a thing possible? (or rather is it easy or has anyone gone to the trouble?)
Thanks in advance!!
For clarification, here is the Unity C# equivalent question with solution:
https://forum.unity.com/threads/c-custom-class-display-in-inspector.89865/
Charlie