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


C# RectTransform.FindChild方法代码示例

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


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

示例1: Awake

    ///////////////////////////////////////////////////////////////////////////
    //  非公開関数
    ///////////////////////////////////////////////////////////////////////////
    //初期化===================================================================
    void Awake()
    {
        //キャンバス取得
        m_Cnvs = transform.GetComponent<Canvas>();

        //ゲージ取得・初期化
        m_GaugeParent = transform.FindChild("Gauge").GetComponent<RectTransform>();
        m_GaugeGlider = m_GaugeParent.FindChild("GliderGauge/Bar").GetComponent<Image>();
        m_GaugeHeat   = m_GaugeParent.FindChild("HeatGauge/Bar"  ).GetComponent<Image>();

        //文字
        m_Goal        = transform.FindChild("Goal").GetComponent<Image>();
        m_Goal.enabled = false;
    }
开发者ID:InagakiTatuya,项目名称:NKC_GlideRace,代码行数:18,代码来源:HeadUpDisplay.cs

示例2: Init

 /// <summary>
 /// 初始化
 /// </summary>
 public void Init()
 {
     MyGameobject = gameObject;
     MyTransfrom = transform.GetComponent<RectTransform>();
     Go_Motion = MyTransfrom.FindChild("Motion").gameObject;
     MyTransfrom.FindChild("Motion").GetComponent<HitTextMotion>().Init(this);
     CanvasRect = FightSceneUI.Canvas;
     MyText = MyTransfrom.FindChild("Motion").FindChild("text").GetComponent<Text>();
     MyImage = MyTransfrom.FindChild("Motion").FindChild("image").GetComponent<Image>();
     RT_Image = MyImage.GetComponent<RectTransform>();
     Ani = MyTransfrom.FindChild("Motion").GetComponent<Animator>();
     ImagePosUp = new Vector2(0, 40);
     ImagePosCenter = new Vector2(0, 0);
     IsInit = true;
 }
开发者ID:scozirge,项目名称:AVentureCapital,代码行数:18,代码来源:HitText.cs

示例3: Start

	// Use this for initialization
	void Start () {
		//Enemy killed counter initialisation
		text = GetComponentInChildren<Text>();
		text.text = ("Enemies killed : " + enemiesKilled);
		GameObject player = GameObject.FindGameObjectWithTag("Player");
		health = player.GetComponent<HealthScript>();
		playerHealth = health.health;
		totalHealth = playerHealth;
		weapon = player.GetComponent<WeaponController>();
		skill = player.GetComponent<SkillController>();

		GameObject skills = GameObject.Find("Skills");
		//skills.gameObject.
		GameObject bullet = GameObject.Find("Bullet");
		bulletCooldownBar = bullet.GetComponentInChildren<RectTransform>();
		bulletCooldownBar = bulletCooldownBar.FindChild("Cooldown") as RectTransform;
		GameObject secondary = GameObject.Find("Secondary");
		secondaryCooldownBar = secondary.GetComponentInChildren<RectTransform>();
		secondaryCooldownBar = secondaryCooldownBar.FindChild("Cooldown") as RectTransform;
		GameObject dodge = GameObject.Find("Dodge");
		dodgeCooldownBar = dodge.GetComponentInChildren<RectTransform>();
		dodgeCooldownBar = dodgeCooldownBar.Find("Cooldown") as RectTransform;

		Image healthBarImage = GetComponentInChildren<Image>();
		healthBar = healthBarImage.gameObject.GetComponent<RectTransform>();
	}
开发者ID:NotYannis,项目名称:waterjumpers,代码行数:27,代码来源:HudScript.cs

示例4: SetChildActive

 /// <summary>
 /// 设置子节点是否可见
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="child"></param>
 /// <param name="isActive"></param>
 public static void SetChildActive(RectTransform parent, string child, bool isActive)
 {
     if (parent == null || string.IsNullOrEmpty(child))
         return;
     var childNode = parent.FindChild(child);
     if (childNode != null)
     {
         childNode.gameObject.SetActive(isActive);
     }
 }
开发者ID:yantian001,项目名称:2DShooting,代码行数:16,代码来源:CommonUtils.cs

示例5: SetChildSliderValue

 /// <summary>
 /// 设置子对象的Slider值
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="child"></param>
 /// <param name="value"></param>
 public static void SetChildSliderValue(RectTransform parent, string child, float value)
 {
     var childTran = parent.FindChild(child);
     if (childTran)
     {
         Slider slider = childTran.GetComponentInChildren<Slider>();
         if (slider)
         {
             slider.value = value;
         }
     }
 }
开发者ID:yantian001,项目名称:2DShooting,代码行数:18,代码来源:CommonUtils.cs

示例6: SetChildText

 /// <summary>
 /// 设置子节点的文本值
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="child"></param>
 /// <param name="text"></param>
 public static void SetChildText(RectTransform parent, string child, string text)
 {
     var childNode = parent.FindChild(child);
     if (childNode != null)
     {
         var textNode = childNode.GetComponent<Text>();
         if (textNode)
         {
             textNode.text = text;
         }
     }
 }
开发者ID:yantian001,项目名称:2DShooting,代码行数:18,代码来源:CommonUtils.cs

示例7: Init

 public void Init()
 {
     if (IsInit)
         return;
     Canvas = transform.GetComponent<RectTransform>();
     //腳色介面
     MyCharaDataUI = Canvas.FindChild("CharaData").GetComponent<CharaDataUI>();
     MyCharaDataUI.Init();//初始化
     //跳血文字控制器
     MyHitTextController = Canvas.FindChild("HitTextController").GetComponent<HitTextController>();
     MyHitTextController.Init();
     //標題控制器
     TitleController = Canvas.FindChild("FightTitle").GetComponent<FightTitleController>();
     TitleController.Init();
     //冒險進度
     MyProgress = Canvas.FindChild("Progress").GetComponent<Progress>();
     MyProgress.Init();
     //事件
     MyEventUI = Canvas.FindChild("Event").GetComponent<EventUI>();
     MyEventUI.Init();
     IsInit = true;
 }
开发者ID:scozirge,项目名称:AVentureCapital,代码行数:22,代码来源:FightSceneUI.cs

示例8: SetChildRawImage

 /// <summary>
 /// 设置RawImage子节点的Texture2d值
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="child"></param>
 /// <param name="texture"></param>
 public static void SetChildRawImage(RectTransform parent, string child, Texture2D texture)
 {
     if (parent == null || texture == null || string.IsNullOrEmpty(child))
         return;
     var childNode = parent.FindChild(child);
     if (childNode != null)
     {
         var img = childNode.GetComponent<RawImage>();
         if (img != null)
         {
             img.texture = texture;
         }
     }
 }
开发者ID:yantian001,项目名称:2DShooting,代码行数:20,代码来源:CommonUtils.cs

示例9: Start

 public void Start()
 {
     panel = Instantiate(Resources.Load<GameObject>("Prefabs/UIPrefabs/ButtlePanel")).GetComponent<RectTransform>();
     panel.SetParent(GameObject.Find("/Canvas").transform);
     panel.sizeDelta = new Vector2();
     panel.SetSiblingIndex(0);
     panel.position = new Vector3(panel.rect.width / 2, panel.rect.height / 2, 0);
     player = GameObject.Find("/Player").GetComponent<PlayerController>();
     maxHP = player.MaxHP;
     hpbar = panel.FindChild("HPPanel/HPBar").GetComponent<Slider>();
     hptext = panel.FindChild("HPPanel/HPText").GetComponent<Text>();
     hpbar.maxValue = maxHP;
     enemyPoint = Resources.Load<GameObject>("Prefabs/UIPrefabs/EnemyPoint");
     radarPanel = panel.FindChild("RadarPanel").gameObject;
     playerPoint = panel.FindChild("RadarPanel/PlayerPoint").gameObject;
     prtf = playerPoint.GetComponent<RectTransform>();
     ptf = player.transform;
     rrtf = radarPanel.GetComponent<RectTransform>();
     marker = panel.FindChild("MarkerPanel").GetComponent<MarkerScript>();
     maincamera = GameObject.Find("/Player/Main Camera").GetComponent<Camera>();
     remainingEnemyPanel = panel.FindChild("RemainingEnemyPanel").GetComponent<RectTransform>();
     remainingEnemyNumText = remainingEnemyPanel.FindChild("Text").GetComponent<Text>();
     remainingEnemyPanel.localScale = Vector3.zero;
     timeLimitPanel = panel.FindChild("TimeLimitPanel").GetComponent<RectTransform>();
     timeLimitText = timeLimitPanel.FindChild("Text").GetComponent<Text>();
     timeLimitPanel.localScale = Vector3.zero;
 }
开发者ID:spi8823,项目名称:Sudenona,代码行数:27,代码来源:ButtleUI.cs

示例10: Awake

        void Awake()
        {
            InputController.SetForKeyboard();
            InputController.SetGravity(5);
            InputController.SetSensitivity(5);

            InputController.SetGamePads();
            InputController.SetAcceptGravityToAnalogPad(true);

            GameStatus.Initialilze();
            rtfButtonPanel = GameObject.Find("/Canvas/ButtonPanel").GetComponent<RectTransform>();
            rtfButtons = rtfButtonPanel.FindChild("Buttons").GetComponent<RectTransform>();
            rtfExpression = rtfButtonPanel.FindChild("ButtonExpression").GetComponent<RectTransform>();
            txtExpression = rtfExpression.FindChild("Text").GetComponent<Text>();
            rtfStatus = GameObject.Find("/Canvas/StatusPanel/Statuses").GetComponent<RectTransform>();
            expressionAnimator = rtfExpression.GetComponent<Animator>();
            eventSystem = GameObject.Find("/EventSystem").GetComponent<EventSystem>();

            buttonList = new List<Button>();
            buttonList.Add(rtfButtons.FindChild("BattleButton").GetComponent<Button>());
            buttonList.Add(rtfButtons.FindChild("PartsButton").GetComponent<Button>());
            buttonList.Add(rtfButtons.FindChild("AIButton").GetComponent<Button>());
            buttonList.Add(rtfButtons.FindChild("SettingButton").GetComponent<Button>());
            buttonList.Add(rtfButtons.FindChild("RecordButton").GetComponent<Button>());
            buttonList.Add(rtfButtons.FindChild("ExitButton").GetComponent<Button>());

            int x = 1;
            int y = x++ + ++x;
            Debug.Log(y);
        }
开发者ID:spi8823,项目名称:Sudenona,代码行数:30,代码来源:HomeUI.cs

示例11: Awake

        public void Awake()
        {
            #region 参照登録

            UICanvas = GameObject.Find("/UICanvas").GetComponent<RectTransform>();
            StageSelectPanel = UICanvas.FindChild("StageSelectPanel").GetComponent<RectTransform>();
            StageDiscriptionPanel = StageSelectPanel.FindChild("StageDiscriptionPanel").GetComponent<RectTransform>();
            StageListPanel = StageSelectPanel.FindChild("StageListPanel").GetComponent<RectTransform>();
            StageButtonsPanel = StageListPanel.FindChild("Stages").GetComponent<RectTransform>();
            DifficultyStarsPanel = StageDiscriptionPanel.FindChild("DifficultyStarsPanel").GetComponent<RectTransform>();

            PartsSelectPanel = UICanvas.FindChild("PartsSelectPanel").GetComponent<RectTransform>();
            PartsDiscriptionPanel = PartsSelectPanel.FindChild("PartsDiscriptionPanel").GetComponent<RectTransform>();
            PartsListPanel = PartsSelectPanel.FindChild("PartsListPanel").GetComponent<RectTransform>();
            PartsButtonsPanel = PartsListPanel.FindChild("PartsButtonsPanel").GetComponent<RectTransform>();
            PartsNameText = PartsDiscriptionPanel.FindChild("PartsNameText").GetComponent<RectTransform>();
            PartsLevelText = PartsDiscriptionPanel.FindChild("LevelText").GetComponent<RectTransform>();
            PartsBulletNumText = PartsDiscriptionPanel.FindChild("BulletNumText").GetComponent<RectTransform>();
            PartsDamageText = PartsDiscriptionPanel.FindChild("DamageText").GetComponent<RectTransform>();
            PartsCoolTimeText = PartsDiscriptionPanel.FindChild("CoolTimeText").GetComponent<RectTransform>();
            PartsDiscriptionField = PartsDiscriptionPanel.FindChild("DiscriptionField").GetComponent<RectTransform>();

            eventData = new PointerEventData(GameObject.Find("EventSystem").GetComponent<EventSystem>());

            DifficultyStarPrefab = Resources.Load<GameObject>("Prefabs/UIPrefabs/DifficultyStar");
            #endregion

            ListUpStage();

            DiscriptStage(UnLockedStageList[0]);
        }
开发者ID:spi8823,项目名称:Sudenona,代码行数:31,代码来源:PrepareForStageUI.cs

示例12: Stock

        public Stock(RectTransform template, string parentName, Itemsss item)
        {
            this.itemPanel = Instantiate<RectTransform>(template);
            itemPanel.SetParent(GameObject.Find(parentName).transform);
            itemPanel.localScale = Vector3.one;

            this.item = item;

            this.iconDisplay = itemPanel.FindChild("Icon").GetComponent<Image>();
            this.nameDisplay = itemPanel.FindChild("Name").GetComponent<Text>();
            this.valueDisplay = itemPanel.FindChild("Value").GetComponent<Text>();

            this.nameDisplay.text = item.obj.name;
            this.valueDisplay.text = item.value.ToString();
        }
开发者ID:ofx360,项目名称:rpg-project,代码行数:15,代码来源:StoreUI.cs

示例13: Awake

    void Awake()
    {
        controller = transform.parent.GetComponentInChildren<Controller>();
        purchaseManager = transform.parent.FindChild("SOOMLA").GetComponent<PurchaseManager>();
        frogPackages = GetComponentInParent<FrogPackages>();
        variableManager = GetComponentInParent<VariableManager>();
        advertisingManager = GetComponentInParent<AdvertisingManager>();
        canvas = GetComponent<RectTransform>();
        titleTransform = canvas.FindChild("Title").GetComponent<RectTransform>();

        mainMenu = canvas.FindChild("MainMenu").GetComponent<CanvasGroup>();
        frogButton = mainMenu.transform.FindChild("FrogButton").GetComponent<RectTransform>();
        settingsButton = mainMenu.transform.FindChild("SettingsButton").GetComponent<RectTransform>();

        settingsMenu = canvas.FindChild("SettingsPanel").GetComponent<CanvasGroup>();
        musicToggle = settingsMenu.transform.GetChild(0).FindChild("MusicToggle").GetComponent<Toggle>();

        hud = transform.FindChild("HUD").GetComponent<HUD>();
        hudCanvas = hud.GetComponent<CanvasGroup>();
        hudRect = hud.GetComponent<RectTransform>();

        qualityCountPanelCG = canvas.FindChild("QualityCountPanel").GetComponent<CanvasGroup>();
        qualityCountPanel = qualityCountPanelCG.GetComponent<RectTransform>();
        perfectCount = qualityCountPanel.FindChild("PerfectCount").GetComponent<TextMeshProUGUI>();
        greatCount = qualityCountPanel.FindChild("GreatCount").GetComponent<TextMeshProUGUI>();;
        okCount = qualityCountPanel.FindChild("OKCount").GetComponent<TextMeshProUGUI>();;

        flyIconPosition = new Vector2(screenWidth, 50);
        flyButton = canvas.FindChild ("FlyPanel").GetComponent<Button>();
        flyPanelCG = flyButton.GetComponent<CanvasGroup>();
        flyTextAnimator = flyButton.transform.FindChild("FlyCount").GetComponent<Animator>();
        flyCount = flyButton.transform.FindChild("FlyCount").GetComponent<TextMeshProUGUI>();
        flyToGoText = flyButton.transform.FindChild("ToGoText").GetComponent<TextMeshProUGUI>();
        tameFlyNet = Instantiate(tameFlyNetPrefab, flyIconPosition, Quaternion.identity) as GameObject;

        arrowPanelCG = canvas.FindChild("ArrowPanel").GetComponent<CanvasGroup>();
        arrowPanel = arrowPanelCG.GetComponent<RectTransform>();
        frogName = arrowPanel.FindChild("FrogName").GetComponent<TextMeshProUGUI>();
        arrowPanelBuyButton = arrowPanel.FindChild("BuyButton").gameObject;

        returnPanel = canvas.FindChild("ReturnPanel").GetComponent<CanvasGroup>();
        returnButton = returnPanel.transform.FindChild("ReturnButton").GetComponent<RectTransform>();

        Transform endGameTransform = canvas.FindChild("EndGamePanel");
        endGamePanel = endGameTransform.GetComponent<CanvasGroup>();
        giftButton = endGameTransform.FindChild("GiftsButton").gameObject;
        adButton = endGameTransform.FindChild("AdsButton").gameObject;

        timeUntilGiftText = endGameTransform.FindChild("TimeUntilGift").GetComponent<TextMeshProUGUI>();

        buyButtonObject = endGameTransform.FindChild("BuyButton").gameObject;
        buyButton = buyButtonObject.GetComponent<Button>();
        buyButtonText = buyButton.transform.FindChild("Text").GetComponent<TextMeshProUGUI>();
        buyButtonImage = buyButton.transform.FindChild("Image").GetComponent<Image>();
    }
开发者ID:VCRhythm,项目名称:hotfrog,代码行数:55,代码来源:MenuManager.cs

示例14: InitView

        public override void InitView()
        {
            if (isInited)
            {
                return;
            }
            isInited = true;

            Transform MainLayout0 = transform.parent.FindChild("MainLayout");
            mainLayout = MainLayout0 as RectTransform;
            Transform MainContainer00 = MainLayout0.FindChild("MainContainer");
            mainContainer = MainContainer00 as RectTransform;

            sideBarLayout = transform as RectTransform;
            Transform SideBarContainer10 = sideBarLayout.FindChild("SideBarContainer");
            sideBarContainer = SideBarContainer10 as RectTransform;
            Transform SideBarNode100 = SideBarContainer10.FindChild("SideBarNode");
            sideBarNode = SideBarNode100 as RectTransform;
            Transform ButtonLayout101 = SideBarContainer10.FindChild("ButtonLayout");
            Transform PanelButtonLocator1010 = ButtonLayout101.FindChild("Locator");
            Transform _Button_SideBar10100 = PanelButtonLocator1010.FindChild("SideBarButton");
            sideBarButton = _Button_SideBar10100.GetComponent<Button>();
            sideBarButton.onClick.AddListener(OnButtonSideBarClicked);

            var localPosition = sideBarLayout.transform.localPosition;
            localPosition.x = localPosition.x + SideBarWidth;

            sideLayoutFixedRightPos = localPosition;
            sideLayoutFixedLeftPos = sideBarLayout.transform.localPosition;

            var horizontalLayoutElement = mainLayout.gameObject.GetComponent<HorizontalLayoutGroup>();
            if (horizontalLayoutElement == null)
            {
                horizontalLayoutElement = mainLayout.gameObject.AddComponent<HorizontalLayoutGroup>();
            }
            horizontalLayoutElement.childForceExpandWidth = false;
            horizontalLayoutElement.childForceExpandHeight = true;

            mainContainerLayoutElement = mainContainer.gameObject.GetComponent<LayoutElement>();
            if (mainContainerLayoutElement == null)
            {
                mainContainerLayoutElement = mainContainer.gameObject.AddComponent<LayoutElement>();
            }
            mainContainerLayoutElement.preferredWidth = mainLayout.rect.width;
        }
开发者ID:ideadreamDefy,项目名称:Defy,代码行数:45,代码来源:SideLayout.cs

示例15: SetChildButtonActive

    public static void SetChildButtonActive(RectTransform parent, string child, bool b)
    {
        if (parent == null || string.IsNullOrEmpty(child))
            return;

        var childNode = parent.FindChild(child);
        if (childNode)
        {
            var button = childNode.GetComponent<Button>();
            button.interactable = b;
        }

    }
开发者ID:yantian001,项目名称:2DShooting,代码行数:13,代码来源:CommonUtils.cs


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