├── Runtime ├── Adapters.meta ├── Style.cs.meta ├── StyleT.cs.meta ├── Styles.meta ├── Assembly.cs.meta ├── StyleAsset.cs.meta ├── StyleAssetT.cs.meta ├── StyleAssets.meta ├── StyleApplicator.cs.meta ├── StyleCompose.cs.meta ├── StyleContext.cs.meta ├── Styles │ ├── TextStyle.cs.meta │ ├── TextColorStyle.cs.meta │ ├── TmpTextStyle.cs.meta │ ├── ImageColorStyle.cs.meta │ ├── ImageSpriteStyle.cs.meta │ ├── TextLocalizeStyle.cs.meta │ ├── TmpTextColorStyle.cs.meta │ ├── ActivateGameObjectStyle.cs.meta │ ├── I2LocalizationTextStyle.cs.meta │ ├── RectTransformSizeStyle.cs.meta │ ├── TmpTextLocalizeStyle.cs.meta │ ├── RectTransformAnchoredPositionStyle.cs.meta │ ├── ActivateGameObjectStyle.cs │ ├── RectTransformSizeStyle.cs │ ├── TextColorStyle.cs │ ├── ImageColorStyle.cs │ ├── ImageSpriteStyle.cs │ ├── RectTransformAnchoredPositionStyle.cs │ ├── TmpTextColorStyle.cs │ ├── I2LocalizationTextStyle.cs │ ├── TextStyle.cs │ ├── TmpTextStyle.cs │ ├── TextLocalizeStyle.cs │ └── TmpTextLocalizeStyle.cs ├── Adapters │ ├── BoolStyleAdapter.cs.meta │ ├── StyleAdapterBase.cs.meta │ ├── TextStyleAdapter.cs.meta │ ├── BoolStyleAdapter.cs │ ├── TextStyleAdapter.cs │ └── StyleAdapterBase.cs ├── DefaultStyleApplicator.cs.meta ├── StyleAssets │ ├── BoolStyleAsset.cs.meta │ ├── TextStyleAsset.cs.meta │ ├── ColorStyleAsset.cs.meta │ ├── SpriteStyleAsset.cs.meta │ ├── Vector2StyleAsset.cs.meta │ ├── BoolStyleAsset.cs │ ├── TextStyleAsset.cs │ ├── ColorStyleAsset.cs │ ├── SpriteStyleAsset.cs │ └── Vector2StyleAsset.cs ├── Assembly.cs ├── CodeWriter.StyleComponents.Runtime.asmdef.meta ├── StyleAsset.cs ├── StyleAssetT.cs ├── StyleApplicator.cs ├── CodeWriter.StyleComponents.Runtime.asmdef ├── DefaultStyleApplicator.cs ├── Style.cs ├── StyleCompose.cs ├── StyleContext.cs └── StyleT.cs ├── Editor ├── StyleEditor.cs.meta ├── StyleAssetEditor.cs.meta ├── StyleContextMenu.cs.meta ├── StyleEditorEx.cs.meta ├── StyleListEditor.cs.meta ├── StyleComposeEditor.cs.meta ├── CodeWriter.StyleComponents.Editor.asmdef.meta ├── CodeWriter.StyleComponents.Editor.asmdef ├── StyleAssetEditor.cs ├── StyleContextMenu.cs ├── StyleEditor.cs ├── StyleEditorEx.cs ├── StyleListEditor.cs └── StyleComposeEditor.cs ├── LICENSE.md.meta ├── README.md.meta ├── package.json.meta ├── Editor.meta ├── Runtime.meta ├── README.md ├── package.json ├── LICENSE.md └── .editorconfig /Runtime/Adapters.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b80e807f5024ebfa76e2d2a600516cd 3 | timeCreated: 1669624647 -------------------------------------------------------------------------------- /Runtime/Style.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5021f701f67047a2850dc35358fda5cd 3 | timeCreated: 1567357517 -------------------------------------------------------------------------------- /Runtime/StyleT.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34eba1d6d0984a5bab49d9f9239ed913 3 | timeCreated: 1567352369 -------------------------------------------------------------------------------- /Runtime/Styles.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb64a2551d2346e994139fbcebc63fdb 3 | timeCreated: 1567356666 -------------------------------------------------------------------------------- /Editor/StyleEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8510181a9ae34f9d99b9d6bddb1d2f36 3 | timeCreated: 1567353128 -------------------------------------------------------------------------------- /Runtime/Assembly.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39c830a3c973476881d92a72d913f479 3 | timeCreated: 1648480963 -------------------------------------------------------------------------------- /Runtime/StyleAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 50f81510088c45bdad324ffc6d713f5d 3 | timeCreated: 1599546963 -------------------------------------------------------------------------------- /Runtime/StyleAssetT.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0102124f67b645d5bacb4a4c6397d9bd 3 | timeCreated: 1599545844 -------------------------------------------------------------------------------- /Runtime/StyleAssets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9dca18ed3e404ec5ada8c93d5443f0d0 3 | timeCreated: 1599545949 -------------------------------------------------------------------------------- /Editor/StyleAssetEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76f600988b7a4e4a96a4e08f7ac40a32 3 | timeCreated: 1599546914 -------------------------------------------------------------------------------- /Editor/StyleContextMenu.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff548e5545d24d03bd65ebf5aac9fa5e 3 | timeCreated: 1625413714 -------------------------------------------------------------------------------- /Editor/StyleEditorEx.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09d54101ca514b629281bf8deb329863 3 | timeCreated: 1610612901 -------------------------------------------------------------------------------- /Editor/StyleListEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b848e71de1cd4ec6866b4cf4b9de2533 3 | timeCreated: 1599546093 -------------------------------------------------------------------------------- /Runtime/StyleApplicator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d53110de73ac4fd2930f2f5c469b3ddc 3 | timeCreated: 1622716845 -------------------------------------------------------------------------------- /Runtime/StyleCompose.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e934e5bfdbbd4d2dba04c447c5241904 3 | timeCreated: 1567357089 -------------------------------------------------------------------------------- /Runtime/StyleContext.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2769fa06bf7446286e2af00920d3813 3 | timeCreated: 1587656334 -------------------------------------------------------------------------------- /Runtime/Styles/TextStyle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24fdf5e48dc24d1bb21a9c6ab1a576af 3 | timeCreated: 1648055756 -------------------------------------------------------------------------------- /Editor/StyleComposeEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f47db7423dd4c5483516a216ac18383 3 | timeCreated: 1567357358 -------------------------------------------------------------------------------- /Runtime/Styles/TextColorStyle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef6737f9e0e042b6b5a388e8ae5641f4 3 | timeCreated: 1648055710 -------------------------------------------------------------------------------- /Runtime/Styles/TmpTextStyle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8147415125d48b8a4929685ee9db025 3 | timeCreated: 1567352548 -------------------------------------------------------------------------------- /Runtime/Adapters/BoolStyleAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 948bf72f757c45bfba654108ae68cec6 3 | timeCreated: 1669625387 -------------------------------------------------------------------------------- /Runtime/Adapters/StyleAdapterBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bdcd07afcb094298afba1d7b712d5bb7 3 | timeCreated: 1669625263 -------------------------------------------------------------------------------- /Runtime/Adapters/TextStyleAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88f118dfaad64144bebd8eced292c019 3 | timeCreated: 1669624659 -------------------------------------------------------------------------------- /Runtime/DefaultStyleApplicator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17034c8a7cb84e83ba7a7123b7c593d5 3 | timeCreated: 1649062181 -------------------------------------------------------------------------------- /Runtime/StyleAssets/BoolStyleAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6fa8eb2936547328e1889ce10551ec2 3 | timeCreated: 1599550021 -------------------------------------------------------------------------------- /Runtime/StyleAssets/TextStyleAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ae6759423a6415c94c3486405e52e8c 3 | timeCreated: 1599549950 -------------------------------------------------------------------------------- /Runtime/Styles/ImageColorStyle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a56900e70b34e8697c0ad9bf521e73f 3 | timeCreated: 1579536196 -------------------------------------------------------------------------------- /Runtime/Styles/ImageSpriteStyle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 224ba7cac6e041e19733fa04130e17d4 3 | timeCreated: 1567356598 -------------------------------------------------------------------------------- /Runtime/Styles/TextLocalizeStyle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86da43a2ab944eab8aabe6d70cdf4983 3 | timeCreated: 1648475474 -------------------------------------------------------------------------------- /Runtime/Styles/TmpTextColorStyle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51a66c5d98374bb4bcf80a59a824dd3e 3 | timeCreated: 1567846476 -------------------------------------------------------------------------------- /Runtime/StyleAssets/ColorStyleAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3fe4230a8afb40108943fc601aa89212 3 | timeCreated: 1599545960 -------------------------------------------------------------------------------- /Runtime/StyleAssets/SpriteStyleAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 31d766817afb45d8b9899c28972f848c 3 | timeCreated: 1599549877 -------------------------------------------------------------------------------- /Runtime/StyleAssets/Vector2StyleAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81bb6d526b0e464680ebefc3255f0937 3 | timeCreated: 1688127852 -------------------------------------------------------------------------------- /Runtime/Styles/ActivateGameObjectStyle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c31a4bca70bc4822a1fc25016a2ad0f1 3 | timeCreated: 1578736567 -------------------------------------------------------------------------------- /Runtime/Styles/I2LocalizationTextStyle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e75580e68e1941008a4d990646d169f3 3 | timeCreated: 1569427005 -------------------------------------------------------------------------------- /Runtime/Styles/RectTransformSizeStyle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef80672b11984ea7be0675ac2330365b 3 | timeCreated: 1688128505 -------------------------------------------------------------------------------- /Runtime/Styles/TmpTextLocalizeStyle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f868743054a34cf2b232714e9d7af6c1 3 | timeCreated: 1648476277 -------------------------------------------------------------------------------- /Runtime/Styles/RectTransformAnchoredPositionStyle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac2e3a610ceb492b8b261cf13eedd8f0 3 | timeCreated: 1688127929 -------------------------------------------------------------------------------- /Runtime/Assembly.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using TriInspector; 3 | 4 | [assembly: InternalsVisibleTo("CodeWriter.StyleComponents.Editor")] 5 | [assembly: DrawWithTriInspector] -------------------------------------------------------------------------------- /LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6770782b04b32f4bb5fbcbf44ca6353 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f2f4090fe37a50646827ef5aadf361dd 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 451d9721b3dde234b854d79c57e49dc4 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6ea2b4bea449d24d98128a553388297 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f144fbe40b8e24f479a556efe51ab411 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/CodeWriter.StyleComponents.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26619fb15ebf5704abcabed9b9684488 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime/CodeWriter.StyleComponents.Runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 379c6026ecfd25643a986527ae827690 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime/StyleAssets/BoolStyleAsset.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace CodeWriter.StyleComponents.StyleAssets 4 | { 5 | [CreateAssetMenu(menuName = "Style Components/Assets/Bool Style Asset", order = 400)] 6 | public sealed class BoolStyleAsset : StyleAsset 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Runtime/StyleAssets/TextStyleAsset.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace CodeWriter.StyleComponents.StyleAssets 4 | { 5 | [CreateAssetMenu(menuName = "Style Components/Assets/Text Style Asset", order = 400)] 6 | public sealed class TextStyleAsset : StyleAsset 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Runtime/StyleAssets/ColorStyleAsset.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace CodeWriter.StyleComponents.StyleAssets 4 | { 5 | [CreateAssetMenu(menuName = "Style Components/Assets/Color Style Asset", order = 400)] 6 | public sealed class ColorStyleAsset : StyleAsset 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Runtime/StyleAssets/SpriteStyleAsset.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace CodeWriter.StyleComponents.StyleAssets 4 | { 5 | [CreateAssetMenu(menuName = "Style Components/Assets/Sprite Style Asset", order = 400)] 6 | public sealed class SpriteStyleAsset : StyleAsset 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Runtime/StyleAssets/Vector2StyleAsset.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace CodeWriter.StyleComponents.StyleAssets 4 | { 5 | [CreateAssetMenu(menuName = "Style Components/Assets/Vector2 Style Asset", order = 400)] 6 | public sealed class Vector2StyleAsset : StyleAsset 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Runtime/StyleAsset.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace CodeWriter.StyleComponents 5 | { 6 | public abstract class StyleAsset : ScriptableObject 7 | { 8 | public abstract Type ElementType { get; } 9 | 10 | public abstract string[] StyleNames { get; } 11 | } 12 | } -------------------------------------------------------------------------------- /Runtime/Adapters/BoolStyleAdapter.cs: -------------------------------------------------------------------------------- 1 | using CodeWriter.StyleComponents.StyleAssets; 2 | using CodeWriter.ViewBinding; 3 | using UnityEngine; 4 | 5 | namespace CodeWriter.StyleComponents.Adapters { 6 | [AddComponentMenu("View Binding/Adapters/[Binding] Bool Style Adapter")] 7 | public class BoolStyleAdapter : StyleAdapterBase 8 | { 9 | protected override bool DefaultValue { get; } = false; 10 | } 11 | } -------------------------------------------------------------------------------- /Runtime/Adapters/TextStyleAdapter.cs: -------------------------------------------------------------------------------- 1 | using CodeWriter.StyleComponents.StyleAssets; 2 | using CodeWriter.ViewBinding; 3 | using UnityEngine; 4 | 5 | namespace CodeWriter.StyleComponents.Adapters 6 | { 7 | [AddComponentMenu("View Binding/Adapters/[Binding] Text Style Adapter")] 8 | public class TextStyleAdapter : StyleAdapterBase 9 | { 10 | protected override string DefaultValue { get; } = ""; 11 | } 12 | } -------------------------------------------------------------------------------- /Runtime/Styles/ActivateGameObjectStyle.cs: -------------------------------------------------------------------------------- 1 | using CodeWriter.StyleComponents.StyleAssets; 2 | 3 | namespace CodeWriter.StyleComponents 4 | { 5 | using UnityEngine; 6 | 7 | [AddComponentMenu(("Style Components/Activate GameObject Style"))] 8 | public sealed class ActivateGameObjectStyle : Style 9 | { 10 | protected override void Apply(Transform target, bool value) => target.gameObject.SetActive(value); 11 | } 12 | } -------------------------------------------------------------------------------- /Runtime/Styles/RectTransformSizeStyle.cs: -------------------------------------------------------------------------------- 1 | namespace CodeWriter.StyleComponents 2 | { 3 | using StyleAssets; 4 | using UnityEngine; 5 | 6 | [RequireComponent(typeof(RectTransform))] 7 | [AddComponentMenu("Style Components/RectTransform Size Style")] 8 | public class RectTransformSizeStyle : Style 9 | { 10 | protected override void Apply(RectTransform target, Vector2 value) => target.sizeDelta = value; 11 | } 12 | } -------------------------------------------------------------------------------- /Runtime/Styles/TextColorStyle.cs: -------------------------------------------------------------------------------- 1 | using CodeWriter.StyleComponents.StyleAssets; 2 | 3 | namespace CodeWriter.StyleComponents 4 | { 5 | using UnityEngine; 6 | using UnityEngine.UI; 7 | 8 | [RequireComponent(typeof(Text))] 9 | [AddComponentMenu("Style Components/Text Color Style")] 10 | public sealed class TextColorStyle : Style 11 | { 12 | protected override void Apply(Text target, Color value) => target.color = value; 13 | } 14 | } -------------------------------------------------------------------------------- /Runtime/Styles/ImageColorStyle.cs: -------------------------------------------------------------------------------- 1 | using CodeWriter.StyleComponents.StyleAssets; 2 | 3 | namespace CodeWriter.StyleComponents 4 | { 5 | using UnityEngine; 6 | using UnityEngine.UI; 7 | 8 | [RequireComponent(typeof(Image))] 9 | [AddComponentMenu("Style Components/Image Color Style")] 10 | public sealed class ImageColorStyle : Style 11 | { 12 | protected override void Apply(Image target, Color value) => target.color = value; 13 | } 14 | } -------------------------------------------------------------------------------- /Runtime/Styles/ImageSpriteStyle.cs: -------------------------------------------------------------------------------- 1 | using CodeWriter.StyleComponents.StyleAssets; 2 | 3 | namespace CodeWriter.StyleComponents 4 | { 5 | using UnityEngine; 6 | using UnityEngine.UI; 7 | 8 | [RequireComponent(typeof(Image))] 9 | [AddComponentMenu("Style Components/Image Sprite Style")] 10 | public sealed class ImageSpriteStyle : Style 11 | { 12 | protected override void Apply(Image target, Sprite value) => target.sprite = value; 13 | } 14 | } -------------------------------------------------------------------------------- /Runtime/Styles/RectTransformAnchoredPositionStyle.cs: -------------------------------------------------------------------------------- 1 | namespace CodeWriter.StyleComponents 2 | { 3 | using StyleAssets; 4 | using UnityEngine; 5 | 6 | [RequireComponent(typeof(RectTransform))] 7 | [AddComponentMenu("Style Components/RectTransform Anchored Position Style")] 8 | public class RectTransformAnchoredPositionStyle : Style 9 | { 10 | protected override void Apply(RectTransform target, Vector2 value) => target.anchoredPosition = value; 11 | } 12 | } -------------------------------------------------------------------------------- /Runtime/StyleAssetT.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace CodeWriter.StyleComponents 5 | { 6 | public abstract class StyleAsset : StyleAsset 7 | { 8 | [SerializeField] private string[] styleNames = default; 9 | [SerializeField] private TValue[] styleValues = default; 10 | 11 | public sealed override Type ElementType => typeof(TValue); 12 | 13 | public override string[] StyleNames => styleNames; 14 | public TValue[] StyleValues => styleValues; 15 | } 16 | } -------------------------------------------------------------------------------- /Runtime/Styles/TmpTextColorStyle.cs: -------------------------------------------------------------------------------- 1 | using CodeWriter.StyleComponents.StyleAssets; 2 | 3 | #if TEXT_MESH_PRO 4 | namespace CodeWriter.StyleComponents 5 | { 6 | using TMPro; 7 | using UnityEngine; 8 | 9 | [RequireComponent(typeof(TMP_Text))] 10 | [AddComponentMenu("Style Components/Tmp Text Color Style")] 11 | public sealed class TmpTextColorStyle : Style 12 | { 13 | protected override void Apply(TMP_Text target, Color value) => target.color = value; 14 | } 15 | } 16 | #endif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Style Components [![Github license](https://img.shields.io/github/license/codewriter-packages/Style-Components.svg)](#) [![openupm](https://img.shields.io/npm/v/com.codewriter.stylecomponents?label=openupm®istry_uri=https://package.openupm.com)](https://openupm.com/packages/com.codewriter.stylecomponents/) 2 | _Library for styling game objects in Unity_ 3 | 4 | #### NOTE: To use Style Components library you need to install [Tri Inspector](https://github.com/codewriter-packages/Tri-Inspector) - Free and open-source library that improves unity inspector. 5 | -------------------------------------------------------------------------------- /Runtime/StyleApplicator.cs: -------------------------------------------------------------------------------- 1 | using CodeWriter.ViewBinding; 2 | using CodeWriter.ViewBinding.Applicators; 3 | using UnityEngine; 4 | 5 | namespace CodeWriter.StyleComponents 6 | { 7 | [RequireComponent(typeof(Style))] 8 | [AddComponentMenu("View Binding/[Binding] Style Applicator (Dynamic)")] 9 | public class StyleApplicator : ComponentApplicatorBase 10 | { 11 | protected override void Apply(Style target, ViewVariableString source) 12 | { 13 | target.Apply(source.Value, link: true); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.codewriter.stylecomponents", 3 | "displayName": "Style Components", 4 | "description": "Library for styling game objects in Unity", 5 | "version": "3.0.0", 6 | "unity": "2019.3", 7 | "license": "MIT", 8 | "author": "CodeWriter (https://github.com/orgs/codewriter-packages)", 9 | "homepage": "https://github.com/codewriter-packages/Style-Components#readme", 10 | "dependencies": { 11 | "com.codewriter.unimob": "2.2.0", 12 | "com.codewriter.view-binding": "3.0.0", 13 | "com.codewriter.triinspector": "1.12.0" 14 | } 15 | } -------------------------------------------------------------------------------- /Runtime/Styles/I2LocalizationTextStyle.cs: -------------------------------------------------------------------------------- 1 | #if I2_LOCALIZATION 2 | namespace CodeWriter.StyleComponents 3 | { 4 | using UniGreenModules.UniCore.Runtime.ComponentStyle; 5 | using UnityEngine; 6 | 7 | [RequireComponent(typeof(I2.Loc.Localize))] 8 | [AddComponentMenu("Style Components/I2 Localize Text Style")] 9 | public sealed class I2LocalizationTextStyle : Style 10 | { 11 | protected override void Apply(I2.Loc.Localize target, string value) 12 | { 13 | target.Term = value; 14 | target.OnLocalize(true); 15 | } 16 | } 17 | } 18 | #endif -------------------------------------------------------------------------------- /Editor/CodeWriter.StyleComponents.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CodeWriter.StyleComponents.Editor", 3 | "references": [ 4 | "CodeWriter.StyleComponents.Runtime", 5 | "CodeWriter.ViewBinding", 6 | "CodeWriter.ViewBinding.Editor", 7 | "CodeWriter.ViewBinding.Applicators" 8 | ], 9 | "includePlatforms": [ 10 | "Editor" 11 | ], 12 | "excludePlatforms": [], 13 | "allowUnsafeCode": false, 14 | "overrideReferences": false, 15 | "precompiledReferences": [], 16 | "autoReferenced": false, 17 | "defineConstraints": [], 18 | "versionDefines": [], 19 | "noEngineReferences": false 20 | } -------------------------------------------------------------------------------- /Runtime/CodeWriter.StyleComponents.Runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CodeWriter.StyleComponents.Runtime", 3 | "rootNamespace": "", 4 | "references": [ 5 | "Unity.TextMeshPro", 6 | "CodeWriter.ViewBinding", 7 | "CodeWriter.ViewBinding.Applicators", 8 | "UniMob", 9 | "TriInspector" 10 | ], 11 | "includePlatforms": [], 12 | "excludePlatforms": [], 13 | "allowUnsafeCode": false, 14 | "overrideReferences": true, 15 | "precompiledReferences": [], 16 | "autoReferenced": true, 17 | "defineConstraints": [], 18 | "versionDefines": [ 19 | { 20 | "name": "com.unity.textmeshpro", 21 | "expression": "1.0.0", 22 | "define": "TEXT_MESH_PRO" 23 | } 24 | ], 25 | "noEngineReferences": false 26 | } -------------------------------------------------------------------------------- /Runtime/Styles/TextStyle.cs: -------------------------------------------------------------------------------- 1 | namespace CodeWriter.StyleComponents 2 | { 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | using StyleAssets; 6 | using ViewBinding; 7 | 8 | [RequireComponent(typeof(Text))] 9 | [AddComponentMenu("Style Components/Text Style")] 10 | public sealed class TextStyle : Style 11 | { 12 | [SerializeField] 13 | private ViewContextBase context = default; 14 | 15 | [SerializeField] 16 | private ViewContextBase[] extraContexts = new ViewContextBase[0]; 17 | 18 | protected override void Apply(Text target, string value) 19 | { 20 | var textBuilder = new ValueTextBuilder(ValueTextBuilder.DefaultCapacity); 21 | try 22 | { 23 | textBuilder.AppendFormat(value, context, extraContexts); 24 | target.text = textBuilder.ToString(); 25 | } 26 | finally 27 | { 28 | textBuilder.Dispose(); 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Runtime/Styles/TmpTextStyle.cs: -------------------------------------------------------------------------------- 1 | #if TEXT_MESH_PRO 2 | 3 | namespace CodeWriter.StyleComponents 4 | { 5 | using TMPro; 6 | using UnityEngine; 7 | using StyleAssets; 8 | using ViewBinding; 9 | 10 | [RequireComponent(typeof(TMP_Text))] 11 | [AddComponentMenu("Style Components/Tmp Text Style")] 12 | public sealed class TmpTextStyle : Style 13 | { 14 | [SerializeField] 15 | private ViewContextBase context = default; 16 | 17 | [SerializeField] 18 | private ViewContextBase[] extraContexts = new ViewContextBase[0]; 19 | 20 | protected override void Apply(TMP_Text target, string value) 21 | { 22 | var textBuilder = new ValueTextBuilder(ValueTextBuilder.DefaultCapacity); 23 | try 24 | { 25 | textBuilder.AppendFormat(value, context, extraContexts); 26 | target.SetText(textBuilder.RawCharArray, 0, textBuilder.Length); 27 | } 28 | finally 29 | { 30 | textBuilder.Dispose(); 31 | } 32 | } 33 | } 34 | } 35 | #endif -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Vlad Vanifatov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Runtime/DefaultStyleApplicator.cs: -------------------------------------------------------------------------------- 1 | using CodeWriter.ViewBinding; 2 | using TriInspector; 3 | using UnityEngine; 4 | 5 | namespace CodeWriter.StyleComponents 6 | { 7 | [RequireComponent(typeof(Style))] 8 | [AddComponentMenu("View Binding/[Binding] Style Applicator (Default)")] 9 | public class DefaultStyleApplicator : ApplicatorBase 10 | { 11 | [Required] 12 | [SerializeField] 13 | private Style target; 14 | 15 | [SerializeField] 16 | private string styleName = "Default"; 17 | 18 | protected override void Apply() 19 | { 20 | if (target == null) 21 | { 22 | Debug.LogError($"Null applicator target at '{name}'", this); 23 | return; 24 | } 25 | 26 | target.Apply(styleName, link: true); 27 | 28 | #if UNITY_EDITOR 29 | if (!Application.isPlaying) 30 | { 31 | UnityEditor.EditorUtility.SetDirty(target); 32 | } 33 | #endif 34 | } 35 | 36 | #if UNITY_EDITOR 37 | protected override void Reset() 38 | { 39 | base.Reset(); 40 | 41 | target = GetComponent