當前位置: 首頁>>代碼示例>>C#>>正文


C# RectTransform.GetComponentsInChildren方法代碼示例

本文整理匯總了C#中UnityEngine.RectTransform.GetComponentsInChildren方法的典型用法代碼示例。如果您正苦於以下問題:C# RectTransform.GetComponentsInChildren方法的具體用法?C# RectTransform.GetComponentsInChildren怎麽用?C# RectTransform.GetComponentsInChildren使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.RectTransform的用法示例。


在下文中一共展示了RectTransform.GetComponentsInChildren方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Start

		void Start () {
			carouselToggler = gameObject.GetComponent<CarouselToggler> ();
			ScrollRect scrollRect = gameObject.GetComponent<ScrollRect> ();
			content = scrollRect.content;
			Toggle[] toggles = content.GetComponentsInChildren<Toggle> ();
			lastToggle = toggles [0];
			StartCoroutine (WaitInactiveCycleAndReset());
		}
開發者ID:Chrismacolor,項目名稱:UI-JMF,代碼行數:8,代碼來源:CarouselRotator.cs

示例2: PlayScaleAnimation

 // Scale animation responsible for hiding and showing the element when required.
 IEnumerator PlayScaleAnimation(RectTransform thisRectTransform, Axis axis, float finalScale, float duration)
 {
     tabManager.busyWithButtonAnimation = true;
     float currentScale = 0.0f, stepDuration = 0.1f;
     // Get Current Scale
     if (axis == Axis.X)
     {
         currentScale = thisRectTransform.localScale.x;
     } else
         if  (axis == Axis.Y)
     {
         currentScale = thisRectTransform.localScale.y;
     }
     // Show Child Elements Back, If Showing
     if (finalScale > currentScale)
         foreach (RectTransform thatRectTransform in thisRectTransform.GetComponentsInChildren<RectTransform>())
             if (thatRectTransform!=thisRectTransform)
                 thatRectTransform.localScale = new Vector3(1,1,1);
     // Ensure At Least 2 Animation Steps
     if (stepDuration > duration/2) stepDuration = duration/2;
     // Calculate Steps
     // float scaleStep = (finalScale-currentScale)/(duration/stepDuration); // Remove Scale Step
     // Execute Animation
     for (float currentDuration=0; currentDuration<duration; currentDuration+=stepDuration)
     {
         float progress = currentDuration/duration;
         float easeProgress = (Mathf.Sin((-90f + 180f*progress)*Mathf.Deg2Rad)+1f)*0.5f;
         if (axis == Axis.X) thisRectTransform.localScale = new Vector3(currentScale + easeProgress * (finalScale - currentScale), thisRectTransform.localScale.y, thisRectTransform.localScale.z);
         else if (axis == Axis.Y) thisRectTransform.localScale = new Vector3(thisRectTransform.localScale.x, currentScale + easeProgress * (finalScale - currentScale), thisRectTransform.localScale.z);
         yield return new WaitForSeconds(stepDuration);
     }
     if (axis == Axis.X && thisRectTransform.localScale.x!=finalScale) thisRectTransform.localScale = new Vector3(finalScale, thisRectTransform.localScale.y, thisRectTransform.localScale.z);
     else if (axis == Axis.Y && thisRectTransform.localScale.y!=finalScale) thisRectTransform.localScale = new Vector3(thisRectTransform.localScale.x, finalScale, thisRectTransform.localScale.z);
     // Hide Child Elements, If Hiding
     if (currentScale > finalScale)
         foreach (RectTransform thatRectTransform in thisRectTransform.GetComponentsInChildren<RectTransform>())
             if (thatRectTransform!=thisRectTransform)
                 thatRectTransform.localScale = new Vector3(0,0,0);
     tabManager.busyWithButtonAnimation = false;
 }
開發者ID:leeohaddad,項目名稱:CodeWay,代碼行數:41,代碼來源:UITabButtonActiveBarAnimation.cs

示例3: InitializeTransitionPage

    public GameObject InitializeTransitionPage(GameObject transition)
    {
        //set the transition page
        GameObject go = Instantiate(transition as GameObject);
        transitionPage = go.GetComponent<RectTransform>();
        //the transition page parent needs to be the canvas (or one of its children)
        transitionPage.transform.SetParent(GameObject.FindGameObjectWithTag(parentTag).transform); //keep the canvas as the parent
        transitionPage.transform.localScale = Vector3.one;
        //fill the text and image arrays with components that need to be faded
        transitionTxts = transitionPage.GetComponentsInChildren<Text>();
        transitionImgs = transitionPage.GetComponentsInChildren<Image>();

        //start the page off at transparent
        foreach (Text t in transitionTxts)
            t.color = new Vector4(t.color.r, t.color.g, t.color.b, 0);
        foreach (Image i in transitionImgs)
            i.color = new Vector4(i.color.r, i.color.g, i.color.b, 0);

        transitionInitialized = true;

        return transitionPage.gameObject;
    }
開發者ID:coderDarren,項目名稱:TheArchitect,代碼行數:22,代碼來源:Transition.cs

示例4: ScaleSizeGivenExpectedWidth

    private void ScaleSizeGivenExpectedWidth(RectTransform rect, int width)
    {
        float originalWidth = originalPanelSize.x;
        float originalHeight = originalPanelSize.y;
        float scaleBy = width / originalWidth;

        Text[] allText = rect.GetComponentsInChildren<Text>(true);
        foreach(Text text in allText)
        {
            //Debug.Log ("Original font size: " + text.fontSize + " Font size: " + (int)(originalFontSize * scaleBy));
            text.fontSize = (int)(originalFontSize * scaleBy);
        }

        //Debug.Log ("Original width: " + originalWidth + " width: " + width);
        //Debug.Log ("Original height: " + originalHeight + " height: " + (int)(originalHeight*scaleBy));
        rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);
        rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (int)(originalHeight*scaleBy)+2);
    }
開發者ID:tng2903,項目名稱:game1,代碼行數:18,代碼來源:RenderScore.cs

示例5: SetPositionAndSizeOfRectTransform

    private void SetPositionAndSizeOfRectTransform(RectTransform rect, float xpos, float ypos, float width, float height)
    {
        float currentHeight = Mathf.Abs( rect.rect.yMax - rect.rect.yMin );
        float ratio = height / currentHeight;

        rect.anchoredPosition = new Vector2(xpos, ypos);
        rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);
        rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);

        Text[] allText = rect.GetComponentsInChildren<Text>(true);
        foreach(Text text in allText)
        {
            text.fontSize = (int)(text.fontSize * ratio)-1	;
        }
    }
開發者ID:tng2903,項目名稱:game1,代碼行數:15,代碼來源:UiPauseMenuController.cs

示例6: markPlayerLayer

	void markPlayerLayer(GameModel game, RectTransform gameCanvas) {
		if (!game.ended) {
			// get components
			Image[] images = gameCanvas.GetComponentsInChildren<Image> ();
			Image challengerLayer = images[1];
			Image challengedLayer = images[2];
			// activate
			if (game.thisTurn == game.players.challenger.username) {
				challengerLayer.enabled = true;
				challengedLayer.enabled = false;
			} 
			else {
				challengedLayer.enabled = true;
				challengerLayer.enabled = false;
			}
		}
	}
開發者ID:mengtest,項目名稱:movieschallenge_client,代碼行數:17,代碼來源:GamesLoader.cs

示例7: setPlayersCategories

	void setPlayersCategories(GameModel game, RectTransform gameCanvas) {
		PlayerLeftCategoryProgressScript[] leftCategoriesProgress;
		PlayerRightCategoryProgressScript[] rightCategoriesProgress;
		// update categories progress
		leftCategoriesProgress = gameCanvas.GetComponentsInChildren<PlayerLeftCategoryProgressScript>();
		foreach (PlayerLeftCategoryProgressScript categoryProgress in leftCategoriesProgress) {
			categoryProgress.updateCategory(game.players.challenger.categoriesProgress);
		}
		rightCategoriesProgress = gameCanvas.GetComponentsInChildren<PlayerRightCategoryProgressScript>();
		foreach (PlayerRightCategoryProgressScript categoryProgress in rightCategoriesProgress) {
			categoryProgress.updateCategory(game.players.challenged.categoriesProgress);
		}
	}
開發者ID:mengtest,項目名稱:movieschallenge_client,代碼行數:13,代碼來源:GamesLoader.cs

示例8: SetMassAlpha

 void SetMassAlpha(RectTransform root, float alpha)
 {
     foreach(var graphic in root.GetComponentsInChildren<CanvasRenderer>()){
         graphic.SetAlpha(alpha);
     }
 }
開發者ID:nemish,項目名稱:cubematters,代碼行數:6,代碼來源:DialogueUGUI.cs

示例9: ScaleSizeGivenExpectedWidth

    private void ScaleSizeGivenExpectedWidth(RectTransform rect, int width)
    {
        float currentWidth = Mathf.Abs( rect.rect.xMax - rect.rect.xMin );
        float currentHeight = Mathf.Abs( rect.rect.yMax - rect.rect.yMin );
        float scaleBy = width / currentWidth;

        rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);
        rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (int)(currentHeight*scaleBy));

        Text[] allText = rect.GetComponentsInChildren<Text>(true);
        foreach(Text text in allText)
        {
            text.fontSize = (int)(text.fontSize * scaleBy);
        }
    }
開發者ID:tng2903,項目名稱:game1,代碼行數:15,代碼來源:RenderMana.cs


注:本文中的UnityEngine.RectTransform.GetComponentsInChildren方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。