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 /
This question was closed Dec 20, 2016 at 10:00 AM by CookieSteve for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by CookieSteve · Dec 05, 2016 at 10:48 AM · texture2dwwwtexturesurlfilepath

Loading a texture from a local image file?

I'm trying to use the method outlined here to load an image file as a texture. However, while that example deals with a website, I'm trying to use a local path instead.

My path may be something like this: "H:\images\newimage.png"

However, if I try to use the aforementioned method for this type of path, it doesn't work. The function just waits indefinitely for the file to 'download'.

What should I be doing instead? www.LoadImageIntoTexture() is the only method I could find for creating a texture from an external image file, but it seems useless if you're not loading it from an actual URL.


Edit: Okay, in one of the related questions, I found this method which seems more suitable for what I'm trying to accomplish.

 tex = Resources.Load(filepath) as Texture2D;
 Debug.Log("Loaded texture: " + tex);

However, running this method doesn't actually seem to load the texture at all. The output just looks like

 Loaded texture: 

I also tried adding "file://" to the start of the filepath string, but that didn't seem to help.

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

  • Sort: 
avatar image
4
Best Answer

Answer by Cherno · Dec 05, 2016 at 12:24 PM

The Resources.Load method only works with assets located in the Resources folder hierarchy inside your project's Assets folder.

This is probably what you are looking for:

Loading texture file from png/jpg file on disk

Texture2D.LoadImage

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 Edy · Jan 10, 2018 at 05:26 PM 3
Share

Since Unity 2017, Texture2D.LoadImage has been replaced by ImageConversion.LoadImage.

Follow this Question

Answers Answers and Comments

63 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

Related Questions

Displaying an image from a resource folder. 2 Answers

How to load image from web (url) without resize? 1 Answer

location of file downloaded with WWW 1 Answer

How to assign texture from url 1 Answer

How do I progressively download images with WWW. 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