Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math functions conflicts with types #190

Open
HellGate94 opened this issue Mar 5, 2021 · 5 comments
Open

math functions conflicts with types #190

HellGate94 opened this issue Mar 5, 2021 · 5 comments

Comments

@HellGate94
Copy link

using static Unity.Mathematics.math; will cause conflicts with types like float3 type, preventing you from using float3.zero ('math.float3(float, float, float)' is a method, which is not valid in the given context)

naming of those functions should be reconsidered

@MrUnbelievable92
Copy link

Same goes for, for instance, quaternion.Euler(float3 xyz) - really annoying. This forces one to prefix all functions with math..

@unpacklo
Copy link
Collaborator

Yeah, it's an unfortunate mistake we made a long time ago. I plan to fix this in the future when we can do a major API breaking change.

@visose
Copy link

visose commented Apr 20, 2021

Is the mistake using static methods to avoid the new keyword?

@unpacklo
Copy link
Collaborator

Is the mistake using static methods to avoid the new keyword?

Basically, yes. The intent was to be able to be as close to hlsl syntax as possible so you wouldn't have to insert new everywhere when you're trying to initialize a type, but we overlooked the fact using static Unity.Mathematics.math; would cause problems elsewhere:

image

@Peaj
Copy link

Peaj commented Jul 4, 2024

Are there any news on this?
I am curious what the solution might be besides just not using using static Unity.Mathematics.math; or removing the static initializers and using new everywhere.
I really love the hlsl like syntax but this problem is a showstopper ☹️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants