Open Thaina opened 2 years ago
+1, the number of time i wished there was a way to make point.x0z is beyond count!
I was like, ah yes, lets use assembly definition references to add this...
public partial struct float2
{
/// <summary>Swizzles the vector.</summary>
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public float3 xy0
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => new(x, y, 0);
}
}
But nope, as soon as it ends up in Bursted code... Burst error BC0102: Unexpected internal compiler error while processing function
At least new float3(float2, z)
exists.
Unfortunately, unity is apparently working on enabling users to extend native class, using the attribute [ExtensionsOfNativeClass], but is definitely not supported at the moment. In the meantime, You can do a pull request and implement it in this file : https://github.com/LTMX/Unity.mathx/blob/master/Runtime/mathx.floatx.gen.cs Have a nice day fellow !
Please add complete swizzle property to
int2
float2
int3
float3
similar toint4
andfloat4
and define it as 0So that we could simply upcast
vec2
andvec3
to another dimension easily as downcastvec4
to lower dimensionSuch as
Alternatively it might be
xy0
x0y
_0xy
yx0
y0x
_0yx
and maybexy1
x1y
_1xy
yx1
y1x
_1yx
and so on for specific default number