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


C# RectTransform.GetChild方法代码示例

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


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

示例1: Start

    private void Start()
    {
        m_Transition = GetComponent<ShowAndHidePanel>();
        m_AudioSource = GetComponent<AudioSource>();
        m_CanvasGroup = GetComponent<CanvasGroup>();
        m_CanvasGroup.alpha = 0;

        m_FaderPanel = transform.GetChild(0).GetComponent<RectTransform>();
        m_UserPanel = transform.GetChild(1).GetComponent<RectTransform>();

        m_NameInputValue = m_UserPanel.GetChild(1).GetChild(0).GetComponent<InputField>();
        m_EmailInputValue = m_UserPanel.GetChild(1).GetChild(1).GetComponent<InputField>();
        m_PasswordInputValue = m_UserPanel.GetChild(1).GetChild(2).GetComponent<InputField>();

        m_CancelButton = m_UserPanel.GetChild(2).GetComponent<Button>();
        m_CancelButton.onClick.RemoveAllListeners();
        m_CancelButton.onClick.AddListener(delegate { Cancel(); });

        m_RegisterButton = m_UserPanel.GetChild(3).GetComponent<Button>();
        m_RegisterButton.onClick.RemoveAllListeners();
        m_RegisterButton.onClick.AddListener(delegate { Register(); });

        m_FaderPanel.gameObject.SetActive(false);
        m_UserPanel.gameObject.SetActive(false);
    }
开发者ID:kleberandrade,项目名称:more-rehab-system,代码行数:25,代码来源:RegisterUser.cs

示例2: FlipLayoutAxes

 /// <summary>
 /// <para>Flips the horizontal and vertical axes of the RectTransform size and alignment, and optionally its children as well.</para>
 /// </summary>
 /// <param name="rect">The RectTransform to flip.</param>
 /// <param name="keepPositioning">Flips around the pivot if true. Flips within the parent rect if false.</param>
 /// <param name="recursive">Flip the children as well?</param>
 public static void FlipLayoutAxes(RectTransform rect, bool keepPositioning, bool recursive)
 {
     if (rect != null)
     {
         if (recursive)
         {
             for (int i = 0; i < rect.childCount; i++)
             {
                 RectTransform child = rect.GetChild(i) as RectTransform;
                 if (child != null)
                 {
                     FlipLayoutAxes(child, false, true);
                 }
             }
         }
         rect.pivot = GetTransposed(rect.pivot);
         rect.sizeDelta = GetTransposed(rect.sizeDelta);
         if (!keepPositioning)
         {
             rect.anchoredPosition = GetTransposed(rect.anchoredPosition);
             rect.anchorMin = GetTransposed(rect.anchorMin);
             rect.anchorMax = GetTransposed(rect.anchorMax);
         }
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:31,代码来源:RectTransformUtility.cs

示例3: Start

    void Start()
    {
        PlayerMovment playermovment = player.GetComponent<PlayerMovment>();

        Vector3 trans = this.transform.position;
        CameraStartPosition = Camera.main.transform.position;
        CameraStartRotation = Camera.main.transform.rotation;
        CameraTargetPosition = new Vector3(trans.x, trans.y + playermovment.p_CamZoomYFromPlayer, trans.z);
        CameraTargetRotation = Quaternion.Euler(new Vector3(90,0,0));    
        canvas = Instantiate(StartCanvas, StartCanvas.position, StartCanvas.rotation) as RectTransform;
        title = canvas.GetChild(0).GetComponent<Text>();
        title.text = LevelName;
        paragraph = canvas.GetChild(1).GetComponent<Text>();
        paragraph.text = "";
        //subscribe to events
        ResourceManager.playerFound += GameOver;
        ResourceManager.playerClearedLevel += LevelClear;

        StartCoroutine(TextType(trans)); //text type triggers LerpCamera, LerpCamera spawns player when complete
    }
开发者ID:ConnorPoulton,项目名称:Millbrook_VGdesign_2016,代码行数:20,代码来源:PlayerStart.cs

示例4: Populate

		protected void Populate(RectTransform container, GameObject prefab, int count)
		{
			if (container.childCount < count)
			{
				int nbToCreate = count - container.childCount;
				Transform tr;
				for (int i = 0; i < nbToCreate; ++i)
				{
					tr = Instantiate(prefab).transform;
					tr.SetParent(container);
					tr.SetAsLastSibling();
				}
			}
			else if (container.childCount > count)
			{
				int nbToDelete = container.childCount - count;
				for (int i = 0; i < nbToDelete; ++i)
				{
					DestroyImmediate(container.GetChild(0).gameObject);
				}
			}
		}
开发者ID:ttesla,项目名称:gj-unity-api,代码行数:22,代码来源:BaseWindow.cs

示例5: Start

    void Start()
    {
        modalWindowSCR = GameObject.FindGameObjectWithTag("ModalWindowManager").GetComponent<ModalWindowManager>();
        tooltipParent = GameObject.FindGameObjectWithTag ("ItemTooltipPanel").GetComponent<RectTransform> ();
        tooltip = tooltipParent.GetChild (0).GetComponent<RectTransform>();
        for (int i = 0; i < 8; i++)
        {
            shopInventory.Add(databaseSCR.GetItem(0));
        }
        for (int i = 0; i < 8; i++)
        {

            shopInventoryStacks.Add(0);

        }
        addItemResult = AddItem(3, 1);
        addItemResult = AddItem(6, 1);
    }
开发者ID:NicolasBighetti,项目名称:bearded-octo-dangerzone,代码行数:18,代码来源:ShopInventory.cs

示例6: buildPopup

    //build the popup from the given list of descriptors
    //also receives the component that this popup will edit and the type of component used to find the descriptors
    public void buildPopup(GameRuleDesignComponent cr, List<GameRuleDesignComponentDescriptor> pd, System.Type describedType)
    {
        //instead of Start(), this is the place where stuff will get initialized
        //store a bunch of size information for positioning things
        RectTransform iconArea = (RectTransform)(transform.GetChild(1));
        iconAreaBottomLeft = iconArea.offsetMin;
        iconAreaTopRight = iconArea.offsetMax; //x and y are both negative for an inset corner
        iconAreaTotalBounds = iconAreaBottomLeft - iconAreaTopRight;
        iconContainer = (RectTransform)(transform.GetChild(2));
        //throw the container out to under the canvas so that it renders over the whole rule
        iconContainer.SetParent(GameRuleDesigner.instance.uiCanvas);
        RectTransform iconContainerSpacing = (RectTransform)(iconContainer.GetChild(0));
        iconContainerSpacingSize = iconContainerSpacing.sizeDelta;
        //we only needed these to get their size, we can get rid of them now
        Destroy(iconArea.gameObject);
        Destroy(iconContainerSpacing.gameObject);

        //now we can build the popup
        transform.SetParent(GameRuleDesigner.instance.iconContainerTransform);
        //setting the parent screwed up the scale so fix it
        transform.localScale = new Vector3(1.0f, 1.0f);
        componentRepresented = cr;
        popupDescriptors = pd;
        //go through all the descriptors and add their icon to this popup
        foreach (GameRuleDesignComponentDescriptor descriptor in popupDescriptors) {
            RectTransform popupIcon;
            //int descriptors don't have icon prefabs, so we have to construct the icons
            if (descriptor is GameRuleDesignComponentIntDescriptor) {
                List<GameObject> iconList = new List<GameObject>();
                int i = ((GameRuleDesignComponentIntDescriptor)descriptor).intDescribed;
                if (i >= 0) {
                    if (describedType == typeof(GameRulePointsPlayerEffect))
                        iconList.Add(GameRuleIconStorage.instance.charPlusIcon);
                    GameRuleIconStorage.instance.addDigitIcons(i, iconList);
                } else {
                    iconList.Add(GameRuleIconStorage.instance.charMinusIcon);
                    GameRuleIconStorage.instance.addDigitIcons(-i, iconList);
                }
                //make a gameobject to hold all of the icons
                popupIcon = groupIcons(iconList);
            //almost all other descriptors we can construct normally
            //if it doesn't have an icon then it's a special case we know about
            } else if (descriptor.displayIcon == null) {
                if (descriptor is GameRuleDesignComponentClassDescriptor) {
                    System.Type otherType = ((GameRuleDesignComponentClassDescriptor)descriptor).typeDescribed;
                    //a points effect shows up as "+?"
                    if (otherType == typeof(GameRulePointsPlayerEffect))
                        popupIcon = groupIcons(new List<GameObject>(new GameObject[] {
                            GameRuleIconStorage.instance.charPlusIcon,
                            GameRuleIconStorage.instance.charQmarkIcon
                        }));
                    else
                        throw new System.Exception("Bug: no special popup icon cases for type " + otherType);
                } else
                    throw new System.Exception("Bug: no special popup icon cases for " + descriptor);
            //it has an icon, it's probably normal
            } else
                popupIcon = componentRepresented.getIconMaybeOpponent(descriptor);
            popupIcon.SetParent(iconContainer);
            popupIcons.Add(popupIcon);
        }
        //we add a "cancel" icon at the end to ensure there's room to cancel out of the popup
        RectTransform cancelIcon = instantiateIcon(GameRuleDesigner.instance.cancelIconPopupPrefab);
        cancelIcon.SetParent(iconContainer);
        popupIcons.Add(cancelIcon);

        //if we're doing a points effect, default to the "+1" choice
        if (describedType == typeof(GameRulePointsPlayerEffect))
            cr.assignDescriptor(popupDescriptors[
                GameRulePointsPlayerEffect.POINTS_SERIALIZATION_MASK - GameRulePointsPlayerEffect.POINTS_SERIALIZATION_MAX_VALUE + 1]);
        //if we're doing a fixed duration, default to the rule generator min value
        else if (describedType == typeof(GameRuleActionFixedDuration))
            cr.assignDescriptor(popupDescriptors[GameRuleGenerator.ACTION_DURATION_SECONDS_SHORTEST]);
        else
            cr.assignDescriptor(popupDescriptors[0]);
    }
开发者ID:BluShine,项目名称:ScoreBall,代码行数:78,代码来源:GameRuleDesignPopup.cs

示例7: FlipLayoutOnAxis

 /// <summary>
 /// <para>Flips the alignment of the RectTransform along the horizontal or vertical axis, and optionally its children as well.</para>
 /// </summary>
 /// <param name="rect">The RectTransform to flip.</param>
 /// <param name="keepPositioning">Flips around the pivot if true. Flips within the parent rect if false.</param>
 /// <param name="recursive">Flip the children as well?</param>
 /// <param name="axis">The axis to flip along. 0 is horizontal and 1 is vertical.</param>
 public static void FlipLayoutOnAxis(RectTransform rect, int axis, bool keepPositioning, bool recursive)
 {
     if (rect != null)
     {
         if (recursive)
         {
             for (int i = 0; i < rect.childCount; i++)
             {
                 RectTransform child = rect.GetChild(i) as RectTransform;
                 if (child != null)
                 {
                     FlipLayoutOnAxis(child, axis, false, true);
                 }
             }
         }
         Vector2 pivot = rect.pivot;
         pivot[axis] = 1f - pivot[axis];
         rect.pivot = pivot;
         if (!keepPositioning)
         {
             Vector2 anchoredPosition = rect.anchoredPosition;
             anchoredPosition[axis] = -anchoredPosition[axis];
             rect.anchoredPosition = anchoredPosition;
             Vector2 anchorMin = rect.anchorMin;
             Vector2 anchorMax = rect.anchorMax;
             float num2 = anchorMin[axis];
             anchorMin[axis] = 1f - anchorMax[axis];
             anchorMax[axis] = 1f - num2;
             rect.anchorMin = anchorMin;
             rect.anchorMax = anchorMax;
         }
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:40,代码来源:RectTransformUtility.cs

示例8: Awake

 void Awake()
 {
     transform = GetComponent<RectTransform>();
     beltLeft = transform.GetChild(0) as RectTransform;
     beltRight = transform.GetChild(1) as RectTransform;
 }
开发者ID:tkesgar,项目名称:ggj16-wayang,代码行数:6,代码来源:ConveyorBeltScript.cs

示例9: Start

 // Use this for initialization
 void Start()
 {
     inventorySCR = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>();
     tempInventorySCR = GameObject.FindGameObjectWithTag("Inventory").GetComponent<TempInventory>();
     databaseSCR = GameObject.FindGameObjectWithTag ("ItemDatabase").GetComponent<ItemDatabase> ();
     tooltip = GameObject.FindGameObjectWithTag ("ItemTooltipPanel").transform.GetChild (0).GetComponent<RectTransform>();
     tooltipParent = GameObject.FindGameObjectWithTag ("ItemTooltipPanel").GetComponent<RectTransform> ();
     tooltip = tooltipParent.GetChild (0).GetComponent<RectTransform>();
     for (int i = 0; i < 5; i++)
     {
         heroInventory.Add (databaseSCR.GetItem(0));
     }
     for (int i = 0; i < heroInventory.Count; i++)
     {
         heroInventoryStacks.Add(0);
     }
 }
开发者ID:NicolasBighetti,项目名称:bearded-octo-dangerzone,代码行数:18,代码来源:HeroInventory.cs

示例10: FlipLayoutAxes

		public static void FlipLayoutAxes(RectTransform rect, bool keepPositioning, bool recursive)
		{
			if (rect == null)
			{
				return;
			}
			if (recursive)
			{
				for (int i = 0; i < rect.childCount; i++)
				{
					RectTransform rectTransform = rect.GetChild(i) as RectTransform;
					if (rectTransform != null)
					{
						RectTransformUtility.FlipLayoutAxes(rectTransform, false, true);
					}
				}
			}
			rect.pivot = RectTransformUtility.GetTransposed(rect.pivot);
			rect.sizeDelta = RectTransformUtility.GetTransposed(rect.sizeDelta);
			if (keepPositioning)
			{
				return;
			}
			rect.anchoredPosition = RectTransformUtility.GetTransposed(rect.anchoredPosition);
			rect.anchorMin = RectTransformUtility.GetTransposed(rect.anchorMin);
			rect.anchorMax = RectTransformUtility.GetTransposed(rect.anchorMax);
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:27,代码来源:RectTransformUtility.cs

示例11: SurveyProjectButton

        public SurveyProjectButton(SurveyProject sProject, RectTransform buttonTemplate,float fromTop)
        {
            surveyProject = sProject;
            rectTransform = (RectTransform)Instantiate(buttonTemplate);
            name = sProject.projectName;
            rectTransform.gameObject.SetActive(true);
            rectTransform.name = name;
            ((Text)rectTransform.GetChild(0).GetComponent<Text>()).text = name;

            rectTransform.parent = buttonTemplate.parent;

            rectTransform.SetDefaultScale();
            rectTransform.SetSize(buttonTemplate.GetSize());

            rectTransform.SetPivotAndAnchors(Vector2.zero);
            rectTransform.SetLeftTopPosition(new Vector2(-(rectTransform.GetWidth()*0.5f), fromTop));

            Button button = rectTransform.GetComponent<Button>();
            button.onClick.AddListener(OnUse);
        }
开发者ID:pbostrm,项目名称:ceres,代码行数:20,代码来源:SurveyProjectListMenu.cs

示例12: Start

 // Initialise l'inventaire
 // Remplit l'inventaire d'objets vides
 void Start()
 {
     tooltipParent = GameObject.FindGameObjectWithTag ("ItemTooltipPanel").GetComponent<RectTransform> (); // Récupération du parent du tooltip
     tooltip = tooltipParent.GetChild (0).GetComponent<RectTransform>();	// Récupération du tooltip
     tempInventorySlotContainer.SetActive(false);						// Masque l'inventaire temporaire
     InitializeInventory();												// Initialise l'inventaire
     StartCoroutine(DisplayInventory());
 }
开发者ID:NicolasBighetti,项目名称:bearded-octo-dangerzone,代码行数:10,代码来源:TempInventory.cs

示例13: BlockDecoration

 private void BlockDecoration(RectTransform blockPrefab, Block block)
 {
     Color color = new Color();
     string name = "";
     if (block is LandBlock)
     {
         color = new Color(0x00 / 255f, 0xB0 / 255f, 0x06 / 255f);
         name = (block as LandBlock).land.name;
     }
     else if (block is ChanceBlock)
     {
         color = new Color(0xFF / 255f, 0x28 / 255f, 0x28 / 255f);
         name = "Chance";
     }
     else if(block is DestinyBlock)
     {
         color = new Color(0xFF / 255f, 0xCC / 255f, 0x1F / 255f);
         name = "Destiny";
     }
     blockPrefab.GetComponent<RawImage>().color = color;
     blockPrefab.GetChild(0).GetComponent<Text>().text = name;
 }
开发者ID:DSobscure,项目名称:MonopolyOnlineGame,代码行数:22,代码来源:MapUIController.cs

示例14: SignBubbleTimer

    IEnumerator SignBubbleTimer(RectTransform PlayerSignBubble)
    {
        yield return new WaitForSeconds(PlayerSignBubbleStayTime);

        for (int i = PlayerSignBubble.childCount; i > 0; i--)
        {
            Destroy(PlayerSignBubble.GetChild(i-1).gameObject);
        }

        PlayerSignBubble.gameObject.SetActive(false);
    }
开发者ID:veselin-,项目名称:Team4BabelGame,代码行数:11,代码来源:InteractableSpeechBubble.cs

示例15: Start

 // Initialise l'inventaire
 // Remplit l'inventaire d'objets vides
 void Start()
 {
     tooltipParent = GameObject.FindGameObjectWithTag ("ItemTooltipPanel").GetComponent<RectTransform> ();
     tooltip = tooltipParent.GetChild (0).GetComponent<RectTransform>();
     itemHeroSelection = itemHeroSelectionParent.GetChild (0).GetComponent<RectTransform>();
     modalWindowSCR = GameObject.FindGameObjectWithTag("ModalWindowManager").GetComponent<ModalWindowManager>();
     shopManagerSCR = GameObject.FindGameObjectWithTag("ShopManager").GetComponent<ShopManager>();
     for (int i = 0; i < inventorySize; i++)
     {
         inventory.Add(databaseSCR.GetItem(0));
     }
     for (int i = 0; i < inventory.Count; i++)
     {
         inventoryStacks.Add(0);
     }
 }
开发者ID:NicolasBighetti,项目名称:bearded-octo-dangerzone,代码行数:18,代码来源:Inventory.cs


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