Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Fixing Idiocies in my code...

Discussion in 'Scripting' started by Kilrath81, Jun 19, 2014.

  1. Kilrath81

    Kilrath81

    Joined:
    Nov 19, 2013
    Posts:
    153
    I have gone through and taken out all of the GetComponents in my Update statement and replaced them with component references that are populated once... What other noob performance destroying common scripting issues should i be looking out for? I changed my windows build game to android and now performance matters. so im trying to lock it down. on my note 2 the game runs a solid 60 FPS now but i need MOAR POWER for the poor older android devices.
     
  2. Frenzy07

    Frenzy07

    Joined:
    Nov 21, 2012
    Posts:
    12
    cashing components provide tiny performance profit
     
  3. Kilrath81

    Kilrath81

    Joined:
    Nov 19, 2013
    Posts:
    153
    The component references took my Note 2 from 57-60 FPS to a rock solid 60 FPS (so i dont know how much it actually helped since it wont go higher then 60) However the note 2 was a pretty peppy phone. MY game insta crashes on the S3 so i have no idea how it works on that older hardware.
     
  4. Sharp-Development

    Sharp-Development

    Joined:
    Nov 14, 2013
    Posts:
    353
    Profile your code, see what components/parts produce to much overhead. Either post them here, or send me a mail to look into your code snippets. There's generally much you can do to nano optimize your code.

    As of caching variables and getting rid of GetComponent calls all over the place does infact grant noticeable performance benefits. Unity does always P/Invoke into unmanaged code when calling GetComponent, so its rather costy. Caching is generally a good idea.
     
  5. Kilrath81

    Kilrath81

    Joined:
    Nov 19, 2013
    Posts:
    153
    i dont have pro for the profiler... unless im missing something there.
     
  6. Sharp-Development

    Sharp-Development

    Joined:
    Nov 14, 2013
    Posts:
    353
    The profiler is a unity pro feature unfortunatly.
     
  7. Kilrath81

    Kilrath81

    Joined:
    Nov 19, 2013
    Posts:
    153
    yea i cant afford 3000 usd or 150usd monthly for pro and android pro.
     
  8. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
    This isn't related to the OP but you should be aware that the Note 2 and S3 have near identical specifications, your insta-crash is likely related to the OS version more than hardware. If it's important to you I'd take another look at the program with that in mind, if you haven't already.
     
  9. zDemonhunter99

    zDemonhunter99

    Joined:
    Apr 23, 2014
    Posts:
    478
    There are some other ways of profiling other than the profiler you know...