so i took a script form a forum post,http://forum.unity3d.com/viewtopic.php?t=46222 , and changed to be used for me:
but when i added this part:
it lagged my game REALLY bad, it must e something here, just try and help me please, if more info is needed tell me
asked Jul 14 '10 at 02:34 AM
You definitely don't want to have that code inside OnGUI. It runs multiple times a frame.
answered Jul 14 '10 at 03:55 AM
You just need to go through your code and separate the GUI stuff from the calculation stuff. Move the calculations into their own functions and then call them as needed when you press a button in the GUI.
Don't move it to LateUpdate. That won't solve the fundamental issue which is just simply that you need to organize your code into sections that get called when needed instead of multiple times per frame.
answered Jul 14 '10 at 07:56 AM
Use time.timeScale = 0 when inventory is open to freeze time. That should freeze the lag but if you want to have things moving in the background of the inventory than this is not the best option.
answered Oct 20 '12 at 12:28 PM
First of all - you have to go over the code and tidy it up.... Lots of wasted CPU cycles are bad for global warming :)
Second - if in fact when you add those lines it got really bad, just for kicks try and define it as a boolean and not let UnityScript figure it out by itself. See if it gives you some boost. Duck typing is fun, but has some performance loss.
answered Aug 11 '10 at 03:26 PM