當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。