I’m including the “add” method to establish an attribute in my script - the attribute name and its corresponding default number (-0.0). When I add the “remove” method immediately after the “add” method in the same script, the attribute is removed. I’m verifying this with a console.log. When the remove method is added to the script, the console.log writes “undefined” instead of the attribute’s default -0.0 value. I can also reestablish the attribute value buy deleting this “remove” method from my script. When the console.log is subsequently rewritten, the correct attribute default value is displayed again.
Despite this apparent proper functioning of the code, when I parse this script in the UI Editor after adding the remove method line of code, it displays this error:
TypeError: myscript.attributes.remove is not a function
My questions are these:
-
Why am I getting this error message in the UI Editor?
-
Why, when I reedit the code to take out the remove method does the error message continue to be displayed and not get refreshed? This happens despite a successful re-parsing of the script.
var Zoom = pc.createScript('zoom');
Zoom.attributes.add('distanceSensitivity', {
type: 'number',
default: -0.0,
title: 'Distance Sensitivity',
description: 'How fast the camera moves in and out. Higher is faster'
});
Zoom.attributes.remove('distanceSensitivity');
Any insights would be appreciated!