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 lucax · Nov 23, 2014 at 05:04 PM · androidshadersmissingpink

Android sprite shaders missing (pink) change via code

Hey, I was working with unity's sprite/diffuse shaders and they work just fine in the editor. But when I make them in android standalone and test them in my Samsung Note 2 they appear pink, which is I reckon missing textures or unsupported shaders. I am changing it from a supported texture using this code

 void Awake()
     {
         daynm = GameObject.Find ("DNM");
         if (daynm.GetComponent<DayNightManager> ().isNight == true) {
             gameObject.renderer.material.shader = Shader.Find("Sprites/Diffuse");    
         }
     }
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 Graham-Dunnett ♦♦ · Nov 23, 2014 at 06:36 PM 0
Share

Well, pink normally means the shader is not found or not supported. Do you have any in the player log file?

2 Replies

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

Answer by lucax · Nov 25, 2014 at 05:42 AM

Alright, I found a foolproof fix. Create a folder called Resources in your Assets. Now make a new shader. Copy the code of your shader in it, change the name as of your new shader in the code (it's in first few lines you can't miss it). Save it.

Now in the the code, call for the shader as normal. It should work fine.

              gameObject.renderer.material.shader = Shader.Find("MyShader");    
 
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
2

Answer by tanoshimi · Nov 23, 2014 at 08:12 PM

If you're changing shaders during runtime, you need to make sure that they're being included in the build (Go to Edit -> Project Settings -> Graphics -> Always Included Shaders and make sure that Sprites/Diffuse is listed there).

The only shaders that Unity can resolve and include at compile-time are those that are initially assigned to objects.

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 lucax · Nov 24, 2014 at 12:10 PM 0
Share

Thanks, I had already done that. No luck :/

avatar image lucax · Nov 24, 2014 at 12:12 PM 0
Share

By the way, YES. I am trying to change them in runtime.

Even tried to use the compression setting while building for the device, which took a good half hour, but that too didn't make any difference.

avatar image PawleyBoboli · Jul 20, 2015 at 10:05 PM 0
Share

This worked for me, since my shader was never used for anything in the scene except when called upon by code.

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

Any news about how to make use of GL_OES_EGL_image_external? 1 Answer

Unity Terrain texture issue on android device 1 Answer

Shader not working, gameobject pink on Android. Fine on Editor 1 Answer

3d platform tutorial 1 Answer

unity 4.6 input, missing touches 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