T
T
tom1392014-11-21 20:03:29
Android
tom139, 2014-11-21 20:03:29

There is a GUI.Button in Unity3D, how to "dress" a sprite on it?

Hello! The problem is the following. There is a casual game created in Unity3D.
There is a script in C #, with the help of which the sound is turned off / on in the game. The question is, how to "dress" a sprite on a standard GUI.Button button? Now it looks like a regular gray rectangle, but I need my image to be. Below is the script:

using UnityEngine;
using System.Collections;
public class Hui : MonoBehaviour {
  public bool CanMute;
  void Start() {
    CanMute = true;
  }
  void OnGUI()
  {
    if (GUI.Button (new Rect (Screen.width - ((Screen.width / 60) * 2) - (Screen.width / 20 * 2), Screen.height / 60, Screen.width / 20, Screen.width / 20), "[email protected]"))
    {
      if (CanMute)
      {
        AudioListener.pause = true;
        CanMute = false;
      }
      else
      {
        AudioListener.pause = false;
        CanMute = true;
      }
    }
  }
}

Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniil Basmanov, 2014-11-21
@tom139

docs.unity3d.com/Manual/class-GUIStyle.html
If possible, it's better to switch to Unity 4.6 , it's much easier to do there.

X
xutesayor, 2017-02-23
@xutesayor

The first loads css, the second js.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question