Giter Site home page Giter Site logo

ivanmurzak / unity-theme Goto Github PK

View Code? Open in Web Editor NEW
90.0 1.0 6.0 2.41 MB

Create palettes of colors and components for change specific color on a specific visual element. Very useful to UI.

License: MIT License

C# 33.67% Batchfile 1.34% ShaderLab 55.37% HLSL 9.63%
unity unity-plugin ugui ui

unity-theme's Introduction

Unity-Theme

npm openupm License Stand With Ukraine

Create palettes of colors and components to change specific colors on a specific visual element. Very useful for UI.

Unity-Theme-1

Features

  • ✔️ Name colors
  • ✔️ Create custom themes with names
  • ✔️ Add as many colors as you need
  • ✔️ Name a theme as you want
  • ✔️ Change theme any moment by name
  • ✔️ Bind color to: Image, SpriteRenderer, TextMeshPro, etc
  • ✔️ Easy way to add custom color binder by new C# class with just a few lines of code
  • ✔️ Rename color even after binding to a component, with no broken links

Installation

openupm add extensions.unity.theme

Usage

  • Go to Window/Unity-Theme
  • Customize color palettes as you want
  • Add ColorBinder components to a target GameObject

Color Binder

A component that binds a color to a specific target, such as Image, SpriteRenderer, TextMeshPro, or anything else.

There is a list of built-in color binders:

  • ImageColorBinder
  • SpriteRendererColorBinder
  • TextMeshProColorBinder

Unity-Theme-Binder

Color palettes

Modify palettes, instant response with all connected GameObjects.

Unity-Theme-Palettes

C# Api

Colors

using Unity.Theme;

Theme.Instance.AddColor("Primary", "#6750A4");
Theme.Instance.AddColor("Primary", Color.white);

Theme.Instance.SetColor("Primary", "#6750A4");
Theme.Instance.SetColor("Primary", Color.white);

Theme.Instance.SetOrAddColor("Primary", "#6750A4");
Theme.Instance.SetOrAddColor("Primary", Color.white);

Theme.Instance.RemoveColorByName("Primary");
Theme.Instance.RemoveColor(colorData);
Theme.Instance.RemoveAllColors();

Themes

using Unity.Theme;

Theme.Instance.AddTheme("Light");
Theme.Instance.SetOrAddTheme("Light");

Theme.Instance.CurrentThemeName = "Light";
Theme.Instance.CurrentThemeIndex = 0;

Theme.Instance.RemoveTheme("Light");
Theme.Instance.RemoveAllThemes();

Create a custom ColorBinder

If you need to bind color to something else, you may extend from BaseColorBinder as listed below.

using UnityEngine;
using TMPro;

namespace Unity.Theme.Binders
{
    [AddComponentMenu("Theme/TextMeshPro Color Binder")]
    public class TextMeshProColorBinder : BaseColorBinder
    {
        [SerializeField] TextMeshProUGUI textMeshPro;

        protected override void Awake()
        {
            if (textMeshPro == null) textMeshPro = GetComponent<TextMeshProUGUI>();
            base.Awake();
        }
        protected override void SetColor(Color color)
        {
            textMeshPro.color = color;
        }
    }
}

Other

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.