I have a simple GUI, 6 buttons, and a couple scroll views. The computer noticeably slows down when I open this GUI. Is there a more efficient way memory wise, to do this stuff?
If this is related to your question about the BasicSword() GUI, it’s probably the Debug.Log() calls. They will really slow down any per-frame operation such as GUI.
Here are some other tips, from an answer I gave at http://answers.unity3d.com/questions/513224/hud-with-a-lot-of-elements-efficient-way.html:
First, every OnGUI method has significant overhead to set up, even if the method is empty. So the first rule is to use only one OnGUI. Put your OnGUI in a separate component that you enable only when the GUI is visible.
Second, put all your icons in a single texture atlas and use GUI.DrawTexture. Set the texture type to GUI.
Third… don’t do any processing in OnGUI (or any method that gets called every frame). Precompute and store all calculations. (However, surprisingly, this might not be as big a factor as the overhead for simply calling OnGUI, so make sure you only have one OnGUI.)
Similarly, don’t use GUILayout to compute GUI control positions. It will double the time it takes to draw the GUI. Precompute absolute positions.
And only assign GUI.skin once, at the beginning of OnGUI, if you’re using a custom skin. Likewise, don’t create new GUIStyles every time OnGUI is called. If you have to create a new style, create it once and store it.
Also, don’t call Debug.Log in any per-frame methods. It will really slow things down.