• 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
Question by MrSteve2 · Aug 07, 2020 at 09:37 AM · runtimetexturesblack

Why are my textures black at runtime?

Hello all!

I suspect this might be something to do with the shader set up but my script which works happily with other objects is rendering the below image completely black at run time. alt text Displays fine in Scene mode, but at runtime it's completely black. It is a Standard shader because I have a script that accesses the Alpha channel of the Color.

I have seen a few questions that relate to this but they are quite old and haven't helped me solve anything.

As I mentioned ealier this works fine on other object which are Spheres, but this is a plane is that gives anything away??

Anyone know what is wrong,

ring.png (19.5 kB)
Comment

People who like this

0 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 MrSteve2 · Aug 07, 2020 at 09:55 AM 0
Share

Just to add extra confusion, I have another Plane, with the same script on it, same set up but that renders fine.

alt text

this is the script I am using. The code in flashFunction() works for the stop sign and works fine!

The code in the regular update function effects the blue ring and doesn't work!

 public class trailFader : MonoBehaviour
 {
     public Material myMaterial;
     public float fadeValue;
     public string objectType;
     public GameObject child;
     public bool fadeDir;
     public bool flashIn;
 
     public void Awake()
     {
         objectType = gameObject.tag;
         myMaterial = gameObject.GetComponent<Renderer>().material;
         if (transform.childCount != 0)
         {
             child = transform.GetChild(0).gameObject;
             myMaterial = child.gameObject.GetComponent<Renderer>().material;
         }
     }
 
     public void Update()
     {
         if (objectType == "Untagged")
         {
             var newColor = myMaterial.color;
             newColor.a -= fadeValue;
             myMaterial.color = newColor;
             if (newColor.a < 0)
             {
                 Destroy(gameObject);
             }
 
         }
 
         if (flashIn)
         {
             flashFunction();
         }
 
     }
 
     public void flashFunction()
     {
         if (fadeDir)
         {
             var newColor = myMaterial.color;
             newColor.a += fadeValue*3;
             myMaterial.color = newColor;
             if (newColor.a > 1)
             {
                 fadeDir = !fadeDir;
             }
         }
 
         if (!fadeDir)
         {
             var newColor = myMaterial.color;
             newColor.a -= fadeValue/3;
             myMaterial.color = newColor;
             if (newColor.a < 0)
             {
                 newColor.a = 0;
                 myMaterial.color = newColor;
                 fadeDir = !fadeDir;
                 flashIn = false;
             }
         }
     }
 
     public void OnCollisionEnter(Collision collision)
     {
         if (collision.gameObject.CompareTag("Player"))
         {
             if (objectType == gameObject.tag)
             {
                 flashIn = true;
                 fadeDir = true;
             }
         }
     }
 }

ring2.png (54.5 kB)

2 Replies

  • Sort: 
avatar image

Answer by MrSteve2 · Aug 07, 2020 at 09:58 AM

Ok 1 last thing and I will keep schtum! I had another script on it that effects the scale. (Its grows basically)

Having disabled that, it renders fine. So now I guess it's a new questions, why does effecting the scale of it, effect how it renders?

Comment

People who like this

0 Show 0 · 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

Answer by BobyStar · Dec 21, 2021 at 05:21 AM

I am not exactly sure why scale would effect the rendering. It could be a floating point issue with lighting small areas or rendering small meshes.

​

For anyone who encounters this issue try these checks:

​

  • Make sure you are not scaling the object with a Vector2 and that all scale axis's are not 0.

  • Double check the material and texture properties

  • If it's an imported model, change the Scale Factor in the import settings.

​

If all else fails, try using an Unlit Shader.

Comment

People who like this

0 Show 0 · 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

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

133 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Export objects to a .3DS file at runtime 1 Answer

Assigning textures in project panel to materials dynamically or via editor scripts 1 Answer

C# Error when trying to load Texture at runtime 1 Answer

How to add Textures to other textures during runtime 0 Answers

,Why is my Material on a GameObject black or not to see? 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