If you mean the NaN value you are getting for alpha … I tested the exact same attributes as yours, in two browsers, and I wasn’t able to reproduce this (I am getting 1 for alpha).
Though I’d say, don’t worry, since you aren’t using rgba but only rgb, so Ι don’t think they’ll be an issue here.
Thanks for the quick response. The alpha value is in fact unusued so that NaN is fine.
RGB always returning 0 is the real problem. I tried moving those attributes to another script, but still cannot get color values set in the inspector (or the default value when untouched).
Looks like I’ll have to dig a little deeper because I guess this works fine in a new project, just like you tested.
If this is isolated in a single project seems like some minor data corruption or something? @yaustar may be able to bring it to the attention of the editor team
I have tried all that. Renamed the attribute + parse, removed and added new attributes + parse. Even renamed the scripts + build & parse and deleted and recreated the entity.
Only thing I have not tried yet is settting up a new scene.
One more note before an admin can make the project accessible:
The color object created in the attribute can be modified via code:
this.sideColor.r = 1; // works
Color attributes on custom script components are not carried over from editor to launch version. I tried adding color attributes to other scripts in the project and none of them works.
Found the issue. Whatever NPM package you are using is monkey patching the way that the engine is handling script attributes. It’s based on an older API that tries to use set values against pc.Color#data which no longer exist (they have been replaced by .r, .g, .b, .a and the .data property is implemented to use a temporary array to support older projects).
Hence, it stays at 0, 0, 0, 1.
Once I fixed the monkey patch code in main.build.js, it ‘works’. I use ‘’ because I don’t know what else could be outdated with it the NPM package used.
We have developed a tool that can upload code to a PlayCanvas project which we are maintaining and doesn’t rely on monkey patching: https://github.com/playcanvas/playcanvas-sync that may be suitable for future projects.
Thank you so much for helping us out. At least we know the reason for this issue now. I’ll talk to the guy who has set up the project and see how we can fix it.