UnityEngine.UI.DefaultControls.CreateImage C# (CSharp) Method

CreateImage() public static method

public static CreateImage ( Resources resources ) : GameObject
resources UnityEngine.Resources
return 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