Error message for attribute.remove method

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'



Any insights would be appreciated!

You could try looking into the docs for removing attributes through code.

Thanks for the suggestion, DP01. I did read through the documentation prior to posting but was unable to locate any reference to this issue. The “attribute.remove” method should work as part of a valid function according to the available documentation (and appears to do so in practice). Why it causes the UI Editor to generate a failure is still a mystery to me though.

1 Like

Ur Welcome! I usually look through it for many errors, but still dunno why it doesn’t work.

It’s an odd edge case to remove an attribute which might be why the editor doesn’t handle it. I think you are the first to really use it that I’ve seen on the forums.

Thanks yaustar. Based on the evidence so far, I’m persuaded you’re right. The good news is that the attribute.remove function does work. I’ll just need to remember that the editor is only human and gets confused sometimes too!