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


C# UnityEngine.RectTransform類代碼示例

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


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

示例1: Awake

        void Awake()
        {
            _resizedPanel = (ResizeParent ? transform.parent : transform) as RectTransform;

            var maximalSizeMargin = 10;
            _maximalSize = new Vector2(Screen.width - maximalSizeMargin, Screen.height - maximalSizeMargin);
        }
開發者ID:Youenn-Bouglouan,項目名稱:Water,代碼行數:7,代碼來源:Resizer.cs

示例2: State

				public State(RectTransform rect) {

					this.anchorMin = rect.anchorMin;
					this.anchorMax = rect.anchorMax;
					this.to = rect.anchoredPosition;

				}
開發者ID:RuFengLau,項目名稱:Unity3d.UI.Windows,代碼行數:7,代碼來源:WindowAnimationTransitionSlide.cs

示例3: Start

    // Use this for initialization
    void Start()
    {
        timescaleButtonImage = GameObject.Find("Timescale Button").GetComponent<Image>();
        buttonTargetColor = Color.white;
        timescaleInfoTransform = transform.GetComponent<RectTransform>();

        hiddenPos = timescaleInfoTransform.position;
        visiblePos = timescaleInfoTransform.position + new Vector3(340,0,0);
        timescaleInfoTransform.position = hiddenPos;

        activeColor = Color.white;
        inactiveColor = new Color(1,1,1,0.1f);

        nextUpgradeColorVisible 	= new Color(0,1,0,1);
        nextUpgradeColorTransparent = new Color(0,1,0,0.05f);

        timescaleImages = new RawImage[9];
        timescaleImages[0] = transform.Find("Current Timescale").Find("Timescale Bar").Find("1").GetComponent<RawImage>();
        timescaleImages[1] = transform.Find("Current Timescale").Find("Timescale Bar").Find("2").GetComponent<RawImage>();
        timescaleImages[2] = transform.Find("Current Timescale").Find("Timescale Bar").Find("3").GetComponent<RawImage>();
        timescaleImages[3] = transform.Find("Current Timescale").Find("Timescale Bar").Find("4").GetComponent<RawImage>();
        timescaleImages[4] = transform.Find("Current Timescale").Find("Timescale Bar").Find("5").GetComponent<RawImage>();
        timescaleImages[5] = transform.Find("Current Timescale").Find("Timescale Bar").Find("6").GetComponent<RawImage>();
        timescaleImages[6] = transform.Find("Current Timescale").Find("Timescale Bar").Find("7").GetComponent<RawImage>();
        timescaleImages[7] = transform.Find("Current Timescale").Find("Timescale Bar").Find("8").GetComponent<RawImage>();
        timescaleImages[8] = transform.Find("Current Timescale").Find("Timescale Bar").Find("9").GetComponent<RawImage>();

        ClearTimescale();
    }
開發者ID:redahanb,項目名稱:Spectral,代碼行數:30,代碼來源:UpgradeReactionTime.cs

示例4: CalculateAnchorSnapValues

 internal static void CalculateAnchorSnapValues(Transform parentSpace, Transform self, RectTransform gui, int minmaxX, int minmaxY)
 {
   for (int mainAxis = 0; mainAxis < 2; ++mainAxis)
   {
     RectTransformSnapping.s_SnapGuides[mainAxis].Clear();
     parentSpace.GetComponent<RectTransform>().GetWorldCorners(RectTransformSnapping.s_Corners);
     for (int index = 0; index < RectTransformSnapping.kSidesAndMiddle.Length; ++index)
     {
       float alongMainAxis = RectTransformSnapping.kSidesAndMiddle[index];
       RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(alongMainAxis, new Vector3[2]
       {
         RectTransformSnapping.GetInterpolatedCorner(RectTransformSnapping.s_Corners, mainAxis, alongMainAxis, 0.0f),
         RectTransformSnapping.GetInterpolatedCorner(RectTransformSnapping.s_Corners, mainAxis, alongMainAxis, 1f)
       }));
     }
     foreach (Transform transform in parentSpace)
     {
       if (!((Object) transform == (Object) self))
       {
         RectTransform component = transform.GetComponent<RectTransform>();
         if ((bool) ((Object) component))
         {
           RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(component.anchorMin[mainAxis], new Vector3[0]));
           RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(component.anchorMax[mainAxis], new Vector3[0]));
         }
       }
     }
     int num = mainAxis != 0 ? minmaxY : minmaxX;
     if (num == 0)
       RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(gui.anchorMax[mainAxis], new Vector3[0]));
     if (num == 1)
       RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(gui.anchorMin[mainAxis], new Vector3[0]));
   }
 }
開發者ID:BlakeTriana,項目名稱:unity-decompiled,代碼行數:34,代碼來源:RectTransformSnapping.cs

示例5: Add

    public bool Add(RectTransform child, bool forceAdd = false)
    {
        bool canAdd = child.rect.width <= AvailableWidth;

        if (!canAdd && !forceAdd)
        {
            return false;
        }

        UpdateHeightForChild(child);

        if (canAdd)
        {
            child.SetParent(transform, false);
            child.SetAsLastSibling();

            CurrentWidth += child.rect.width;
        }
        else
        {
            GameObject containerObject = new GameObject("LineForceContainer");
            RectTransform containerTransformRect = containerObject.AddComponent<RectTransform>();
            containerTransformRect.SetParent(transform, false);
            containerTransformRect.SetAsLastSibling();

            LayoutElement containerLayoutElement = containerObject.AddComponent<LayoutElement>();
            containerLayoutElement.preferredWidth = AvailableWidth;
            containerLayoutElement.preferredHeight = child.rect.height;

            CurrentWidth += containerLayoutElement.preferredWidth;
        }
        return true;
    }
開發者ID:ideadreamDefy,項目名稱:Defy,代碼行數:33,代碼來源:RichEditLine.cs

示例6: UpdatePosition

    public void UpdatePosition(RectTransform goToObject)
    {
        if (goToObject == null) return;

        gotoX = goToObject.rect.xMin - (goToObject.rect.width / 2);
        gotoY = goToObject.position.y + 0.2f;
    }
開發者ID:Midimistro,項目名稱:Deadmen,代碼行數:7,代碼來源:UI_Cursor.cs

示例7: Start

//--------------------------------------------------------------------------------------------

	void Start ()
	{
		// get handle on player script
		playerScript = GetComponent<Player> ();
		if(playerScript.chassisQuick) 
		{
			rechargeRate *= playerScript.cooldownBoost;
		}

		energyBar = GameObject.Find("EnergyBar").GetComponent<RectTransform>();
		origin = energyBar.localPosition;

		energySprites = Resources.LoadAll<Sprite>("GUI_Assets/EnergyIcons");
		energyImg = GameObject.Find("EnergyImg").GetComponent<Image>();
		blinkCoroutine = null;

		//init emp area prefab
		empAreaPrefab = Resources.Load<GameObject>("PlayerBullets/EMPArea");

		currEnergy = maxEnergy;
		isOnCooldown = false;

		//get handle on audio source for secondary ready
		readyAudio = GetComponents<AudioSource>()[1];
	}
開發者ID:zachary-goodless,項目名稱:Cull-the-Swarm,代碼行數:27,代碼來源:EMPManager.cs

示例8: OnBeginDrag

	public void OnBeginDrag (PointerEventData eventData)
	{
		originPos = rt.position;
		fatherRT = rt.parent.GetComponent<RectTransform>();
		cg.blocksRaycasts = false;
		isDrag = true;
	}
開發者ID:applexiaohao,項目名稱:CardGame,代碼行數:7,代碼來源:M_FoodMoveScript.cs

示例9: Start

    	void Start()
    	{
		colRectTransform = itemPrefab.GetComponent<RectTransform> ();
		containerRectTransform = gameObject.GetComponent<RectTransform> ();
		cardHeight = containerRectTransform.rect.height;
		cardWidth = colRectTransform.rect.width;
    	}
開發者ID:ShaneMcCloskey,項目名稱:GameOfLoans,代碼行數:7,代碼來源:ScrollableList.cs

示例10: Awake

	void Awake()
	{
		foodSprites = new Sprite[foodNum];
		orderedName = new string[foodNum];
		panelRT = GameObject.FindWithTag ("Panel").GetComponent<RectTransform>() ;
		cells = new GameObject[foodNum];
	}
開發者ID:applexiaohao,項目名稱:CardGame,代碼行數:7,代碼來源:M_ManagerScript.cs

示例11: Start

	void Start ()
	{
		if(canvas != null){
			scaleFactor = canvas.scaleFactor;
		}
		rect_transform = GetComponent<RectTransform>();
	}
開發者ID:PlayFab,項目名稱:PlayFabGameServer,代碼行數:7,代碼來源:PUIResizableWindow.cs

示例12: Start

 void Start()
 {
     tran = GetComponent <RectTransform> ();
     sizelength = Mathf.Min (tran.rect.width, tran.rect.height);
     Init ();
     print (tran.rect);
 }
開發者ID:wey521520,項目名稱:NewMGC,代碼行數:7,代碼來源:KeyBoard.cs

示例13: Awake

    void Awake()
    {
        timeLastEnemyHitted = Time.time;
        trigger = GetComponentInChildren<BoxCollider>();
        sprite = transform.GetComponentInChildren<SpriteRenderer>();

        glitchPartPool = new ObjectPool(glitchPart);
        lives = 3;
        items = 0;

        //Instantiate the glitch fragments to avoid lag later in the game
        GameObject[] parts = new GameObject[100];
        for (int i = 0; i < 100; i++)
        {
            parts[i] = glitchPartPool.getObject();
        }
        for (int i = 0; i < 100; i++)
        {
            parts[i].SetActive(false);
        }

        boxUIActivatedRectTransform = boxUIActivated.GetComponent<RectTransform>();
        exclamationSize = boxUIActivatedRectTransform.sizeDelta;
        boxUIActivated.SetActive(false);
        guiRectTrans = gui.GetComponent<RectTransform>();
        slowFPSScript = transform.FindChild("Powers").GetComponentInChildren<SlowFPS>();
    }
開發者ID:TeamGlitch,項目名稱:Glitch,代碼行數:27,代碼來源:Player.cs

示例14: Start

    // Use this for initialization
    void Start()
    {
        Invoke("ShowContinueText", 5);

        startTime = Time.realtimeSinceStartup;

        tScaler = GameObject.Find("Time Manager").GetComponent<TimeScaler>();

        boxTransform 			= GetComponent<RectTransform>();
        backgroundTransform 	= transform.parent.GetComponent<RectTransform>();
        gradientTransform 		= transform.Find("Background Gradient").GetComponent<RectTransform>();
        topBorder			 	= transform.Find("Top Border").GetComponent<RectTransform>();
        bottomBorder 			= transform.Find("Bottom Border").GetComponent<RectTransform>();

        boxImage 				= GetComponent<RawImage>();
        backgroundImage 		= transform.parent.GetComponent<RawImage>();
        gradientImage 			= transform.Find("Background Gradient").GetComponent<RawImage>();
        topImage			 	= transform.Find("Top Border").GetComponent<RawImage>();
        bottomImage 			= transform.Find("Bottom Border").GetComponent<RawImage>();
        iconImage				= transform.Find("Info Icon").GetComponent<RawImage>();

        tutorialText			= transform.Find("Tutorial Text").GetComponent<Text>();
        continueText			= transform.Find("Continue Text").GetComponent<Text>();

        SetStartingColors();

        i = 0;
    }
開發者ID:redahanb,項目名稱:Spectral,代碼行數:29,代碼來源:TutorialBox.cs

示例15: SetRectAsFullScreen

 public static void SetRectAsFullScreen(ref RectTransform targetTrans)
 {
     targetTrans.anchorMin = Vector2.zero;
     targetTrans.anchorMax = Vector2.one;
     targetTrans.offsetMin = Vector2.zero;
     targetTrans.offsetMax = Vector2.zero;
 }
開發者ID:IriskaDev,項目名稱:BasicUnityProj,代碼行數:7,代碼來源:UIUtils.cs


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