Quantcast
Channel: Latest Questions by Teriander
Viewing all articles
Browse latest Browse all 16

How to Access the Source Image on "Image" new GUI?

$
0
0
I have a GameOjbect dynamically created called "Package". The component "Image" is created and it works. But I can't figure out how to access the Source Image to assign an image, starting with a sprite called "A.png". Images are located in Assets/Images. Basically I want to assign this image to the Source Image of the component "Image". Any suggestions? using UnityEngine; using System.Collections; using UnityEngine.UI; public class Placement : MonoBehaviour { public GameObject BuildLetter; public Sprite ASprite; // Use this for initialization void Start () { BuildLetter = new GameObject("Package"); BuildLetter.transform.position = new Vector3(0, 0, 0); BuildLetter.AddComponent("Image"); ASprite = BuildLetter.GetComponent("A.png");// this is broken, how do I connect this? } // Update is called once per frame void Update () { } }

Viewing all articles
Browse latest Browse all 16

Latest Images

Trending Articles





Latest Images