Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Barracade · Feb 11, 2019 at 04:18 AM · texture2dmaterialsgameobjectsdynamic loading

My Dynamically create Textures are showing up white until i play with the inspector

Hello I have an odd problem,

I am creating players for a soccer game with dynamically created textures for jumpers

When they get created the Texture shows as white, but if i tick and untick the "enable Detail texture" flag it renders fine showing that the texture was created properly, (Pictures below to explain further)

I assume a redraw call gets made when you fiddle with the inspector but i'm unsure how to leverage that.

Thanks for reading, any advice is greatly appreciated :D

my Problem in image form

dyn2.png (293.8 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
Best Answer

Answer by Eno-Khaon · Feb 11, 2019 at 05:07 AM

I'm not very familiar with the shader you're using, but an initial look around online suggests that it is multi-compiled to use two variants with the Detail Texture enabled or disabled.

Based on that, because you're toggling that shader flag back to "on" it updates which variant of the shader it's using.

With all of this in mind, you should be able to solve your problem at the same time you assign the procedural Texture to the Material by enabling the Keyword in the shader.

 // When you assign the Texture to the Material...
 // I don't know what yours looks like, so here's an
 // approximate guess.
 myMaterial.mainTexture = myNewTexture;
 
 // Then, to tell the Material that you want to use it,
 // assuming you're using the shader I came across...
 myMaterial.EnableKeyword("_TEX_ON");

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 Barracade · Feb 11, 2019 at 05:16 AM 0
Share

Thank you so much for your quick reply, Worked perfectly!!! i have added the snippet below just in case anyone else has the issue i had.

              Debug.Log("Create a jumper");
         GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
             cube.transform.position = new Vector3(0,0, 0);
         cube.GetComponentInChildren<Renderer>().material = make$$anonymous$$at(pname,number);
         cube.GetComponentInChildren<$$anonymous$$eshRenderer>().material.Enable$$anonymous$$eyword("_TEX_ON");

Thanks again!!

avatar image Eno-Khaon Barracade · Feb 11, 2019 at 05:41 AM 0
Share

Happy to help out.

If I may offer another idea while we're at it, $$anonymous$$eshRenderer inherits from Renderer, so you can also cut out a GetComponent<> call here.

 $$anonymous$$eshRenderer mr = cube.GetComponentInChildren<$$anonymous$$eshRenderer>();
 mr.material = make$$anonymous$$at(pname,number);
 mr.material.Enable$$anonymous$$eyword("_TEX_ON");


In fact, you could even potentially condense that down slightly more, as well:

 $$anonymous$$aterial mat = make$$anonymous$$at(pname,number);
 mat.Enable$$anonymous$$eyword("_TEX_ON");
 cube.GetComponentInChildren<$$anonymous$$eshRenderer>().material = mat;
avatar image
0

Answer by unity_107801B5E237A5D0D25D · Jan 28 at 10:04 AM

Hello this is happening when we change the texture of the 2d raw image it is displaying white, if anything changing then it is displaying. what should be going when this happens in 2d Raw image texture change? Thanks

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

109 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

Related Questions

multipart material for texturing a unity default cube 0 Answers

Texture won't apply to plane at runtime. (HDRP) 0 Answers

Batch creating material files for png textures 0 Answers

Texturing a large surface 2 Answers

Problem with textures ? 1 Answer


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