x


Dynamicaly Creating A Plane With A JPG Material ...

Hi,

I want to load Image to a plane at runtime...

I have seen this wiki (http://www.unifycommunity.com/wiki/index.php?title=CreatePlane) But I want a more simple basic loading code

I am dreaming something like this...

GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
plane.name = "myPlane";
plane.transform.position = new Vector3(0, 0, 0);
plane.transform.Rotate(90f, 0f, 0f);
//the lines above creates the plane and loads it...

//1 is a jpg in resources folder
//But this line just gives me a pink plane not my jpg...
plane.renderer.material = Resources.Load("1", typeof(Material)) as Material;

How can I achieve this? thanks

more ▼

asked Sep 02 '11 at 06:42 AM

Serdar gravatar image

Serdar
1 1 1 2

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Almost. You want:

plane.renderer.material.mainTexture = Resources.Load("1", typeof(Texture)) as Texture;
more ▼

answered Sep 02 '11 at 06:46 AM

Waz gravatar image

Waz
6.5k 22 33 71

thank you very much.

Sep 02 '11 at 06:47 AM Serdar
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2207
x819
x374
x253
x233

asked: Sep 02 '11 at 06:42 AM

Seen: 1440 times

Last Updated: Sep 02 '11 at 07:05 AM