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 madhu131313 · Mar 31, 2015 at 10:06 AM · androidtexturewwwrenderer

www.texture results in black texture in Android

Using WWW I have loaded image from Android Mobile to www object

 planeObj.renderer.material.mainTexture = www.texture;


I am sure image is loaded because www.bytesDownloaded prints exact number of bytes in the image.

 Debug.Log ("No of bytes downloaded are " + www.bytesDownloaded);


Here is my full code attached to an empty game object. this shows actual image when I play in Unity, but when the android app is running, I m getting a black image.

 public class ExampleClass : MonoBehaviour {
     GameObject Cube;
 
     public string url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";
     IEnumerator Start() {
         GameObject planeObj = GameObject.CreatePrimitive (PrimitiveType.Cube);
         planeObj.name="SuperPlane";
         planeObj.transform.eulerAngles = new Vector3 (270,180f, 0f);
         planeObj.transform.localScale = new Vector3 (1.0f, 0, 1.0f);
         WWW www = new WWW(url);
         yield return www;
         planeObj.renderer.material.mainTexture = www.texture; 
 }}

If it is not able to access image it should show ? image, I am getting image as black in color and there is no error in the android logcat console. I have also added a light to make it visible.

edit : simplfied the question to minute level.

Comment
Add comment · Show 2
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 Graham-Dunnett ♦♦ · Mar 31, 2015 at 10:10 AM 0
Share

Normally I'd reject this kind of question. Your code is hosted on an external server, which might download viruses, or interfere with the browser. (I know with paste bin this is unlikely). Also, you are relying on users to go and look at your code, when you could just paste it inline in your question. Also, you show us how you assign the texture to the material. Does that assignment work? Can you display the texture in a GUITexture? What errors, if any, get written to logcat?

avatar image madhu131313 · Apr 03, 2015 at 05:39 AM 0
Share

thanks a lot for encouraging newbie, I have simplified question to my best and modified as per your comments

2 Replies

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

Answer by madhu131313 · Apr 03, 2015 at 12:21 PM

I don't how this is working, if someone explains that will be great.

In Android player settings, I have changed Rendering path to Vertex lit instead of "Forward" It is also not working for other option "Deferred Lighting"

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 ahmadian · Aug 12, 2017 at 05:43 AM 1
Share

This is not an answer. by accepting this you discourage others from giving better answers

avatar image
1

Answer by trololo · Apr 02, 2015 at 08:25 AM

Try the following:

 WWW www = new WWW(url);
 yield return www;
 
 if(www != null && www.error == null)
 {
     Texture2D text = new Texture2D(128, 128, TextureFormat.DXT1, false); //TextureFormat must be DXT
     
     texture.renderer.material.mainTexture = text;
     
     www.LoadImageIntoTexture(text);
 }
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 madhu131313 · Apr 03, 2015 at 05:38 AM 0
Share

my method and your method are working when I load url from web or local image in unity play, but it is displaying black texture in Android in all the cases. $$anonymous$$y game object is dynamically created. When I use a gameobject in scene, I am able to see proper image. Can you please run my code mentioned in your mobile.

avatar image ahmadian · Aug 12, 2017 at 05:44 AM 0
Share

This is not working, my game runs fine on android 4.2 but has this problem with 4.4

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

Loading Pictures from Android Device into game at runtime 1 Answer

Apply texture to object from device gallery 0 Answers

Save an image to PersistentDataPath then access it again 1 Answer

Load texture on disabled GameObject 1 Answer

unity3d www download of large texture mobile 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