How can I define a Vector2 with defaults for Unity UI?
works: however defaults to (0,0)
@serializeable (Vector2)
_vec2: Vector2;
errors: cannot convert from ‘double’ to ‘float’
@serializeable (Vector2)
_vec2: Vector2 = new Vector2(0.0,1.0);
Thanks
Original Post on Discord
by user 943936853348855838
marwie1
(marwi)
November 6, 2022, 12:00am
2
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
marwie1
(marwi)
November 6, 2022, 12:00am
3
The foldout here contains examples about the partials part Needle Engine Scripting | Needle Engine Documentation
marwie1
(marwi)
November 6, 2022, 12:00am
4
I think ill fixed it in the compiler + added a test for it
marwie1
(marwi)
November 6, 2022, 12:00am
5
will make a new release (the compiler package)
marwie1
(marwi)
November 6, 2022, 12:00am
6
It’s in component compiler version 1.9.1
marwie1
(marwi)
November 6, 2022, 12:00am
7
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?
@serializeable()
_loop?: boolean = false;
but it always returns false.
by user 943936853348855838
marwie1
(marwi)
November 6, 2022, 12:00am
9
What does “sent back to needle” mean? Unity or runtime?
marwie1
(marwi)
November 6, 2022, 12:00am
10
the delcaration looks fine
runtime gets the value from Unity.
by user 943936853348855838
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
Using my fancy overlay content and clickable geometry.
by user 943936853348855838
marwie1
(marwi)
November 6, 2022, 12:00am
19
haha is it a bug that they seem to rotate in the inverse direction?