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


C# RectTransform.GetComponentInChildren方法代码示例

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


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

示例1: ResizeButton

	private void ResizeButton (RectTransform _rect)
	{
		float screenX = 800;
		float screenY = 480;
		
		float rectWidth = (_rect.sizeDelta.x / screenX) * Screen.width;
		float rectHeight = (_rect.sizeDelta.y / screenY) * Screen.height;
		_rect.sizeDelta = new Vector2 (rectWidth, rectHeight);
		
		float rectX = (_rect.anchoredPosition.x / screenX) * Screen.width;
		float rectY = (_rect.anchoredPosition.y / screenY) * Screen.height;
		_rect.anchoredPosition = new Vector2 (rectX, rectY);
		
		int size = _rect.GetComponentInChildren<Text> ().fontSize;
		_rect.GetComponentInChildren<Text> ().fontSize = (int)(size * (Screen.width / screenX));
	}
开发者ID:calvinwo,项目名称:missile,代码行数:16,代码来源:GameInfo.cs

示例2: Summon

 //summon activates whenever a card is played. All spells (at least for now) target a specific tile.
 public override Transform Summon(RectTransform location, Transform hand)
 {
     if (location.GetComponent<Tile_Component>().unit != null)
         location.GetComponentInChildren<BaseUnit_Component>().TakeDamage(5);
     else
     {
         hand.GetComponent<ResourceManager>().AddResources(cost);
         hand.GetComponent<Hand_Component>().AddCard(0003);
     }
     return transform;
 }
开发者ID:GOTFCodingTeam,项目名称:GOTF2.0,代码行数:12,代码来源:BaseSpell_Component.cs

示例3: Start

    void Start()
    {
        healthBarCanvas = GameObject.Find("Health Bar Canvas").transform;
        hpSource = this.GetComponent<IHealth>();

        _healthBarInstance = GameObject.Instantiate(healthBarPrefab);
        _healthBarInstance.SetParent(healthBarCanvas, false);
        healthBarSlider = _healthBarInstance.GetComponentInChildren<Slider>();

        healthBarPos = this.transform.position;
        healthBarPos.y += healthBarHeight;
        _healthBarInstance.anchoredPosition = Camera.main.WorldToScreenPoint(healthBarPos);
    }
开发者ID:sylistine,项目名称:Clone,代码行数:13,代码来源:HealthBar.cs

示例4: Awake

        void Awake()
        {
            m_TextMeshPro = gameObject.GetComponent<TextMeshProUGUI>();


            m_Canvas = gameObject.GetComponentInParent<Canvas>();

            // Get a reference to the camera if Canvas Render Mode is not ScreenSpace Overlay.
            if (m_Canvas.renderMode == RenderMode.ScreenSpaceOverlay)
                m_Camera = null;
            else
                m_Camera = m_Canvas.worldCamera;

            // Create pop-up text object which is used to show the link information.
            m_TextPopup_RectTransform = Instantiate(TextPopup_Prefab_01) as RectTransform;
            m_TextPopup_RectTransform.SetParent(m_Canvas.transform, false);
            m_TextPopup_TMPComponent = m_TextPopup_RectTransform.GetComponentInChildren<TextMeshProUGUI>();
            m_TextPopup_RectTransform.gameObject.SetActive(false);
        }
开发者ID:Reticulatas,项目名称:Embargo,代码行数:19,代码来源:TMP_TextSelector.cs

示例5: Start

    void Start()
    {
        currentStep = PlayerHistoryStep.HELLCIRCLE;
        HistorySelection = GetComponent<Canvas> ();
        HistoChoiceDescription = HistorySelection.GetComponentInChildren<RectTransform> ();
        ChoiceDisplay = HistoChoiceDescription.GetComponentInChildren<GridLayoutGroup> ();

        for (int i=0; i<9; i++) {
            Choice [i] = ChoiceDisplay.GetComponentsInChildren<Button> () [i];
        }
        for (int i=0; i<10; i++) {
            HistoryChoiceDisplay [i] = HistorySelection.GetComponentInChildren<Mask> ().GetComponentsInChildren<Text> () [i];
        }
        for (int i=0; i<9; i++) {
            HistoryChoiceImage [i] = HistorySelection.GetComponentInChildren<Mask> ().GetComponentsInChildren<Image> () [i + 1];
        }

        GetHistoryUIButtons ();

        HistorySelection.enabled = false;
    }
开发者ID:Rgallouet,项目名称:Blue-Star,代码行数:21,代码来源:HistorySelectionButtons.cs

示例6: LoadCoroutine

    private IEnumerator LoadCoroutine()
    {
        int i = 0;
        foreach (FileInfo f in info)
        {
            item = Instantiate(prefab) as RectTransform;
            item.SetParent(transform, false);
            Text titleText = item.GetComponentInChildren<Text>();
            titleText.text = f.Name.Substring(0, f.Name.Length - 5);

            item.gameObject.GetComponent<LoadButtonParam>().Number = i++;
            _loadButtonParam = item.gameObject.GetComponent<LoadButtonParam>();

            string folderPath = "";
            try
            {

                if (Application.platform != RuntimePlatform.WindowsEditor)
                {
                    folderPath = Application.persistentDataPath + "/" + titleText.text + ".png";
                }
                else if(Application.platform == RuntimePlatform.OSXEditor)
                {
                    folderPath = Application.dataPath + "/../" + titleText.text + ".png";
                }else
                {
                    folderPath = Application.dataPath + "/../" + titleText.text + ".png";
                }
                byte[] by = File.ReadAllBytes(folderPath);

                Texture2D tex = new Texture2D(0, 0);
                tex.LoadImage(by);

                GameObject sun = item.transform.FindChild("ScreenShot").gameObject;
                Image image = sun.GetComponent<Image>();
                image.sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height),Vector2.zero);
            }
            catch (Exception e)
            {
                print(e.Message);
            }

            yield return null;
        }
    }
开发者ID:maskedzx,项目名称:AinuMonyouApp,代码行数:45,代码来源:ScrollController.cs

示例7: UpdateSubroutineButtonText

 private void UpdateSubroutineButtonText(RectTransform r, string compositeName)
 {
     r.GetComponentInChildren<Text>().text = compositeName;
 }
开发者ID:HarmonicOrder,项目名称:WarpedDrive,代码行数:4,代码来源:SubroutineWorkstation.cs

示例8: setPlayersNames

	void setPlayersNames(GameModel game, RectTransform gameCanvas) {
		PlayerLeftNameScript playerLeftName;
		PlayerRightNameScript playerRightName;
		// set players names
		playerLeftName = gameCanvas.GetComponentInChildren<PlayerLeftNameScript>();
		if (playerLeftName != null) {
			playerLeftName.setName(game.players.challenger.username);
		}
		playerRightName = gameCanvas.GetComponentInChildren<PlayerRightNameScript>();
		if (playerRightName != null) {
			playerRightName.setName(game.players.challenged.username);
		}
	}
开发者ID:mengtest,项目名称:movieschallenge_client,代码行数:13,代码来源:GamesLoader.cs

示例9: setTurn

	void setTurn(GameModel game, RectTransform gameCanvas) {
		GameTurnUpdateScript turnDisplay;
		// set players names
		turnDisplay = gameCanvas.GetComponentInChildren<GameTurnUpdateScript>();
		turnDisplay.setTurn (game.turn);
	}
开发者ID:mengtest,项目名称:movieschallenge_client,代码行数:6,代码来源:GamesLoader.cs

示例10: setPayload

	void setPayload(GameModel game, RectTransform gameCanvas) {
		GamePayloadScript gamePayload;
		// set players names
		gamePayload = gameCanvas.GetComponentInChildren<GamePayloadScript>();
		gamePayload.gameId = game._id;
	}
开发者ID:mengtest,项目名称:movieschallenge_client,代码行数:6,代码来源:GamesLoader.cs

示例11: Awake

 void Awake() {
     _textField = GetComponent<Text>();
     _windowTransform = GameObject.FindGameObjectWithTag("ConsoleWindow").GetComponent<RectTransform>();
     _scrollbar = _windowTransform.GetComponentInChildren<Scrollbar>();
 }
开发者ID:BrianErikson,项目名称:ScriptingTheGame,代码行数:5,代码来源:ResizeConsole.cs

示例12: AddButton

 private void AddButton(Action onClick, RectTransform buttonInst)
 {
     var image = buttonInst.GetComponentInChildren<Image>();
     image.gameObject.SetActive(false);
     Buttons.Add(new ButtonData()
     {
         Trans = (RectTransform)buttonInst.transform,
         HightlighEffect = image,
         OnClick = onClick,
     });
 }
开发者ID:Fawcan,项目名称:GameJamVR,代码行数:11,代码来源:ControllerFaceMenu.cs

示例13: Start

    void Start()
    {
        PreDefinedSelection = GetComponent<Canvas> ();

        data.Load(CSVSource);

        HistoChoiceDescription = PreDefinedSelection.GetComponentInChildren<RectTransform> ();
        ChoiceDisplay = HistoChoiceDescription.GetComponentInChildren<GridLayoutGroup> ();

        for (int i=0; i<9; i++) {
            Choice [i] = ChoiceDisplay.GetComponentsInChildren<Button> () [i];
        }

        for (int i=0; i<9; i++) {
            HistoryChoiceImage [i] = PreDefinedSelection.GetComponentInChildren<Mask> ().GetComponentsInChildren<Image> () [i + 1];
        }

        for (int i = 0; i < 9; i++)

        GetPreDefinedUIButtons ();
        PreDefinedSelection.enabled = false;
    }
开发者ID:Rgallouet,项目名称:Blue-Star,代码行数:22,代码来源:PreDefinedSelectionButtons.cs

示例14: Update

        private void Update()
        {
            if (m_LastEnabled != m_Interactable)
            {
                m_LastEnabled = m_Interactable;

                if (canvasGroup != null)
                {

                    if (m_LastEnabled)
                    {
                        canvasGroup.blocksRaycasts = true;
                        canvasGroup.alpha = 1f;

						if (m_DisabledPanel != null)
                        {
                            Destroy(m_DisabledPanel.gameObject);
                        }
                    }
                    else
                    {
                        canvasGroup.blocksRaycasts = false;
                        canvasGroup.alpha = 0.15f;

						if (m_ShowDisabledPanel)
						{
	                        m_DisabledPanel = PrefabManager.InstantiateGameObject(PrefabManager.ResourcePrefabs.disabledPanel, rectTransform).GetComponent<RectTransform>();
	                        m_DisabledPanel.anchoredPosition = Vector2.zero;
	                        m_DisabledPanel.sizeDelta = Vector2.zero;
	                        Color backgroundColor = tabView.GetComponent<Image>().color;
	                        m_DisabledPanel.GetComponent<Image>().color = backgroundColor;
	                        m_DisabledPanel.GetComponentInChildren<Text>().color =
	                            (backgroundColor.r + backgroundColor.g + backgroundColor.b) / 3 > 0.8f
	                                ? MaterialColor.textDark
	                                : MaterialColor.textLight;
						}
                    }
                }
            }
        }
开发者ID:adamtelfer,项目名称:idlecraft,代码行数:40,代码来源:TabPage.cs


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