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


C# Toggle.GetComponent方法代码示例

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


在下文中一共展示了Toggle.GetComponent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToggleStateChanged

 private void ToggleStateChanged(Toggle toggle, bool state)
 {
     // If the toggle was enabled notify the group
     if (state == true)
     {
         result.text = toggle.GetComponent<ToggleValue>().Value.ToString();
     }
 }
开发者ID:Tsetso,项目名称:UnityGUIExamples,代码行数:8,代码来源:ToggleGroupControl.cs

示例2: UpdateAttribute

        public void UpdateAttribute(Toggle toggle)
        {
            if (!toggle.isOn) {
                return;
            }

            int index = this.isEditingYellowTeam ? 0 : 1;
            string description = "Enter equation. Current: (";
            EnumToggle enumToggle = toggle.GetComponent<EnumToggle>();
            if (enumToggle != null) {
                switch (enumToggle.value) {
                    default:
                        Debug.LogError("Invalid toggle value.");
                        break;
                    case 0: //Health
                        this.equationInputField.text = description + this.teamEquations[index].health + ")";
                        UpdateLevelInfo(enumToggle.value, this.teamEquations[index].health);
                        break;
                    case 1: //Attack
                        this.equationInputField.text = description + this.teamEquations[index].attack + ")";
                        UpdateLevelInfo(enumToggle.value, this.teamEquations[index].attack);
                        break;
                    case 2: //Speed
                        this.equationInputField.text = description + this.teamEquations[index].speed + ")";
                        UpdateLevelInfo(enumToggle.value, this.teamEquations[index].speed);
                        break;
                    case 3: //Split
                        this.equationInputField.text = description + this.teamEquations[index].split + ")";
                        UpdateLevelInfo(enumToggle.value, this.teamEquations[index].split);
                        break;
                    case 4: //Merge
                        this.equationInputField.text = description + this.teamEquations[index].merge + ")";
                        UpdateLevelInfo(enumToggle.value, this.teamEquations[index].merge);
                        break;
                    case 5: //Attack Cooldown
                        this.equationInputField.text = description + this.teamEquations[index].attackCooldown + ")";
                        UpdateLevelInfo(enumToggle.value, this.teamEquations[index].attackCooldown);
                        break;
                }
            }
        }
开发者ID:tommai78101,项目名称:Multiplier,代码行数:41,代码来源:SimulationManager.cs

示例3: UpdateTeamToggle

        public void UpdateTeamToggle(Toggle toggle)
        {
            if (!toggle.isOn) {
                return;
            }

            EnumToggle enumToggle = toggle.GetComponent<EnumToggle>();
            if (enumToggle == null) {
                Debug.Log("Unable to obtain EnumToggle component. Did you accidentally passed in the wrong Toggle?");
                return;
            }

            this.isEditingYellowTeam = enumToggle.value == 0 ? true : false;

            //NOTE(Thompson): If enumToggle.value is not using 0 or 1, change this to check on isEditingYellowTeam.
            int index = enumToggle.value;
            Toggle attributeToggle = this.unitAttributeToggleGroup.GetSingleActiveToggle();
            if (attributeToggle != null) {
                EnumToggle attributeEnumToggle = attributeToggle.GetComponent<EnumToggle>();
                if (attributeEnumToggle != null) {
                    string equationValue = "Enter equation. Current: (";
                    switch (attributeEnumToggle.value) {
                        default:
                            Debug.LogError("Attribute Enum Toggle value is invalid.");
                            equationValue = "[INTERNAL ERROR]: Invalid attribute enum toggle value.";
                            break;
                        case 0:
                            equationValue += this.teamEquations[index].health + ")";
                            UpdateLevelInfo(attributeEnumToggle.value, this.teamEquations[index].health);
                            break;
                        case 1:
                            equationValue += this.teamEquations[index].attack + ")";
                            UpdateLevelInfo(attributeEnumToggle.value, this.teamEquations[index].attack);
                            break;
                        case 2:
                            equationValue += this.teamEquations[index].speed + ")";
                            UpdateLevelInfo(attributeEnumToggle.value, this.teamEquations[index].speed);
                            break;
                        case 3:
                            equationValue += this.teamEquations[index].split + ")";
                            UpdateLevelInfo(attributeEnumToggle.value, this.teamEquations[index].split);
                            break;
                        case 4:
                            equationValue += this.teamEquations[index].merge + ")";
                            UpdateLevelInfo(attributeEnumToggle.value, this.teamEquations[index].merge);
                            break;
                        case 5:
                            equationValue += this.teamEquations[index].attackCooldown + ")";
                            UpdateLevelInfo(attributeEnumToggle.value, this.teamEquations[index].attackCooldown);
                            break;
                    }
                    this.equationInputField.text = equationValue;
                }
            }
        }
开发者ID:tommai78101,项目名称:Multiplier,代码行数:55,代码来源:SimulationManager.cs

示例4: CenterToggleOnRect

		void CenterToggleOnRect(Toggle toggle) {
			RectTransform toggleRectTransform = toggle.GetComponent<RectTransform> ();
			RectTransform rectTransform = gameObject.GetComponent<RectTransform> ();
			CarouselToggler carousel = gameObject.GetComponent<CarouselToggler> ();
			ScrollRect scrollRect = gameObject.GetComponent<ScrollRect> ();
			Vector3 diff = rectTransform.position - toggleRectTransform.position;
			diff = contentRectTransform.InverseTransformVector (diff);
			if (carousel.horizontalWrap && scrollRect.horizontal) {
				if ( Mathf.Abs(diff[0]) > Mathf.Abs(scrollRect.content.rect.height-Mathf.Abs(diff[0])-rectTransform.rect.height) ) {
					diff[0] = -1*Mathf.Sign(diff[0])*Mathf.Abs(scrollRect.content.rect.height-Mathf.Abs(diff[0])-rectTransform.rect.height);
				}
			}
			if (carousel.verticalWrap && scrollRect.vertical) {
				if ( Mathf.Abs(diff[1]) > Mathf.Abs(scrollRect.content.rect.height-Mathf.Abs(diff[1])-rectTransform.rect.height) ) {
					diff[1] = -1*Mathf.Sign(diff[1])*Mathf.Abs(scrollRect.content.rect.height-Mathf.Abs(diff[1])-rectTransform.rect.height);
				}
			}
			Vector2 currentPosition = contentRectTransform.anchoredPosition;
			targetPosition.Set (
				scrollRect.horizontal? currentPosition.x + (diff[0]) : currentPosition.x,
				scrollRect.vertical?   currentPosition.y + (diff[1]) : currentPosition.y
				);
			startingPosition.Set(currentPosition.x,currentPosition.y);
			movingToPosition = true;
			currentProgress = 0;
			targetToggle = toggle;
		}
开发者ID:Chrismacolor,项目名称:UI-JMF,代码行数:27,代码来源:CarouselToggler.cs


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