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

Allow tweening for long and ulong data types #6

Closed
ScriptGeek opened this issue Mar 29, 2015 · 9 comments
Closed

Allow tweening for long and ulong data types #6

ScriptGeek opened this issue Mar 29, 2015 · 9 comments

Comments

@ScriptGeek
Copy link

DOTween makes things incredibly easy and I'd like to see it support more of the primitive data types. My video game project requires unsigned long integers to tween a score display. It would be fantastic if DOTween provided a way to handle this.

@Demigiant Demigiant self-assigned this Mar 29, 2015
@Demigiant
Copy link
Owner

Hi,

Not a problem at all, should take me just a short time. Gonna implement them in the next days.

@Demigiant
Copy link
Owner

Hey, I implemented it for long, but am having issues with ulong, and I'd need some help.

Obviously, I need to multiply a ulong for a float in order to tween it correctly. That is not a problem, and I end up with a float result that is the correct equivalent of the required ulong.

The problem is between the conversion from float to ulong. Convert.ToUInt64 (as well as casting to ulong) returns a result, absurdly, whose max allowed value is the max value of a long instead than of a ulong. The only thing that works is converting the resulting float FIRST to a string and THEN to a ulong. But the problem with that is that it generates byte allocations every frame because of the string.

Do you have any better idea for the conversion? Am I missing something?

@ScriptGeek
Copy link
Author

Thanks for taking a look at this so quickly, I wasn't expecting such a lightning fast response!

I could probably buy some time by using the long data type in the meantime while ulong is being implemented. I'll tinker around a bit and see what I can discover about conversions. Maybe a persistent bit array can be used in the conversion process or maybe there's some other kind of built in conversion trick that will suffice. I'll take a look and see what I can come up with.

@Demigiant
Copy link
Owner

Great, that would be very helpful.

In the meantime, you can grab the updated version here. Ulong is implemented too, just with those byte allocations that we don't like.

@ScriptGeek
Copy link
Author

Well, I checked it out and I found a solution. Cast the float to a decimal and then the decimal can be multiplied by the ulong. So something like this:

ulong foo = (ulong)(ulong.MaxValue * (decimal)1f;

@Demigiant
Copy link
Owner

Nice! Gonna try tomorrow morning :)

@Demigiant
Copy link
Owner

Works like a beauty, thanks a lot for the help! New download link coming in next comment

@Demigiant
Copy link
Owner

Implemented in v1.0.416

v1.0.416

@ScriptGeek
Copy link
Author

Glad I could help, thanks for the awesome support!

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

No branches or pull requests

2 participants