All Projects → mob-sakai → CompositeToggle

mob-sakai / CompositeToggle

Licence: MIT license
Composite toggle system for unity

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to CompositeToggle

RevealLayout
揭示效果布局,可以指定2个子布局,以圆形揭示效果切换选中状态
Stars: ✭ 118 (+210.53%)
Mutual labels:  toggle, switch
PygameWidgets
A module for use with Pygame. Includes fully customisable buttons, textboxes, sliders and many more, as well as the ability to create and run animations on these widgets.
Stars: ✭ 34 (-10.53%)
Mutual labels:  toggle, switch
ng-toggle
Bootstrap-styled Angular Toggle Component
Stars: ✭ 14 (-63.16%)
Mutual labels:  toggle, switch
Expo Dark Mode Switch
A beautiful React dark mode switch component for iOS, Android, and Web
Stars: ✭ 137 (+260.53%)
Mutual labels:  style, switch
lily
Hosts管理工具,双击切换立即生效,告别重启浏览器! Hosts manager takes effect immediately on switch
Stars: ✭ 69 (+81.58%)
Mutual labels:  switch
ugui-animated-progressbar
A progress bar with animation of uGUI.
Stars: ✭ 81 (+113.16%)
Mutual labels:  ugui
postcss-gtk
Processes GTK+ CSS into browser CSS
Stars: ✭ 23 (-39.47%)
Mutual labels:  style
SHSliderSwitch
SHSliderSwitch is a simple lightweight library to implement an animated slider switch.
Stars: ✭ 18 (-52.63%)
Mutual labels:  switch
ReuseScroller
Reuse cell for uGUI ScrollView
Stars: ✭ 29 (-23.68%)
Mutual labels:  ugui
unity-ugui-edit-tools
编辑器下的界面工具集合
Stars: ✭ 30 (-21.05%)
Mutual labels:  ugui
markdown.css
📝 The simple CSS to replicate the GitHub Markdown style (Sukka Ver.)
Stars: ✭ 13 (-65.79%)
Mutual labels:  style
WDataTable
WDataTable,a data form component for unity by ugui.
Stars: ✭ 38 (+0%)
Mutual labels:  ugui
wp-showhide
Allows you to embed content within your blog post via WordPress ShortCode API and toggling the visibility of the cotent via a link.
Stars: ✭ 21 (-44.74%)
Mutual labels:  toggle
rcli
Simplified R version handling
Stars: ✭ 33 (-13.16%)
Mutual labels:  switch
xiaomiplug
Xiaomi Mi Smart WiFi Socket integration for Home Assistant
Stars: ✭ 99 (+160.53%)
Mutual labels:  switch
emusak-ui
This is a tool which allows you to download saves or mods for Nintendo Switch emulators using a compatible Emusak backend
Stars: ✭ 877 (+2207.89%)
Mutual labels:  switch
pidswallow
A swallower script using process hierarchy.
Stars: ✭ 40 (+5.26%)
Mutual labels:  toggle
jw-bootstrap-switch-ng2
Bootstrap Switch for Angular 2+
Stars: ✭ 45 (+18.42%)
Mutual labels:  switch
Daft-Exprt
PyTorch Implementation of Daft-Exprt: Robust Prosody Transfer Across Speakers for Expressive Speech Synthesis
Stars: ✭ 41 (+7.89%)
Mutual labels:  style
MultiToggleButton
Multiple state tap-to-toggle UIButton (like old camera flash button)
Stars: ✭ 81 (+113.16%)
Mutual labels:  toggle

CompositeToggle & StyleSystem

Overview

CompositeToggle & StyleSystem are components that manage snapshots of properties.
They supports every properties including Image's Sprite, Graphic's Color, Text's text, GameObject's SetActive, etc...
Set values to properties you need, at same time, without other script.

Requirement

  • Unity5.3+
  • No other SDK

Usage

  1. Download CompositeToggle.unitypackage and install to your project.
  2. AddComponent CompositeToggle or Style to the GameObject.
  3. Enjoy!

How to contorol component's properties in Unity?

In Unity, how to control Images and Text components at the same time?
How to control the properties, such as sprite, text, color or fontSize?
It's common case in game development.

compositetoggle_switch

Do you use UnityEvent? Unfortunately, structures such as Color are not supported.
So, we need a script as following to control the properties.

The script controls 'state (On / Off)' and 'property (sprite etc.)'.
Therefore, as the state or properties increase, we need to add a script.
Considering work bottleneck and maintainability, it is not good.

[SerializeField] Sprite sptireOn;
[SerializeField] Sprite sptireOff;
[SerializeField] Color colorOn;
[SerializeField] Color colorOff;
[SerializeField] int fontSizeOn;
[SerializeField] int fontSizeOff;

void SwitchOn()
{
    GetComponent<Image>().sprite = sptireOn;
    GetComponent<Image>().color = colorOn;
    GetComponent<Text>().fontSize = fontSizeOn;
}

void SwitchOff()
{
    GetComponent<Image>().sprite = sptireOff;
    GetComponent<Image>().color = colorOff;
    GetComponent<Text>().fontSize = fontSizeOff;
}
...

CompositeToggle

CompositeToggle implemented to separate 'state' and 'property'.
The state is defined by a script, and the property is defined by a scene or a prefab.
The script should only turn the toggle on or off. Yes, it is very simple.

compositetoggle_property

[SerializeField] CompositeToggle toggle;

void SetToggleValue(bool isOn)
{
    toggle.booleanValue = isOn;
}

CompositeToggle manage snapshots of properties.
Set values to properties you need, at same time, without other script.

compositetoggle_selectproperty

StyleSystem

StyleSystem collectively manages the properties of Component and separates layout and design like CSS.
A style have some properties you need, and can be referred to by multiple GameObjects.
When the properties of the style are changed, they are immediately applied to the referencing GameObjects.

stylesystem_inspector

In addition, styles can apply at runtime :)

style_pp

Bake Properties To Improve Performance

CompositeToggle internally uses reflection.
Reflection is slow? -Yes, that's right.
You can avoid reflection by baking the property to the script.
Bake the properties from the Style or StyleAsset inspector.

image

Screenshot

  • Tabs and views
    compositetoggle_tabs

  • Indicator
    compositetoggle_indicator

Release Notes

ver.0.1.1:

  • Fixed: InspectorGUI issue.
  • Fixed: Demo scene.

ver.0.1.0:

  • Feature: Supports every properties of all components.
  • Feature: Set values to properties you need, at same time, without other script.
  • Feature: Bake properties to script to improve invocation performance.
  • Feature: (CompositeToggle) 4 kind of value type.
    • Boolean
    • Index
    • Count
    • Flag
  • Feature: (CompositeToggle) Synchronization mode
    • Parent-child relationships
    • Grouping
    • Sync-Other
  • Feature: (CompositeToggle) Some features for every toggles.
    • Comment
    • GameObject activation
    • UnityEvent
  • Feature: (CompositeToggle) Auto grouping construction based on hierarchy children.
  • Feature: (StyleSystem) Style inheritance.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].