FashGek / hotween

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

Add a flag to keep the HOTween GameObject. #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
To reduce memory allocation and garbage collection, I'd like to have the 
possibility to set a flag to keep the HOTween game object even when no tweens 
are active.

It should also not rename the game object because that also allocates memory 
(72B) in the Update, FixedUpdate, LateUpdate and TimeScaleIndependantUpdate for 
a total of 288B every frame.

Thanks

Original issue reported on code.google.com by rej.ri...@gmail.com on 13 Mar 2012 at 8:41

GoogleCodeExporter commented 9 years ago
Ok, will probably do it tomorrow (march 15).

About renaming it with the current number of tweens, I'll use 
platform-dependent compilation and have it renamed only when inside the editor.

Original comment by daniele....@gmail.com on 14 Mar 2012 at 9:47

GoogleCodeExporter commented 9 years ago
In the end I did it immediately :)
To prevent HOTween to be destroyed and recreated when new tweens are added, 
initialize HOTween with HOTween.Init(true), before starting any tween.

Original comment by daniele....@gmail.com on 14 Mar 2012 at 10:46

GoogleCodeExporter commented 9 years ago
Thanks a lot!

For the isEditor flag, you could go with this instead:

[System.Diagnostics.ConditionalAttribute("UNITY_EDITOR")]
static private void SetGOName()
{
    tweenGOInstance.name = GAMEOBJNAME + " : " + totTweens;
}

The function code is not included if UNITY_EDITOR isn't defined so that's even 
faster.

Thanks again for this great tool!

Original comment by rej.ri...@gmail.com on 14 Mar 2012 at 12:37

GoogleCodeExporter commented 9 years ago
Thanks a lot for the detailed infos :)

I tried using ConditionalAttribute, but since it's inside a DLL assembly it 
doesn't work (because Unity has no control over the defines included before 
compilation)?

Original comment by daniele....@gmail.com on 14 Mar 2012 at 5:16

GoogleCodeExporter commented 9 years ago
That's a good point.

Thanks for looking into it!

By the way, I don't know if you have the pro version of Unity but you can see 
all the Garbage Collector Alloc in the Profiler. I find this really useful to 
find allocation that are not needed and could be replaced. With the DeepProfile 
option, you can easily spot where the allocation occurs; really awesome stuff!

Original comment by rej.ri...@gmail.com on 14 Mar 2012 at 5:27

GoogleCodeExporter commented 9 years ago
Thanks for the advice.
I got the Pro version since a short while, but I still didn't check out the 
Profiler deeply. I'll follow your advice and definitely try to improve 
performance (gave a quick look at it and it really looks awesome!).

Original comment by daniele....@gmail.com on 14 Mar 2012 at 5:34