Dec 12, 2013

[Unity3d] GUI Button Image

  1. public Texture2D center;
  2.  
  3. void Start() {
  4. ...
  5. center = (Texture2D) Resources.Load("center", typeof(Texture2D)); // Assigns a texture named "center.png" to a Texture2D(center).
  6.  
  7. ...
  8. }
  9.  
  10. void OnGUI() {
  11. ...
  12. if (GUI.Button (new Rect (850, 570, 32, 32), new GUIContent(center))) {
  13. ...
  14. }
  15. ...
  16. }

No comments:

Post a Comment