Reputation:
Here is my code to add a plane in unity but the problem is the octopus.jpg seems like not to work.
GameObject my_plane;
my_plane = GameObject.CreatePrimitive (PrimitiveType.Plane);
my_plane.transform.Rotate (-90, 0, 0);
Texture my_img = (Texture)Resources.Load ("octopus.jpg");
my_plane.GetComponent<Renderer>().material.mainTexture = my_img;
suggestion please or help . Thank you . my octopus.jpg is in the resources folder.
Upvotes: 0
Views: 2156
Reputation: 106
It would be easier to create a public field in your class :
public Texture my_img;
and just drag the texture that you want to use.
In case you are not running that code in a monobehaviour, you need to have your image inside a folder called "Resources" inside the "Assets" folder. https://docs.unity3d.com/ScriptReference/Resources.html
Upvotes: 1