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
1
Question by kingrex · May 01, 2011 at 05:02 AM · loadimagesautomatically

how to load images automatically from user's hard disk?

i want to assign a picture from a folder in my computer to a texture2d, but not in the inspector! i want to do it in script. I used Resources Load but there is a problem: I built the game but there was no folder called Resources! how should the user put some extra images in that folder? only I can put images in the folder before building the game, but end user can't.

my purpose is to use images in some folder and load them as texture for some objects. but not in editor! i want to allow the user do this. i've tried many ways like www and this is my last hope. is there any way to do it?

Comment
Add comment · Show 1
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 Joshua · May 01, 2011 at 05:09 AM 0
Share

Interesting question.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Uzquiano · May 01, 2011 at 07:44 AM

Hi,

you have several options:

1) Something like this

private var file : String = ""file://c:/files/file.txt";

var reader : StreamReader = File.OpenText(file);

2) using the WWW class

// Get the latest webcam shot from outside "Friday's" in Times Square var url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg"; function Start () { // Start a download of the given URL var www : WWW = new WWW (url);

// Wait for download to complete yield www;

// assign texture renderer.material.mainTexture = www.texture; }

Comment
Add comment · Show 2 · 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 kingrex · May 01, 2011 at 09:33 AM 0
Share

many thanx bro. but the www make the game crashed. and its becuase of using buttons for loading those images. I want the images to load into buttons automatically so i need to do in OnGUI() function. any other idea?

avatar image entity476 · Feb 03, 2013 at 01:29 PM 0
Share

If by "the www make the game crashed" , you mean there's a script error like "The OnGUI() cannot be a coroutine", then you should call the WWW class from another function, which, the later is called inside OnGUI(). Diagrammatically:

 function OnGUI()
 {
    if button pressed
    {
       URLdownload()
    }
 }
 
 function URLdownload()
 {
    var url...
    var www…
 }

I think the problem is that OnGUI() is called every frame.

(I know it's been a while since the question was asked, but maybe someone will be helped anyhow. Also my program$$anonymous$$g knowledge is very weak, so feel free to correct me)

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

1 Person is following this question.

avatar image

Related Questions

how to load images from hard disk to gui buttons? 1 Answer

How to load images from given folder? 7 Answers

Fatal error after loading image and drawing texture 1 Answer

Error while loading image from Windows Phone gallery 1 Answer

How to load a very large image? 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