Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by christianstrang · Sep 05, 2013 at 11:25 AM · textureproceduralplaneresources.load

Can't add texture to procedurally generated plane

I'm quite new to Unity and currently have the issue that I can't add a texture to my procedurally generated plane:

 function Start () {
     //Create landscape
     var plane : GameObject = GameObject.CreatePrimitive(PrimitiveType.Plane);
     plane.transform.position = Vector3(0.0, 0.0, 0.0);
     plane.renderer.material.mainTexture = Resources.Load("planeTex");
 
 }

I created a graphic that is 1024x1024 and saved it as .jpg and than dragged this image into my "assets -> materials" folder in unity. At least this is what I gathered in other articles.

Considering the articles this should be a simple task but somehow the texture is not visible (the plane is white). Any help is appreciated (maybe I'm missing a basic information about textures or something like this).

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Benproductions1 · Sep 05, 2013 at 11:25 AM 0
Share

It would be much better if you had the texture as a variable on your script. This would allow you to assign it in the inspector and ensure that it also gets assigned to your material. Resources.Load may return null if the asset is not found.

avatar image christianstrang · Sep 05, 2013 at 11:29 AM 0
Share

I tried that as well, but the texture was still not visible. Do you maybe have a link to an example?

avatar image christianstrang · Sep 05, 2013 at 11:33 AM 0
Share

You mean like this?

 var plane : GameObject = GameObject.CreatePrimitive(PrimitiveType.Plane);
 plane.transform.position = Vector3(0.0, 0.0, 0.0);        
 var mainTex : Texture = Resources.Load("planeTex");        
 plane.renderer.material.mainTexture = mainTex;
avatar image Benproductions1 · Sep 05, 2013 at 12:07 PM 0
Share

no, more like this:

 var texture:Texture2D;
 
 function Start() {
     //plane code
     plane.renderer.material.mainTexture = texture;
 }

This is the standard for inspector assigned variables and is preferred over any dynamic resource loading because of the increased speed it provides.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by fherbst · Sep 05, 2013 at 11:36 AM

As per the documentation for Resources.Load, your texture has to be in a folder called Resources if you want to load it this way. So "Assets > Resources > planeTex" would be a correct path, otherwise it probably won't be found.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image christianstrang · Sep 05, 2013 at 11:37 AM 0
Share

Oh boy... I read that before and couldn't find a resource folder, didn't think to add one myself :/ Thank you for the help, this fixed my issue!

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Texture on plane not displaying properly 0 Answers

Procedural planet, apply textures based on height 0 Answers

Problem with texturing plane 0 Answers

Textures on procedurally generated mesh have lines in between 1 Answer

ridiculous load time using Resources.Load() on android build 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges