akhilkrushnaa / hotween

Automatically exported from code.google.com/p/hotween
0 stars 0 forks source link

ABSTweenPlugin is allocating 20B each frame (base on Unity Profiler). Maybe, I have a way to avoid this. #73

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I've done some profiling and I think we can avoid extra allocation while 
plugins is calling SetValue from ABSTweenPlugin.

I'm not an expert, so maybe my solution isn't good at all, but at least I know 
that there is no more allocation (base on Unity Profiler).

Instead of having one SetValue method signature in ABSTweenPlugin, you could 
create multiple SetValue method with specific signature (ex: SetValue(Vector3 
p_value), SetValue(Quaternion p_value)).

I've add two method for the moment with specific signature for Vector3 and 
Quaternion and it seems to avoid the extra allocation when using Hotween.To 
with Transform.position, localPosition, localScale, rotation, localRotation.

If the way I've done it is good, maybe you could create more method with 
specific signature for float, int, etc...

Here's your ABSTweenPlugin with the modification I've made till now. I've 
encapsulate what I've changed in a region tag MODIFICATIONS

Thanks,
David

PS Contact me if you have time to check it :)

Original issue reported on code.google.com by bevelart...@gmail.com on 28 Apr 2014 at 9:54

GoogleCodeExporter commented 8 years ago
Forgot to say, I'm profiling with Unity Deep Linking. There's an allocation of 
84B each frame. 64B is for the SetGOName (which is editor only), and the other 
20B is for what I mentionned above. 

Original comment by bevelart...@gmail.com on 29 Apr 2014 at 12:51

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hey David,

that is great, thanks for the help and for encapsulating everything clearly so 
I can check it out without fears :) Gonna check it later today.

Cheers,
Daniele

Original comment by daniele....@gmail.com on 30 Apr 2014 at 9:12

GoogleCodeExporter commented 8 years ago
Checked, and that is perfect. Only issue, in case I want to tween a Vector3 
that is not part of a Transform, nothing would happen with your modification, 
so I fixed that (you can see the changes in the latest commit - practically, if 
the target is a Transform, it behaves like you wrote, otherwise it reverts to 
normal, including GC allocation).

Original comment by daniele....@gmail.com on 30 Apr 2014 at 10:56