当前位置: 首页>>代码示例>>C#>>正文


C# Toggle类代码示例

本文整理汇总了C#中Toggle的典型用法代码示例。如果您正苦于以下问题:C# Toggle类的具体用法?C# Toggle怎么用?C# Toggle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Toggle类属于命名空间,在下文中一共展示了Toggle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的Toggle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。