public class demo : MonoBehaviour { public Texture texture; private bool textBool = false;toggle private bool textureBool = true; private void OnGUI() { if (!texture) { //判断图片是否参加 Debug.LogWarning("请添加一张图片"); return; } textBool=GUI.Toggle(new Rect(Screen.width / 8.5f, Screen.height / 7, Screen.height / 5, Screen.height / 5),textBool,"开关控件"); textureBool=GUI.Toggle(new Rect(Screen.width / 4, Screen.height / 7, Screen.height / 5, Screen.height / 5),textureBool,texture); } }
来源:https://www.cnblogs.com/zyz322/p/12450399.html