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 Opak · Jun 04, 2013 at 08:40 AM · texturewwwruntimechangewww.loadimageintotexture

LoadImageIntoTexture Runtime Change

Hey,

I'd like to create a script that assigns a texture loaded from the web to three different walls and the url should be changeable within a textfield, so that it changes the texture as well. What I have so far is that it assigns the texture of the predefined url but when I change the url in the textfield, somehow it only changes the texture of one wall. What should I do that it assigns the texture of the new link to every wall? Where's the problem and is there maybe a better solution for what I want to do?

PS: I have just a basic scene with three walls called WallR, WallT and WallL. The "user" should be able to put any link there with an image (ofc with the right format) so it's not possible to preload every texture.

Thank you in advance, Opak

 var url = "http://www10.pic-upload.de/28.05.13/2mztreb6f16.jpg";
 var wallL : GameObject;
 var wallR : GameObject;
 var wallT : GameObject;
 
 function Start () {
     wallL = GameObject.Find("WallL");
      wallR = GameObject.Find("WallR");
      wallT = GameObject.Find("WallT");
      
 // Create a texture in DXT1 format
         renderer.material.mainTexture = new Texture2D(4, 4, TextureFormat.DXT1, false);
         while(true) {
             // Start a download of the given URL
             var www = new WWW(url);
             // wait until the download is done
             yield www;
             // assign the downloaded image to the main texture of the object
             www.LoadImageIntoTexture(renderer.material.mainTexture);
             wallL.renderer.material.mainTextureScale = Vector2 (1 , 0.33);
             wallT.renderer.material.mainTextureScale = Vector2 (1 , 0.33);
             wallT.renderer.material.mainTextureOffset = Vector2 (1 , 0.335);
             wallR.renderer.material.mainTextureScale = Vector2 (1 , 0.33);
             wallR.renderer.material.mainTextureOffset = Vector2 (1 , 0.67);      
         }    
 }
 
 function Update () {
 
 }
 
 function OnGUI () {
     url = GUI.TextField (Rect (10, 10, 500, 20), url, 100); 
 }
 
Comment
Add comment
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

1 Reply

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

Answer by Ashkan_gc · Jun 04, 2013 at 08:55 AM

You are assigning the texture directly to the material of the object which has the script attached. It's beter to put a reference of the texture that you are creating in a variable and set the renderer.material.mainTexture of the 3 wall objects to that texture.

Comment
Add comment · 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

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

15 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

Related Questions

Removing Texture at Runtime Without replacing it 1 Answer

Loading Pictures from Android Device into game at runtime 1 Answer

Run a coroutine when there is spare time 0 Answers

Is there a way to replace the question mark in the WWW.LoadImageIntoTexture? 2 Answers

change terrain texture and tree at runtime 1 Answer


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