Hello Guest

Author Topic: Perf Issue W/ tk2dPixelPerfectHelper  (Read 4255 times)

jmcguirk

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Perf Issue W/ tk2dPixelPerfectHelper
« on: April 04, 2013, 04:38:07 pm »
So this started showing up in my scene creation profile as a big CPU hit,

   /// <summary>
   /// Global singleton instance.
   /// </summary>
   public static tk2dPixelPerfectHelper inst
   {
      get
      {
         if (_inst == null)
         {
            _inst = GameObject.FindObjectOfType(typeof(tk2dPixelPerfectHelper)) as tk2dPixelPerfectHelper;
            if (_inst == null)
            {
               return null;
            }
            inst.Setup();
         }
         return _inst;
      }
   }


Since essentially every tk2dsprite or textmesh that gets created or rescaled invokes an ObjectSearch that will never return successfully.

Seems to be safe to kill entirely (obviously you may need to continue to support backwards compat w/ those using tk2dPPH). Might be good to have that search governed by a killswitch

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Perf Issue W/ tk2dPixelPerfectHelper
« Reply #1 on: April 04, 2013, 07:27:38 pm »
Do you set pixelPerfect to true? It shouldn't actually search for this otherwise...
You're right though, its just a legacy bit of code. I'll be stripping this and maybe a few others in tk2d 2.0.