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 niki9000 · Jun 28, 2015 at 07:39 AM · errorimportimageplane

Cant load image into my game

Hey, I want to import an image at runtime into my game from a folder. There is a button, which opens the Editor Utility Open Folder Dialog so you can choose the folder where an image with the name "1 - mid" must be inside. After Choosing the Folder, the image "1 - mid.*" will be added on a new plane. To import the image to the plane I'm using the following code:

 using UnityEngine;
 using System.Collections;
 using System.IO;
 using UnityEditor;
 using UnityEngine.UI;
 
 namespace ImportClass {
     public class ImportPack : MonoBehaviour {
         IEnumerator LoadTexture (FileInfo newPath)
         {
             WWW www = new WWW ("file://"+newPath);;
             yield return www;
             Texture NewImage = null;
             ButtonGameObject.GetComponent<Renderer>().material.mainTexture = www.texture;
         }
     }
 }



Actually everything works fine when I start use this. But when I choose the Folder to import, it shows a questionmark image on the Plane...

alt text

This is the actual image that I want to show ingame...

alt text

Can someone tell me why it shows the questionmark instead of the chosen image?

pic.png (15.1 kB)
fragezeichen.png (197.0 kB)
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

Answer by komodor · Jun 28, 2015 at 07:40 AM

i'd say the problem is in this line

 WWW www = new WWW ("file://"+newPath);;

where you are adding FileInfo to the string

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 niki9000 · Jun 28, 2015 at 08:30 PM 0
Share

I didnt find any mistakes in there...

avatar image komodor · Jul 02, 2015 at 01:51 PM 0
Share

sorry for delay

newPath is FileInfo and not a string, so the FileInfo.ToString() is automatically called and maybe it's not the rest of the path

avatar image niki9000 · Jul 04, 2015 at 08:27 PM 0
Share

That worked for the most of the pictures but some of them still show that question mark...

avatar image
0

Answer by Bunny83 · Jul 02, 2015 at 03:07 PM

"Note: When using file protocol on Windows and Windows Store Apps for accessing local files, you have to specify file:/// (with three slashes)."

See also this one

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

texture import error 0 Answers

[Edited]Access photos from gallery in application (Android) 1 Answer

Mesh deformed? Tried re-import... 1 Answer

import blend to unity, rig look mess 0 Answers

Import Image from Library 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