- Home /
Question by
akisrn · Aug 26, 2016 at 06:36 AM ·
instantiateprefabtexture2d
Instantiating RawImage
Hi. So i need to load the each image found in a RawImage. I have successfully loaded the images but it's just loading in a single RawImage so the images get on top of one another. I have created a prefab of a RawImage but Im having trouble with calling the instantiate. any help would be greatly appreciated.
So far, this is my algorithm
foreach (object found in folder) {
load image into texture2d
//im having trouble loading the texture2d to the rawimage clones help??
}
Comment
Answer by bolt5 · Aug 26, 2016 at 08:31 AM
To instantiate any objects properly, do:
RawImage ri;
var myRawImage = (RawImage)Instantiate(ri) as RawImage;
//then you can now safely do anything with it; myRawImage.transform.position = Vector3.zero; etc, etc...
Your answer