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 Menatombo · Jun 16, 2014 at 02:39 AM · textures3d modelscolor change

Change the tint of a texture by texture name?

 using UnityEngine;
 using System.Collections;
 
 public class PSColor : MonoBehaviour {
 
     void OnSetColor(Color color)
     {
         particleSystem.renderer.material.SetColor("_TintColor", color);
     }
     
     void OnGetColor(ColorPicker picker)
     {
         picker.NotifyColor(particleSystem.renderer.material.GetColor("_TintColor"));
     }
 }
 

This works on particles, but I can't figure out exactly what I need to get it to accept the name of a texture. All textures are on the 3D model, but I'd like to allow people to change the colors, but I don't know where to look or what to put in to get it to allow me to call by named textures.

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 Menatombo · Jun 16, 2014 at 04:47 AM 0
Share
 using UnityEngine;
 using System.Collections;
 
 
 public class ObjectColor : $$anonymous$$onoBehaviour {
 
     void OnSetColor(Color color)
     {
         Debug.Log("Hello", gameObject);
         $$anonymous$$aterial mt = new $$anonymous$$aterial(GetComponent<Renderer>().shared$$anonymous$$aterial);
         mt.color = color;
         GetComponent<Renderer>().material = mt;
     }
 
     void OnGetColor(ColorPicker picker)
     {
         picker.NotifyColor(GetComponent<Renderer>().material.color);
     }
 }
 
 

The code is this ins$$anonymous$$d of particle. But I still can't figure out how to call to shaders by name.

2 Replies

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

Answer by robertbu · Jun 16, 2014 at 04:15 AM

Coloring is a property of the shader, not of a texture. Many shaders don't use color at all, and the ones that do, typically use _Color rather than _Tintcolor. And it is up to the shader how the color is used. There is a shortcut if the color property is '_Color'. You can use Material.color:

 renderer.material.color = Color.red;

So the first step is to examine the materials/shaders on your 3D models to see if they have an _Color property. If not, you may have to change the shader you use for your 3D models to get a color overlay. Then you can use material.SetColor() or material.color to set the color.

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 Menatombo · Jun 16, 2014 at 04:45 AM 0
Share

I do have a color property on them. All the shaders have names, but I can't seem to be able to call to the names of the shaders. Like I have one called Pupil and one called Iris. I'd like to be able to call to the shader by name so it is changed.

avatar image
0

Answer by Menatombo · Jun 16, 2014 at 08:12 PM

Wow. Well, I completely forgot that Unity doesn't go by names for almost anything. I got it working by using an array instead of trying to use the names of the shaders!

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

21 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

Related Questions

Select UV map 0 Answers

3D model texture 1 Answer

Trying to use multiple png files for a single texture 0 Answers

Uploading textures to be used for 3d model at runtime? 0 Answers

Car Model Run time Color Change Problem 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