UnityEngine.UI.DefaultControls.SetParentAndAlign C# (CSharp) Метод

SetParentAndAlign() приватный статический Метод

private static SetParentAndAlign ( GameObject child, GameObject parent ) : void
child UnityEngine.GameObject
parent UnityEngine.GameObject
Результат void
        private static void SetParentAndAlign(GameObject child, GameObject parent)
        {
            if (parent != null)
            {
                child.transform.SetParent(parent.transform, false);
                SetLayerRecursively(child, parent.layer);
            }
        }

Usage Example

        public static GameObject CreateButton(DefaultControls.Resources resources)
        {
            GameObject gameObject  = DefaultControls.CreateUIElementRoot("Button", DefaultControls.s_ThickElementSize);
            GameObject gameObject2 = new GameObject("Text");

            gameObject2.AddComponent <RectTransform>();
            DefaultControls.SetParentAndAlign(gameObject2, gameObject);
            Image image = gameObject.AddComponent <Image>();

            image.sprite = resources.standard;
            image.type   = Image.Type.Sliced;
            image.color  = DefaultControls.s_DefaultSelectableColor;
            Button defaultColorTransitionValues = gameObject.AddComponent <Button>();

            DefaultControls.SetDefaultColorTransitionValues(defaultColorTransitionValues);
            Text text = gameObject2.AddComponent <Text>();

            text.text      = "Button";
            text.alignment = TextAnchor.MiddleCenter;
            DefaultControls.SetDefaultTextValues(text);
            RectTransform component = gameObject2.GetComponent <RectTransform>();

            component.anchorMin = Vector2.zero;
            component.anchorMax = Vector2.one;
            component.sizeDelta = Vector2.zero;
            return(gameObject);
        }
All Usage Examples Of UnityEngine.UI.DefaultControls::SetParentAndAlign