Serializeable Vector2 defaults

How can I define a Vector2 with defaults for Unity UI?

works: however defaults to (0,0)
_vec2: Vector2;

errors: cannot convert from ‘double’ to ‘float’
_vec2: Vector2 = new Vector2(0.0,1.0);


Original Post on Discord

by user 943936853348855838

Ah that looks like a bug in the component compiler. I think as a workaround you could mark the field with @nonSerialized in typescript and declare it in a partial class manually

The foldout here contains examples about the partials part Needle Engine Scripting | Needle Engine Documentation

I think ill fixed it in the compiler + added a test for it

will make a new release (the compiler package)

It’s in component compiler version 1.9.1

Can you try with the latest version? It bumps the dependency too

Pulling it now. So part of the problem may be my declarations as I am having issues with a Boolean in the UI also. How do I need to set it up so the value gets sent back to Needle?

_loop?: boolean = false;

but it always returns false.

by user 943936853348855838

What does “sent back to needle” mean? Unity or runtime?

the delcaration looks fine

runtime gets the value from Unity.

by user 943936853348855838

Ok - but it doesnt?

correct. let me readd and see if something is broken.

by user 943936853348855838

First image is how it is set in Unity, my code, and the report in console.log


by user 943936853348855838

PM you the bug zip.

by user 943936853348855838

Let me publish to Glitch real quick

by user 943936853348855838

by user 943936853348855838

Using my fancy overlay content and clickable geometry. :smile:

by user 943936853348855838

haha is it a bug that they seem to rotate in the inverse direction?