GUILayout.Togglestatic function Toggle (value : boolean, image : Texture, params options : GUILayoutOption[]) : booleanstatic function Toggle (value : boolean, text : String, params options : GUILayoutOption[]) : booleanstatic function Toggle (value : boolean, content : GUIContent, params options : GUILayoutOption[]) : booleanstatic function Toggle (value : boolean, image : Texture, style : GUIStyle, params options : GUILayoutOption[]) : booleanstatic function Toggle (value : boolean, text : String, style : GUIStyle, params options : GUILayoutOption[]) : booleanstatic function Toggle (value : boolean, content : GUIContent, style : GUIStyle, params options : GUILayoutOption[]) : booleanParameters
Returnsboolean - The new value of the button. DescriptionMake an on/off toggle button.
JavaScripts
// Draws 2 toggle controls, one with a text, the other with an image.
var aTexture : Texture; private var toggleTxt : boolean = false; private var toggleImg : boolean = false; function OnGUI () { if(!aTexture) { Debug.LogError("Please assign a texture in the inspector."); return; } toggleTxt = GUILayout.Toggle(toggleTxt, "A Toggle text"); toggleImg = GUILayout.Toggle(toggleImg, aTexture); } using UnityEngine;
using System.Collections; public class example : MonoBehaviour { public Texture aTexture; private bool toggleTxt = false; private bool toggleImg = false; void OnGUI() { if (!aTexture) { Debug.LogError("Please assign a texture in the inspector."); return; } toggleTxt = GUILayout.Toggle(toggleTxt, "A Toggle text"); toggleImg = GUILayout.Toggle(toggleImg, aTexture); } } import UnityEngine
import System.Collections class example(MonoBehaviour): public aTexture as Texture private toggleTxt as bool = false private toggleImg as bool = false def OnGUI(): if not aTexture: Debug.LogError('Please assign a texture in the inspector.') return toggleTxt = GUILayout.Toggle(toggleTxt, 'A Toggle text') toggleImg = GUILayout.Toggle(toggleImg, aTexture)
|

