コード例 #1
1
ファイル: RenderScore.cs プロジェクト: tng2903/game1
    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);
    }
コード例 #2
0
		void Start () {
			carouselToggler = gameObject.GetComponent<CarouselToggler> ();
			ScrollRect scrollRect = gameObject.GetComponent<ScrollRect> ();
			content = scrollRect.content;
			Toggle[] toggles = content.GetComponentsInChildren<Toggle> ();
			lastToggle = toggles [0];
			StartCoroutine (WaitInactiveCycleAndReset());
		}
コード例 #3
0
 // 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;
 }
コード例 #4
0
    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;
    }
コード例 #5
0
    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	;
        }
    }
コード例 #6
0
	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;
			}
		}
	}
コード例 #7
0
	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);
		}
	}
コード例 #8
0
ファイル: DialogueUGUI.cs プロジェクト: nemish/cubematters
 void SetMassAlpha(RectTransform root, float alpha)
 {
     foreach(var graphic in root.GetComponentsInChildren<CanvasRenderer>()){
         graphic.SetAlpha(alpha);
     }
 }
コード例 #9
-1
ファイル: RenderMana.cs プロジェクト: tng2903/game1
    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);
        }
    }