Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by FlashX · Feb 07, 2017 at 12:07 PM · texture

loading texture from folder dynamically?

silly question i think...

if i place a texture in the same folder as the .exe, is it possible to dynamically load that texture to a 3d object?

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

2 Replies

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

Answer by FlashX · Feb 08, 2017 at 09:27 AM

So i figgured it out! its taken me all day but with the help of AR_Rizvi its all working!!!

the problem... you cant use a friggin PSD file like you can if you were to just drag and drop it onto the object!!! so annoying!!!

 // Add this script to a GameObject. The Start() function fetches an
 // image from the documentation site.  It is then applied as the
 // texture on the GameObject.
 
 using UnityEngine;
 using System.Collections;
 
 public class tex : MonoBehaviour {
 
     private string url = "file:///Users/theuser/Desktop/map.png";
     
     IEnumerator Start() {
     
         Texture2D tex;
         tex = new Texture2D(4, 4, TextureFormat.DXT1, false);
         WWW www = new WWW(url);
         yield return www;
         www.LoadImageIntoTexture(tex);
         GetComponent<Renderer>().material.mainTexture = tex;
     }
 }

Hope this helps someone else out cos ive been beating my head over it all day!!

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
avatar image
0

Answer by AR_Rizvi · Feb 07, 2017 at 12:44 PM

Try This

Comment
Add comment · Show 3 · 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 FlashX · Feb 07, 2017 at 10:51 PM 0
Share

Thanks AR_Rizvi,

I am able to get images from the web working though im having some difficulty getting them directcly from a mac hard drive. ideally id like to have a folder called textures at the same level as the exported .dmg file. ive tried a number of things though i keep getting a "?" texture on my object.

any ideas?

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class loadTex : $$anonymous$$onoBehaviour {
 private string url = "file:///~/textures/testmap.psd";
 
 
     // Use this for initialization
 IEnumerator Start() {
 
         WWW www = new WWW(url);
 
         yield return www;
         Renderer renderer = GetComponent<Renderer>();
         renderer.material.mainTexture = www.texture;
 
     }
     
 }
 
avatar image AR_Rizvi · Feb 08, 2017 at 05:15 AM 0
Share

@FlashX i think you have to provide texture format or so have you checked this

And please look at this for more info

avatar image FlashX AR_Rizvi · Feb 08, 2017 at 07:42 AM 0
Share

Thank you again, i figured it out!!

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

77 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 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 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Assigning UV Map to model at runtime 0 Answers

Terrain Procedural Texturing based on height? 4 Answers

Choose a texture in-game 1 Answer

Leaking Textures in custom editor 2 Answers

Image loaded with LoadImageIntoTexture gets inverted 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