• About
  • Advertise
  • Privacy & Policy
  • Contact
Tech News, Magazine & Review WordPress Theme 2017
  • Home
    • Home – Layout 1
    • Home – Layout 2
    • Home – Layout 3
    • Home – Layout 4
    • Home – Layout 5
  • Review
  • Gaming
  • Gear

    Trending Tags

    • Best iPhone 7 deals
    • Apple Watch 2
    • Nintendo Switch
    • CES 2017
    • Playstation 4 Pro
    • iOS 10
    • iPhone 7
    • Sillicon Valley
  • Computers
  • Applications
  • Security
No Result
View All Result
  • Home
    • Home – Layout 1
    • Home – Layout 2
    • Home – Layout 3
    • Home – Layout 4
    • Home – Layout 5
  • Review
  • Gaming
  • Gear

    Trending Tags

    • Best iPhone 7 deals
    • Apple Watch 2
    • Nintendo Switch
    • CES 2017
    • Playstation 4 Pro
    • iOS 10
    • iPhone 7
    • Sillicon Valley
  • Computers
  • Applications
  • Security
No Result
View All Result
Overflow Archives
No Result
View All Result

Change Color in Runtime – Unity 3D Tutorial

by
Home Unity
Share on FacebookShare on Twitter

In this post, we will learn how to change/update the color of an image, text, and other 2D UI elements. Before going in-depth let’s have a brief on Unity’s Color. In Unity 3D the Color.color having the combination of RGB with an Alpha value which is responsible for the transparency of the color.

To create a color you need four input values like
r – Red color value
g – Green color value
b – Blue color value
a – Alpha value,
these values are range between 0 – 255 on the Unity’s color picker window.

Unity Color Picker Window
Unity Color Picker Window
RGB vs Hexadecimal Color

RGB is a color scope of light using Red, Green, and Blue to render the colors onscreen. RGB is the primary color that provides different colors when mixed. Hexadecimal color code is similar to the RGB combination but it mentioned with the hex value of RGB input. The first two digits represent the Red color, the third and fourth digits for Green color, the last two digits represent Blue color. In most programming tools the color input will be in hexadecimal value, also it is easy to handle the color combination.

Create Color in C#

To create a new color variable do the following

When using color code in C# the input value range from 0 – 1, the method can be used without alpha value also.

The above two example are using the RGB values, we can also use the Hexadecimal color code as following.

Parse Hexadecimal Color Code

To create color from the hexadecimal value we need to use a inbuilt method to handle.

ColorUtility.TryParseHtmlString helps to parse the hex color code to the color variable.

Create Color Variable in Unity Editor

To create a color variable from the Inspector you need to create a public variable for color.

Add pick your desire color from the color picker window.

Create Color From Editor
Create Color From Editor
Changing Color of UI Elements

To change the color of image, button, text and other UI elements first access the game object and update the color with new one.

Hope this post will helpful to you, Happy Coding!.

Tags: archiveschange colorchange color in runtimecolor utilitycreate colors in unityhow to change color in unityoverflowoverflowarchivesparse colorparse html color stringunity 3dunity 3d for beginnersunity 3d tutorialUnity Colorunity tutorialunity tutorial for beginnersunity UIupdate color in runtime

Next Post
Excel to Json in Unity 3D

How to Convert Excel to JSON in Unity C# - Parse Excel file to JSON

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended.

Android Developer Options – Debugging Mode Options Explained – Part – I

Android Developer Options – Debugging Mode Options Explained – Part – I

How to Create circular progress bar in Unity 3D with rounded edge

Trending.

Create Switch button UI in Unity 3D - overflow archives

Create Switch button UI in Unity 3D

Unity Gradient Effect UI Design Without Scripting | Simple Gradient Effects in Unity 3D

Unity Gradient Effect UI Design Without Scripting | Simple Gradient Effects in Unity 3D

Parse Color Runtime In Unity 3D - Thumbnail

Change Color in Runtime – Unity 3D Tutorial

Progress bar in Unity 3D

How to Create Progress bar in Unity 3D

How to Create Android Custom Viewpager Adapter – Android Tutorial

How to Create Android Custom Viewpager Adapter – Android Tutorial

Overflow Archives

© 2023 OverflowArchives.

Navigate Site

  • About
  • Advertise
  • Privacy & Policy
  • Contact

Follow Us

No Result
View All Result
  • Home
  • Review
  • Apple
  • Applications
  • Computers
  • Gaming
  • Gear
    • Audio
    • Camera
    • Smartphone
  • Microsoft
  • Photography
  • Security

© 2023 OverflowArchives.