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

CreateImage() публичный статический Метод

public static CreateImage ( Resources resources ) : GameObject
resources UnityEngine.Resources
Результат UnityEngine.GameObject
        public static GameObject CreateImage(Resources resources)
        {
            GameObject obj2 = CreateUIElementRoot("Image", s_ImageElementSize);
            obj2.AddComponent<Image>();
            return obj2;
        }

Usage Example

Пример #1
0
        private Image NewImage()
        {
            var resources = new DefaultControls.Resources();
            var go        = DefaultControls.CreateImage(resources);

            if (Application.isPlaying)
            {
                GameObject.DontDestroyOnLoad(go);
            }
            go.layer = gameObject.layer;
            var rt = go.transform as RectTransform;

            if (rt)
            {
                rt.SetParent(rectTransform);
                rt.localPosition = Vector3.zero;
                rt.localRotation = Quaternion.identity;
                rt.localScale    = Vector3.one;
            }
            Image img = go.GetComponent <Image>();

            img.raycastTarget = false;
            return(img);
        }
All Usage Examples Of UnityEngine.UI.DefaultControls::CreateImage