本文整理汇总了C#中Toggle类的典型用法代码示例。如果您正苦于以下问题:C# Toggle类的具体用法?C# Toggle怎么用?C# Toggle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Toggle类属于命名空间,在下文中一共展示了Toggle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SetToggle
public void SetToggle(Toggle toggle)
{
if ((toggle.name).Contains("Database"))
{
GameObject[] dbTogglers = GameObject.FindGameObjectsWithTag("DatabaseToggle");
for (int i = 0; i < dbTogglers.Length; i++)
{
Toggle otherToggle = dbTogglers[i].GetComponent<Toggle>();
if (!string.Equals(dbTogglers[i].name, gameObject.name) && otherToggle.isOn)
{
otherToggle.isOn = false;
dbTogglers[i].GetComponent<ToggleToggler>().text.color = new Color(0.3f, 0.3f, 0.3f);
dbTogglers[i].GetComponent<ToggleToggler>().image.color = OffColor;
}
}
}
if ((toggle.tag).Contains("MusicToggle"))
{
GameObject[] musicTogglers = GameObject.FindGameObjectsWithTag("MusicToggle");
for (int i = 0; i < musicTogglers.Length; i++)
{
Toggle otherToggle = musicTogglers[i].GetComponent<Toggle>();
if (!string.Equals(musicTogglers[i].name, gameObject.name) && otherToggle.isOn)
{
otherToggle.isOn = false;
musicTogglers[i].GetComponent<ToggleToggler>().text.color = new Color(0.3f, 0.3f, 0.3f);
musicTogglers[i].GetComponent<ToggleToggler>().image.color = OffColor;
}
}
}
if (toggle.isOn)
{
if ((toggle.tag).Contains("MuteToggle") || (toggle.name).Contains("RtsOn"))
{
text.text = "On";
if ((toggle.name).Contains("SoundMute"))
{
soundFx.GetComponent<AudioSource>().mute = true;
}
}
image.color = OnColor;
}
else
{
if ((toggle.tag).Contains("MusicToggle"))
{
GameObject source = GameObject.FindGameObjectWithTag("MusicSource");
source.GetComponent<MusicController>().PlaylistStop();
}
else if ((toggle.tag).Contains("MuteToggle") || (toggle.name).Contains("RtsOn"))
{
text.text = "Off";
if ((toggle.name).Contains("SoundMute"))
{
soundFx.GetComponent<AudioSource>().mute = false;
}
}
image.color = OffColor;
}
}
开发者ID:WilliamRADFunk,项目名称:vedic,代码行数:60,代码来源:ToggleToggler.cs
示例2: Awake
void Awake()
{
_ts = ToggleObj.gameObject.GetComponent<Toggle>();
_tx = TextObj.gameObject.GetComponent<Text>();
_tor = ToggleObj.GetComponent<RectTransform>();
_txr = TextObj.GetComponent<RectTransform>();
}
开发者ID:illvisation,项目名称:cellVIEW_bdbox,代码行数:7,代码来源:ToggleFieldItem.cs
示例3: Start
void Start()
{
// Set up our fullscreen toggle button
if (GameObject.Find("FullscreenToggle") != null) {
fullscreen = GameObject.Find("FullscreenToggle").GetComponent<Toggle>();
if (Screen.fullScreen) fullscreen.isOn = true;
else fullscreen.isOn = false;
}
// Set up our resolution dropdown box
if (GameObject.Find("ResolutionList") != null) {
resolutions = GameObject.Find("ResolutionList").GetComponent<ComboBox>();
ComboBoxItem[] items = new ComboBoxItem[Screen.resolutions.Length];
int counter = 0;
Resolution[] res = Screen.resolutions;
foreach (Resolution r in res) {
items[counter] = new ComboBoxItem(r);
counter++;
}
resolutions.Items = items;
resolutions.ItemsToDisplay = 5;
Resolution tmpRes = Screen.currentResolution;
foreach (Resolution r in Screen.resolutions) {
if (Screen.width == r.width && Screen.height == r.height) {
tmpRes = r;
break;
}
}
resolutions.SelectedIndex = System.Array.IndexOf(Screen.resolutions, tmpRes);
}
}
开发者ID:parkersprouse,项目名称:Spectrum,代码行数:34,代码来源:OptionsMenuHandler.cs
示例4: Reset
void Reset()
{
m_VRMode = GameObject.Find("VRMode").GetComponent<Toggle>();
m_IPAddress = GameObject.Find("IPAddress/InputField").GetComponent<InputField>();
m_PortNumber = GameObject.Find("Port/InputField").GetComponent<InputField>();
m_Message = GameObject.Find("Message").GetComponent<Text>();
}
开发者ID:ChunChunMorning,项目名称:SharedVR-client,代码行数:7,代码来源:SettingManager.cs
示例5: Start
// Use this for initialization
void Start()
{
if (camToggle == null)
{
camToggle = gameObject.GetComponent<Toggle>();
}
}
开发者ID:ironpencil,项目名称:critomit,代码行数:8,代码来源:CameraToggle.cs
示例6: Start
void Start()
{
// This automatically registers the event click on the button component
toggleButton = GetComponent<Toggle>();
toggleButton.onValueChanged.AddListener(Click);
SetIcon();
}
开发者ID:Jturesson90,项目名称:ReversoGit,代码行数:7,代码来源:ToggleButtonIcon.cs
示例7: Movement
public Movement(Node parent = null)
{
if (parent != null) this.parent = parent;
randInitialVel = new Toggle<float>(8f);
pushable = true;
mode = movemode.wallbounce;
}
开发者ID:GameMakersUnion,项目名称:BoulderDash-OrbIt,代码行数:7,代码来源:Movement.cs
示例8: Awake
void Awake()
{
anim = GetComponent<Animator>();
toggle = GetComponent<Toggle>();
toggle.onValueChanged.AddListener(OnValueChanged);
}
开发者ID:LittleBulldozer,项目名称:regime2015,代码行数:7,代码来源:CardClick.cs
示例9: Awake
void Awake() {
if (instance != null && instance != this) {
Destroy(gameObject);
}
if (instance == null) {
if (musicSlider == null)
musicSlider = transform.Find("Sounds/Music").GetComponentInChildren<Slider>();
if (masterSlider == null)
masterSlider = transform.Find("Sounds/Master").GetComponentInChildren<Slider>();
if (soundsSlider == null)
soundsSlider = transform.Find("Sounds/Sounds").GetComponentInChildren<Slider>();
if (musicToggle == null)
musicToggle = transform.Find("Sounds/Music").GetComponentInChildren<Toggle>();
if (masterToggle == null)
masterToggle = transform.Find("Sounds/Master").GetComponentInChildren<Toggle>();
if (soundsToggle == null)
soundsToggle = transform.Find("Sounds/Sounds").GetComponentInChildren<Toggle>();
if (fullScreenToggle == null) {
fullScreenToggle = transform.Find("Graphics/FullScreen/FullScreenCheck").GetComponent<Toggle>();
}
if (tooltipsToggle == null) {
tooltipsToggle = transform.Find("Graphics/Tooltips/TooltipsCheck").GetComponent<Toggle>();
}
UpdateSettings();
}
}
开发者ID:ForsakenGS,项目名称:LostKids,代码行数:29,代码来源:SettingsManager.cs
示例10: EnableSessionLimitInputField
public void EnableSessionLimitInputField(Toggle checkbox)
{
if (checkbox.isOn)
sessLengthInputField.image.enabled = true;
else
sessLengthInputField.image.enabled = false;
// ??? How to shorten this? Took me an hour, and this was the only way I could get it to work.
// if (checkbox.name == "TrialsToggle")
// {
// if (checkbox.isOn)
// if (minuteLimit.isOn)
// minuteLimit.isOn = false;
// else
// sessLengthInputField.image.enabled = true;
// else
// if (!minuteLimit.isOn)
// sessLengthInputField.image.enabled = false;
// }
// else if (checkbox.isOn)
// if (trialLimit.isOn)
// trialLimit.isOn = false;
// else
// sessLengthInputField.image.enabled = true;
// else
// if (!trialLimit.isOn)
// sessLengthInputField.image.enabled = false;
//}
}
开发者ID:TheHolodeckProject,项目名称:UnityHolodeckProject,代码行数:30,代码来源:LoadScene.cs
示例11: changeValue
public void changeValue(Toggle toggle)
{
if (toggle.isOn == true)
toggle.isOn = false;
else
toggle.isOn = true;
}
开发者ID:tcourreges,项目名称:HOPE,代码行数:7,代码来源:UIController.cs
示例12: Awake
void Awake()
{
ChildToggles = new List<Toggle>(this.GetComponentsInChildren<Toggle>());
foreach(var toggle in ChildToggles) {
var toggleRef = toggle;
toggle.onValueChanged.AddListener(_ => {
if(!_) {
if(ChildToggles.Count(a => a.isOn) < MinActiveElements)
LastDisabledToggle.isOn = true;
LastDisabledToggle = toggleRef;
}
if(_)
BoardEditor.Current.Board.ItemTypes.Add((ItemType)Enum.Parse(typeof(ItemType), toggleRef.name));
else
BoardEditor.Current.Board.ItemTypes.Remove((ItemType)Enum.Parse(typeof(ItemType), toggleRef.name));
});
BoardEditor.Current.OnLevelLoaded += _ => {
ChildToggles.ForEach(t => t.interactable = false);
ChildToggles.ForEach(t => t.isOn = _.ItemTypes.Contains((ItemType)Enum.Parse(typeof(ItemType), t.name)));
ChildToggles.ForEach(t => t.interactable = true);
};
}
}
开发者ID:satirikasha,项目名称:MatchThree,代码行数:25,代码来源:ElementsToggleWidget.cs
示例13: IsAnyActive
public static bool IsAnyActive(Toggle[] pizzas)
{
foreach(Toggle pizza in pizzas) {
if(pizza.IsActive()) return true;
}
return false;
}
开发者ID:NashIlli,项目名称:calculandox,代码行数:7,代码来源:Views.cs
示例14: Start
// Use this for initialization
void Start()
{
custom = FindObjectOfType<CustomManager>();
toggle = this.gameObject.GetComponent<Toggle>();
toggle.onValueChanged.AddListener((on) => custom.nodeIsAccept(toggle.isOn));
toggle.onValueChanged.AddListener((off) => custom.nodeIsAccept (toggle.isOn));
}
开发者ID:AlexMaskill,项目名称:DissertationGame,代码行数:8,代码来源:AcceptNodeCheckBox.cs
示例15: UpdateBool
public void UpdateBool(Toggle check)
{
if (check.isOn)
info = "true";
else
info = "false";
}
开发者ID:chadarm,项目名称:Cognitive_Rehab,代码行数:7,代码来源:CheckInput.cs
示例16: Awake
// Use this for initialization
void Awake ()
{
if (!sceneController)
sceneController = FindObjectOfType<SceneController>();
if (!generationValueLabel)
generationValueLabel = FindTextComponent("GenerationValue");
if (!waveNoValueLabel)
waveNoValueLabel = FindTextComponent("WaveNoValue");
if (!spawnNoValueLabel)
spawnNoValueLabel = FindTextComponent("SpawnNoValue");
if (!highestFitnessValueLabel)
highestFitnessValueLabel = FindTextComponent("HighestFitnessValue");
if (!solutionsValueLabel)
solutionsValueLabel = FindTextComponent("SolutionsValue");
if (!remainingEnemiesValueLabel)
remainingEnemiesValueLabel = FindTextComponent("RemainingEnemiesValue");
if (!sceneStateValueLabel)
sceneStateValueLabel = FindTextComponent("SceneStateValue");
if (!autoEvolveToggle)
autoEvolveToggle = GameObject.Find("AutoEvolveCheck").GetComponent<Toggle>();
autoEvolveToggle.isOn = sceneController.AutoEvolve;
}
开发者ID:Richy321,项目名称:TowerDefenseSolver,代码行数:31,代码来源:GA_GuiHandler.cs
示例17: Awake
protected virtual void Awake()
{
// Call the base class's function to initialize all variables
base.Awake();
// Find all UI elements in the scene
SMM_PlanterNameInputField = GameObject.Find("SMM_PlanterNameInputField").GetComponent<InputField>();
SMM_DefuserNameInputField = GameObject.Find("SMM_DefuserNameInputField").GetComponent<InputField>();
SMM_TutorialToggle = GameObject.Find("SMM_TutorialToggle").GetComponent<Toggle>();
SMM_BackButton = GameObject.Find("SMM_BackButton").GetComponent<Button>();
SMM_PlayButton = GameObject.Find("SMM_PlayButton").GetComponent<Button>();
SMM_NumOfBombsSlider = GameObject.Find("SMM_NumOfBombsSlider").GetComponent<Slider>();
SMM_NumOfBombsText = GameObject.Find("SMM_NumOfBombsText").GetComponent<Text>();
if (!SMM_PlanterNameInputField)
Debug.LogError("SMM_PlanterNameInputField");
if (!SMM_DefuserNameInputField)
Debug.LogError("SMM_DefuserNameInputField");
if (!SMM_TutorialToggle)
Debug.LogError("SMM_TutorialToggle");
if (!SMM_BackButton)
Debug.LogError("SMM_BackButton");
if (!SMM_PlayButton)
Debug.LogError("SMM_PlayButton");
if (!SMM_NumOfBombsSlider)
Debug.LogError("SMM_NumOfBombsSlider");
if (!SMM_NumOfBombsText)
Debug.LogError("SMM_NumOfBombsText");
if (!gameManager)
Debug.LogError("AWAKE: CANT find game manager in base");
// Get SM_Backdrop and disable renderer
smBack = GameObject.Find("SM_Backdrop");
smBack.SetActive(false);
}
开发者ID:khoavnguyen,项目名称:Unity-AR-Game-Explode-with-Friends,代码行数:35,代码来源:SharedModeMenuState.cs
示例18: OnEditModleToggleChanged
public void OnEditModleToggleChanged(Toggle toggle)
{
foreach (GameObject obj in editModleNodes)
{
if (obj.name == editModleDic[toggle.name])
obj.SetActive(true);
else
obj.SetActive(false);
}
if (toggle.isOn)
{
switch (toggle.name)
{
case "Toggle-loading":
break;
case "Toggle-start":
break;
case "Toggle-gaming":
break;
case "Toggle-gameover":
break;
default:
break;
}
}
}
开发者ID:sparxepisode,项目名称:H5Test,代码行数:28,代码来源:EditDirector.cs
示例19: clearUI
private void clearUI() {
if (lobbyUI != null) {
Destroy (lobbyUI);
lobbyUI = null;
readyToggle = null;
}
}
开发者ID:blufiro,项目名称:CiderFox,代码行数:7,代码来源:LobbyPlayerBehaviour.cs
示例20: SelectPRS
//To change the variable to be the selected one
public void SelectPRS( Toggle toggle)
{
if (toggle.isOn == true) {
if (toggle.name == "Toggle P") {
togglePRSName = "Toggle P";
}
else if (toggle.name == "Toggle R")
{
togglePRSName = "Toggle R";
}
else if(toggle.name == "Toggle S")
{
togglePRSName = "Toggle S";
}
else if(toggle.name == "Toggle C")
{
togglePRSName = "Toggle C";
}
}
if (togglePRSName == toggle.name) {
if(toggle.isOn == false)
{
togglePRSName = null;
}
}
}
开发者ID:RogerDong,项目名称:3D_Kit,代码行数:31,代码来源:ToggleInfo.cs
注:本文中的Toggle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论