Exemple #1
0
        public static GameObject InstantiateGUIObject <T>(GameObject prefab, Transform parent, string name) where T : Component
        {
            GameObject gameObject = UITools.InstantiateGUIObject_Pre <T>(prefab, parent, name);

            if (gameObject == null)
            {
                return(null);
            }
            RectTransform component = gameObject.GetComponent <RectTransform>();

            if (component == null)
            {
                Debug.LogError(name + " prefab is missing RectTransform component!");
            }
            else
            {
                component.localScale = Vector3.one;
            }
            return(gameObject);
        }
Exemple #2
0
        public static GameObject InstantiateGUIObject <T>(GameObject prefab, Transform parent, string name, Vector2 pivot, Vector2 anchorMin, Vector2 anchorMax, Vector2 anchoredPosition) where T : Component
        {
            GameObject gameObject = UITools.InstantiateGUIObject_Pre <T>(prefab, parent, name);

            if (gameObject == null)
            {
                return(null);
            }
            RectTransform component = gameObject.GetComponent <RectTransform>();

            if (component == null)
            {
                Debug.LogError(name + " prefab is missing RectTransform component!");
            }
            else
            {
                component.localScale       = Vector3.one;
                component.pivot            = pivot;
                component.anchorMin        = anchorMin;
                component.anchorMax        = anchorMax;
                component.anchoredPosition = anchoredPosition;
            }
            return(gameObject);
        }