Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 martygrof3708 · May 06, 2019 at 09:17 PM · materialcolortheme

How to go about making multiple color themes for a simple game?

I have a simple geometry kind of game. It uses basic colors on gameobjects. I want to have multiple color themes.

Should I have 6-7 of the same materials for each theme? Or should I have just one material for each prefab and store different color values in code which I can apply to the materials based on the theme picked?

Or, is there a better way to do this?

Thanks.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by K-Anator · May 06, 2019 at 10:15 PM

I believe, depending on how you're currently colouring your objects, that you can change the albedo via code. https://docs.unity3d.com/ScriptReference/Material.SetColor.html

What kind of code have you currently got that's responsible for setting the objects colour? How many colours are you looking to change?

Comment
Add comment · Show 6 · 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 martygrof3708 · May 07, 2019 at 12:32 AM -1
Share

There are 12 colors per theme, and I want about 10 themes.

As of right now, I just dragged a material onto each prefab. But since I want the colors to change based on the theme the user picks, I am unsure if I should make separate materials for each theme, or just one material for each prefab, and just change the albedo through code. What is better practice?

avatar image K-Anator martygrof3708 · May 07, 2019 at 02:01 AM 0
Share

I'm definitely not one for best practices, though I would assume that multiple materials would be more expensive than doing it via code... I'm trying to think of an efficient way to go about it though. Perhaps have each object query a "theme controller" as to what it's colour should be. something like:

     private void Start()
     {
         //Get required bits
         Renderer rend = GetComponent<Renderer>();
         themeCon = GameObject.FindGameObjectWithTag("ThemeController");
 
         //set required bits
         rend.material.shader = Shader.Find("_Color");
         rend.material.SetColor("_Color", themeCon.SquareColor);
     }

Then within that theme controller, have a number of variables for each type of object

     public string SquareColor;
     public string HexagonColor;
     public string CircleColor;
 
     private void Start()
     {
         //Default Values
         SquareColor = "red";
         HexagonColor = "blue";
         CircleColor = "yellow";
     }
 
     void Theme1()
     {
         SquareColor = "black";
         HexagonColor = "grey";
         CircleColor = "purple";
     }
 
     void Theme2()
     {
         SquareColor = "green";
         HexagonColor = "pink";
         CircleColor = "blellow"; //Reese was a genius.
     }

Then finally, have some sort of GUI that would call whichever theme you wanted. Of course none of the code I wrote here is actually usable, but I think something along those lines would work... you could also look at using JSON to store your themes, then have each object look in there to see what colour it should be based on the current theme. I've yet to delve in to working with JSON, though I do know that it would be more flexible in the long run since you wouldn't need to add another method for each theme. And would probably be easier than my contrived method.

avatar image martygrof3708 K-Anator · May 07, 2019 at 06:50 PM -1
Share

Wow, thanks for the help. I think I will do what you said with the theme controller.

I am still relatively new to Unity, it has JSON? Isn't that a web-language?

Show more comments

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

120 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

Related Questions

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

Changing two different objects renderer colour 1 Answer

Adding a Color Change Script to a Model 1 Answer

Change material color at runtime!! 5 Answers

i have two material , how can i reach them both 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