├── .gitignore ├── Assets └── Editor │ └── ColorBox.cs ├── Images ├── colorbox.gif └── promo.png ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | Assets/AssetStoreTools* 7 | 8 | # Visual Studio cache directory 9 | .vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | *.opendb 26 | 27 | # Unity3D generated meta files 28 | *.pidb.meta 29 | *.pdb.meta 30 | 31 | # Unity3D Generated File On Crash Reports 32 | sysinfo.txt 33 | 34 | # Builds 35 | *.apk 36 | *.unitypackage 37 | -------------------------------------------------------------------------------- /Assets/Editor/ColorBox.cs: -------------------------------------------------------------------------------- 1 | 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | public class ColorBox : EditorWindow { 6 | private string _hexCode; 7 | private string _rValue; 8 | private string _gValue; 9 | private string _bValue; 10 | 11 | [MenuItem("Window/ColorBox")] 12 | static void Open() { 13 | GetWindow(); 14 | } 15 | 16 | private void OnGUI() { 17 | var originColor = GUI.color; 18 | 19 | GUI.color = EditorGUIUtility.isProSkin? Color.white : Color.black; 20 | 21 | EditorGUILayout.Space(); 22 | EditorGUILayout.Space(); 23 | 24 | EditorGUILayout.LabelField("ColorBox", new GUIStyle { 25 | fontSize = 40, 26 | padding = new RectOffset(10, 0, 0, 0), 27 | normal = new GUIStyleState { 28 | textColor = Color.white 29 | } 30 | }); 31 | 32 | EditorGUILayout.Space(); 33 | EditorGUILayout.Space(); 34 | EditorGUILayout.Space(); 35 | EditorGUILayout.Space(); 36 | EditorGUILayout.Space(); 37 | 38 | EditorGUILayout.LabelField("Color hex code to C# color class code", new GUIStyle { 39 | fontSize = 16, 40 | padding = new RectOffset(10, 0, 0, 0), 41 | normal = new GUIStyleState { 42 | textColor = Color.white 43 | } 44 | }); 45 | 46 | GUI.color = Color.white; 47 | 48 | EditorGUILayout.Space(); 49 | EditorGUILayout.Space(); 50 | EditorGUILayout.Space(); 51 | 52 | _hexCode = EditorGUILayout.TextField("Input Hex Color", _hexCode); 53 | 54 | EditorGUILayout.BeginHorizontal(); 55 | EditorGUILayout.LabelField("RGB"); 56 | _rValue = EditorGUILayout.TextField(_rValue, GUILayout.ExpandWidth(true)); 57 | _gValue = EditorGUILayout.TextField(_gValue, GUILayout.ExpandWidth(true)); 58 | _bValue = EditorGUILayout.TextField(_bValue, GUILayout.ExpandWidth(true)); 59 | EditorGUILayout.EndHorizontal(); 60 | 61 | if (!string.IsNullOrEmpty(_hexCode)) { 62 | var hex = _hexCode; 63 | if (!hex.StartsWith("#")) 64 | hex = $"#{hex}"; 65 | 66 | if (ColorUtility.TryParseHtmlString(hex, out var color)) { 67 | EditorGUILayout.ColorField("Color", color); 68 | EditorGUILayout.TextField("Result (Color)", $"new Color({color.r:0.###}f, {color.g:0.###}f, {color.b:0.###}f, {color.a:0.###}f)"); 69 | EditorGUILayout.TextField("Result (Color32)", 70 | $"new Color32({Mathf.RoundToInt(color.r * 255f)}, {Mathf.RoundToInt(color.g * 255f)}, {Mathf.RoundToInt(color.b * 255f)}, {Mathf.RoundToInt(color.a * 255f)})"); 71 | } 72 | } else { 73 | if (int.TryParse(_rValue, out var r) && int.TryParse(_gValue, out var g) && 74 | int.TryParse(_bValue, out var b)) { 75 | var color = new Color32((byte)r, (byte)g, (byte)b, 255); 76 | EditorGUILayout.ColorField("Color", color); 77 | var hex = ColorUtility.ToHtmlStringRGB(color); 78 | EditorGUILayout.TextField("Result (Hex)", hex); 79 | } 80 | } 81 | 82 | GUI.color = originColor; 83 | } 84 | 85 | 86 | } 87 | -------------------------------------------------------------------------------- /Images/colorbox.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synchrok/UnityColorBox/e4673d2269e0a98abf49fb46ba766c0baeb47de3/Images/colorbox.gif -------------------------------------------------------------------------------- /Images/promo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synchrok/UnityColorBox/e4673d2269e0a98abf49fb46ba766c0baeb47de3/Images/promo.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Woosung Jeon 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ColorBox 2 | Color hex code to C# color class code (Editor Window) 3 | 4 | This is a simple editor tool that will make your life better. 5 | 6 | Screenshot 7 | -------- 8 | ![ColorBox Screenshot GIF](/Images/colorbox.gif) 9 | 10 | 11 | Effect 12 | -------- 13 | ![ColorBox Promo](/Images/promo.png) --------------------------------------------------------------------------------