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
1
Question by jacksmash2012 · Jul 20, 2010 at 04:56 PM · shadercolor

How do I get the shader color-property to show up in the Inspector?

Here is the code that I just copied from the Shader tutorial:

   Shader "Tutorial/Basic" {
        Properties {
            _Color ("Main Color", Color) = (1,0.5,0.5,1)
        }
        SubShader {
            Pass {
                Material {
                    Diffuse [_Color]
                }
                Lighting On
            }
        }
    }

But when I look at the inspector, the "Main Color" is always white (1,1,1,1).

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 Cursedth · Oct 08, 2017 at 05:14 AM 0
Share

It's a necro post, but I started the tutorial too and had the same problem To have the color show up simple 'Reset' the shader, no need for all the other hassle :)

3 Replies

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

Answer by Jessy · Jul 20, 2010 at 10:54 PM

Here's how it works, in the Inspector. Whenever you switch the shader, it behaves as if Material.CopyPropertiesFromMaterial was used. So, any similarly-named properties in your new shader will inherit the values from the last shader that had them. Color is not white by default. The reason your default is overwritten, as white, is that the default material has a property named "_Color", and it is set to white by default. When you assign our own material, your "_Color" property won't be respected, so defining it is basically useless, but unfortunately necessary to not produce an error.

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
0
Best Answer

Answer by jashan · Jul 20, 2010 at 05:18 PM

Hm ... it seems that color _Color is somehow predefined to white by Unity. It might be serialized as such. I've added

_Color2 ("Test Color", Color) = (1, 0.5, 0.5, 1)

and that did show up with the correct color. So, my guess would be that you simply have to change the color in the inspector and cannot rely on the default value given in the shader (at least not for _Color; for any other variable name it works).

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 jacksmash2012 · Jul 20, 2010 at 06:04 PM 0
Share

That worked. Thanks!

avatar image
0

Answer by equalsequals · Jul 20, 2010 at 05:19 PM

I believe the problem here is that whenever you create a new Material it defaults to the Diffuse shader.

If you create a new material, change the color to 0,0,255,255 (blue) and then change the shader to something else like say, Decal you will see that the color does not change to that shader's default color.

So unless you write an Editor script that somehow automates and creates a Material with your specified shader, and skips defaulting to Diffuse all together, you're always going to start out with white.

I believe this is just something with the system that is built in that allows you to change shaders in your material without losing any custom data that you have created in the Inspector.

Cheers,

==

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

1 Person is following this question.

avatar image

Related Questions

Material doesn't have a color property '_Color' 4 Answers

Create color changer in strumpy shader editor 1 Answer

Material doesn't have property '_Color' 4 Answers

Transparency cube shader? 1 Answer

GL.Color() has no effect on android 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