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 Ony · Jul 06, 2010 at 10:20 PM · shadermaterialcolorspecular

Can't set _SpecColor but can set _Color no problem - why?

I have an instantiated prefab object with multiple materials assigned. I'm able to easily change properties its instanced material like this:

bodyMesh.renderer.materials[0].SetVector( "_Color", Vector4(1.000, 0.1, 0.1, 1.000) );

and

bodyMesh.renderer.materials[0].mainTexture= theCharTexBundle.assetBundle.Load("BODY-hi-body", Texture2D);

So far, so good. That changes the color and the texture with no trouble.

But... when I try to set the _SpecColor in the same way I'm setting _Color, nothing happens:

bodyMesh.renderer.materials[0].SetVector( "_SpecColor", Vector4(1.000, 0.1, 0.1, 1.000) );

That does nothing.

Why does the _Color property change just fine but _SpecColor doesn't? I feel like I'm missing something obvious.

I'm using the Skin/Bumped Specular shader from the wiki.

Here's the first part of that code:

Shader "Skin/Bumped Specular" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
    _Shininess ("Shininess", Range (0.01, 1)) = 0.078125
    _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
    _BumpMap ("Bump (RGB)", 2D) = "white" {}
    _RimTex ("Rim ramp (GRB) Fresnel ramp (A)", 2D) = " grey" {}
    _WrapTex ("Wrap ramp (RGBA)", 2D) = "grey" {}
}

The crazy part is that right before I change the SpecColor I have this:

print (bodyMesh.renderer.materials[0].GetVector("_SpecColor"));

and it prints the original color, then I do it again after I change the Spec and it prints the new result that I set. When I look at the object in the inspector or in game the spec color is not changed.

I'm losing my mind perhaps?

Comment
Add comment · Show 5
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 Eric5h5 · Jul 06, 2010 at 10:30 PM 0
Share

Shouldn't you be using SetColor and GetColor rather than Vector?

avatar image Ony · Jul 07, 2010 at 03:45 AM 0
Share

I tried those first and had the same results.

avatar image qJake · Jul 07, 2010 at 04:46 AM 0
Share

Still, you should use Set/GetColor... it's probably safer ;)

avatar image Ony · Jul 07, 2010 at 05:11 AM 0
Share

I will if I can get either working, lol.

avatar image Charles-Van-Norman · Jan 16, 2011 at 04:04 AM 0
Share

Bump -- I need to change Spec and Emissive color by script and I can't figure it out!!

0 Replies

· Add your reply
  • Sort: 

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

Changing two different objects renderer colour 1 Answer

Mobile\Vertex Colored shader 0 Answers

Material doesn't have property '_Color' 4 Answers

How can I edit a built-in shader ? 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