I read some requests for this a few years back which sort of morphed into a more
complicated request (hiding variables based on other variable values) which was then closed but I don’t think ever resolved. Im just wishing for the very basics here.
p.s I know i can just create something like this.myVar=27; manually in the init method but in some cases i would like to keep my attributes defined in the normal way at the top of the script.
calling @Mark_Lundin
but I’d say the reason for attributes is to have them exposed in the inspector. If you don’t want them exposed, don’t use the attributes.
Hmm, agreed, but sometimes I might want to hide then temporarily or you may have a variable which is a chunk of quite complicated json schema or enums which takes time to recreate elsewhere. A ‘visible’ parameter would just make things so much easier.
With this new format, you can simply remove the /** @attribute */ tag above the variable, and it will no longer be visible in the editor. You can read more about the proposal here.
It’s unlikely we’ll be making any further changes to the the older scripting/attribute system, although we will continue to support it. Hope that helps
This isn’t possible at the moment, but a lot of people are asking, so we’ll definitley investigate.
Currently thinking something like this would work;
class MyScript extends Script {
/** @attribute */
a = 0;
/**
* @attribute
* @visibleWhen {a === 0}
*/
b = 1;
}
This tells the editor that b is only visible when a === 0. This obviously allows you to construct more complex conditions like only showing b when a is 0 and maybe when c is true.