Working color picker UI

feature-better-tweakables
Andrew Cassidy 4 years ago
parent e57bed6ed9
commit 10da3dd402

@ -1,21 +1,13 @@
using ConformalDecals.Util;
using UnityEngine;
using UnityEngine.UI;
namespace ConformalDecals.UI {
public class ColorBoxSlider : MonoBehaviour {
[SerializeField] private ColorPickerController.ChannelUpdateEvent _onXChannelChanged = new ColorPickerController.ChannelUpdateEvent();
[SerializeField] private ColorPickerController.ChannelUpdateEvent _onYChannelChanged = new ColorPickerController.ChannelUpdateEvent();
[SerializeField] private Vector2 _value;
[SerializeField] private Vector2Int _channel;
[SerializeField] private bool _hsl;
public class ColorBoxSlider : MonoBehaviour{
[SerializeField] private Vector2 _value;
[SerializeField] private BoxSlider _slider;
[SerializeField] private Image _image;
public void OnSliderUpdate(Vector2 value) { }
public void OnColorUpdate(Color rgb, ColorHSL hsl) { }
}
}

@ -1,14 +1,11 @@
using ConformalDecals.Util;
using UnityEngine;
using UnityEngine.UI;
namespace ConformalDecals.UI {
public class ColorChannelSlider : MonoBehaviour {
[SerializeField] private ColorPickerController.ChannelUpdateEvent _onChannelChanged = new ColorPickerController.ChannelUpdateEvent();
[SerializeField] private float _value;
[SerializeField] private int _channel;
[SerializeField] private bool _hsl;
[SerializeField] private bool _hsv;
[SerializeField] private Selectable _textBox;
[SerializeField] private Slider _slider;
@ -17,7 +14,5 @@ namespace ConformalDecals.UI {
public void OnTextBoxUpdate(string text) { }
public void OnSliderUpdate(float value) { }
public void OnColorUpdate(Color rgb, ColorHSL hsl) { }
}
}

@ -1,12 +0,0 @@
using System;
using System.Globalization;
using UnityEngine;
namespace ConformalDecals.Util {
public struct ColorHSL {
public float h;
public float s;
public float l;
public float a;
}
}

@ -1,19 +1,11 @@
using System;
using ConformalDecals.Util;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace ConformalDecals.UI {
public class ColorPickerController : MonoBehaviour {
[Serializable]
public class ColorUpdateEvent : UnityEvent<Color, ColorHSL> { }
[Serializable]
public class ChannelUpdateEvent : UnityEvent<float, int, bool> { }
[SerializeField] private ColorUpdateEvent _onColorChanged = new ColorUpdateEvent();
[SerializeField] private Color _value;
[SerializeField] private Image _previewImage;
[SerializeField] private Selectable _hexTextBox;
@ -21,7 +13,5 @@ namespace ConformalDecals.UI {
public void OnClose() { }
public void OnHexColorUpdate(string text) { }
public void OnChannelUpdate(float value, int channel, bool hsl) { }
}
}

@ -1,9 +1,14 @@
Shader "ConformalDecals/UI/ColorSlider"
Shader "ConformalDecals/UI/Color Slider"
{
Properties
{
_Color("Color", Color) = (0,0,0,0)
_Radius("Radius", Float) = 4
_OutlineGradient("Outline Gradient Step", Range (0, 1)) = 0.6
_OutlineOpacity("Outline Opacity", Range (0, 0.5)) = 0.1
_OutlineWidth("Outline Width", Float) = 3
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
@ -68,6 +73,10 @@ Shader "ConformalDecals/UI/ColorSlider"
float _Radius;
float4 _Color;
float _OutlineGradient;
float _OutlineOpacity;
float _OutlineWidth;
struct appdata
{
float4 vertex : POSITION;
@ -92,13 +101,10 @@ Shader "ConformalDecals/UI/ColorSlider"
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 color = 1;
color.a = saturate(0.5 - sdRoundedUVBox(i.uv, _Radius));
float4 color = 1;
#ifdef HUE
color.rgb = HSL2RGB(float3(i.uv.y, 1, 0.5));
color.rgb = HSV2RGB(float3(i.uv.y, _Color.y, _Color.z));
#endif //HUE
#ifdef RED
@ -113,6 +119,14 @@ Shader "ConformalDecals/UI/ColorSlider"
color.rgb = float3(_Color.r, _Color.g, i.uv.x);
#endif //BLUE
float rrect = sdRoundedUVBox(i.uv, _Radius);
float gradient = smoothstep(_OutlineGradient, 1 - _OutlineGradient, i.uv.y);
float outlineOpacity = _OutlineOpacity * smoothstep(-1*_OutlineWidth, 0, rrect);
color.rgb = lerp(color.rgb, gradient, outlineOpacity);
color.a = saturate(0.5 - rrect);
#ifdef UNITY_UI_CLIP_RECT
color.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
#endif

@ -1,10 +1,14 @@
Shader "ConformalDecals/UI/HSLSquare"
Shader "ConformalDecals/UI/HSV Square"
{
Properties
{
_Hue("Hue", Range(0,1)) = 0
_Color("Color", Color) = (0,0,0,0)
_Radius("Radius", Float) = 4
_OutlineGradient("Outline Gradient Step", Range (0, 1)) = 0.6
_OutlineOpacity("Outline Opacity", Range (0, 0.5)) = 0.1
_OutlineWidth("Outline Width", Float) = 3
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
@ -57,10 +61,14 @@ Shader "ConformalDecals/UI/HSLSquare"
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
float _Hue;
float _Radius;
float4 _ClipRect;
float _Radius;
float4 _Color;
float _OutlineGradient;
float _OutlineOpacity;
float _OutlineWidth;
struct appdata
{
float4 vertex : POSITION;
@ -90,7 +98,13 @@ Shader "ConformalDecals/UI/HSLSquare"
color.a = saturate(0.5 - sdRoundedUVBox(i.uv, _Radius));
color.rgb = HSL2RGB(float3(_Hue, i.uv.x, i.uv.y));
color.rgb = HSV2RGB(float3(_Color.x, i.uv.x, i.uv.y));
float rrect = sdRoundedUVBox(i.uv, _Radius);
float gradient = smoothstep(_OutlineGradient, 1 - _OutlineGradient, i.uv.y);
float outlineOpacity = _OutlineOpacity * smoothstep(-1*_OutlineWidth, 0, rrect);
color.rgb = lerp(color.rgb, gradient, outlineOpacity);
#ifdef UNITY_UI_CLIP_RECT
color.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);

@ -4,6 +4,11 @@ Shader "ConformalDecals/UI/Color Swatch"
{
_Color("Color", Color) = (0,0,0,0)
_Radius("Radius", Float) = 4
_OutlineGradient("Outline Gradient Step", Range (0, 1)) = 0.6
_OutlineOpacity("Outline Opacity", Range (0, 0.5)) = 0.1
_OutlineWidth("Outline Width", Float) = 3
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
@ -61,6 +66,10 @@ Shader "ConformalDecals/UI/Color Swatch"
float _Radius;
float4 _Color;
float _OutlineGradient;
float _OutlineOpacity;
float _OutlineWidth;
struct appdata
{
float4 vertex : POSITION;
@ -89,6 +98,12 @@ Shader "ConformalDecals/UI/Color Swatch"
color.a = saturate(0.5 - sdRoundedUVBox(i.uv, _Radius));
float rrect = sdRoundedUVBox(i.uv, _Radius);
float gradient = smoothstep(_OutlineGradient, 1 - _OutlineGradient, i.uv.y);
float outlineOpacity = _OutlineOpacity * smoothstep(-1*_OutlineWidth, 0, rrect);
color.rgb = lerp(color.rgb, gradient, outlineOpacity);
#ifdef UNITY_UI_CLIP_RECT
color.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
#endif

@ -8,4 +8,10 @@ inline float3 HSL2RGB(float3 hsl) {
return hsl.z - a * max(-1, min(k - 3, min(9 - k, 1)));
}
inline float3 HSV2RGB(float3 hsv) {
int3 n = int3(5, 3, 1);
float3 k = (n + hsv.x * 6) % 6;
return hsv.z - hsv.z * hsv.y * max(0, min(1, min(k, 4 - k)));
}
#endif

@ -65,13 +65,17 @@ Material:
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _GradientStep: 0.331
- _Green: 0
- _Hue: 0
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _OutlineGradient: 0.7
- _OutlineOpacity: 0.15
- _OutlineWidth: 2.5
- _Parallax: 0.02
- _Radius: 5
- _Radius: 4
- _Red: 0
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1

@ -13,7 +13,7 @@ GameObject:
- component: {fileID: 7880243890744815016}
- component: {fileID: 941972267497223076}
m_Layer: 0
m_Name: SLpicker
m_Name: SVpicker
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -38,7 +38,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -14, y: 0}
m_SizeDelta: {x: -44, y: -16}
m_SizeDelta: {x: -36, y: -16}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &170662711293987444
MonoBehaviour:
@ -110,41 +110,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c9a6d7f28c8cf48c5b0f50cce3c3471d, type: 3}
m_Name:
m_EditorClassIdentifier:
_onXChannelChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2127733108409970602}
m_MethodName: OnChannelUpdate
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: ConformalDecals.UI.ColorPickerController+ChannelUpdateEvent, ConformalDecals,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
_onYChannelChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2127733108409970602}
m_MethodName: OnChannelUpdate
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: ConformalDecals.UI.ColorPickerController+ChannelUpdateEvent, ConformalDecals,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
_value: {x: 0, y: 0}
_channel: {x: 1, y: 2}
_hsl: 1
_hsv: 1
_slider: {fileID: 170662711293987444}
_image: {fileID: 1670219945733215598}
--- !u!114 &941972267497223076
@ -160,81 +128,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
type: 10
--- !u!1 &210006475572844241
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6890609385592660779}
- component: {fileID: 5734712357595334408}
- component: {fileID: 5274020013174875648}
m_Layer: 0
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6890609385592660779
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 210006475572844241}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1102500228457808546}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -8, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5734712357595334408
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 210006475572844241}
m_CullTransparentMesh: 0
--- !u!114 &5274020013174875648
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 210006475572844241}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 2100000, guid: d041a7ea6f10040509c571a1a522a16b, type: 2}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &1102500227130160448
GameObject:
m_ObjectHideFlags: 0
@ -244,6 +137,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1102500227130160449}
- component: {fileID: 4847305968835957251}
- component: {fileID: 1304730198164346037}
m_Layer: 0
m_Name: Handle Slide Area
m_TagString: Untagged
@ -264,73 +159,36 @@ RectTransform:
m_Children:
- {fileID: 1102500228592354974}
m_Father: {fileID: 1102500228457808546}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1102500227191842401
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1102500227191842402}
- component: {fileID: 1102500227191842404}
- component: {fileID: 1102500227191842403}
m_Layer: 0
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1102500227191842402
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500227191842401}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1102500228518806388}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: -8}
m_SizeDelta: {x: -8, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1102500227191842404
--- !u!222 &4847305968835957251
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500227191842401}
m_GameObject: {fileID: 1102500227130160448}
m_CullTransparentMesh: 0
--- !u!114 &1102500227191842403
--- !u!114 &1304730198164346037
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500227191842401}
m_GameObject: {fileID: 1102500227130160448}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 2100000, guid: e77b464119ec34d8094b62f59f1549af, type: 2}
m_Material: {fileID: 2100000, guid: d041a7ea6f10040509c571a1a522a16b, type: 2}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
@ -764,28 +622,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 32f2020e7e41e441cb08d73a98d21fda, type: 3}
m_Name:
m_EditorClassIdentifier:
_onChannelChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2127733108409970602}
m_MethodName: OnChannelUpdate
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: ConformalDecals.UI.ColorPickerController+ChannelUpdateEvent, ConformalDecals,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
_value: 0
_channel: 2
_hsl: 0
_hsv: 0
_textBox: {fileID: 1102500227802508560}
_slider: {fileID: 1102500228518806389}
_image: {fileID: 1102500227191842403}
_image: {fileID: 6696529076962308442}
--- !u!1 &1102500227500736560
GameObject:
m_ObjectHideFlags: 0
@ -815,7 +657,6 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1102500229216677013}
- {fileID: 1102500229029945128}
m_Father: {fileID: 1102500228167217150}
m_RootOrder: 0
@ -1032,28 +873,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 32f2020e7e41e441cb08d73a98d21fda, type: 3}
m_Name:
m_EditorClassIdentifier:
_onChannelChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2127733108409970602}
m_MethodName: OnChannelUpdate
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: ConformalDecals.UI.ColorPickerController+ChannelUpdateEvent, ConformalDecals,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
_value: 0
_channel: 1
_hsl: 0
_hsv: 0
_textBox: {fileID: 1102500227673565182}
_slider: {fileID: 1102500227791644168}
_image: {fileID: 1102500228478160621}
_image: {fileID: 8868464681833934854}
--- !u!1 &1102500227589379527
GameObject:
m_ObjectHideFlags: 0
@ -1628,7 +1453,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 12, y: 0}
m_SizeDelta: {x: 12, y: 8}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1102500227700081975
CanvasRenderer:
@ -2065,7 +1890,6 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1102500228478160620}
- {fileID: 1102500228960856548}
m_Father: {fileID: 1102500227533609007}
m_RootOrder: 0
@ -2431,7 +2255,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 12, y: 0}
m_SizeDelta: {x: 12, y: 8}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1102500227806351781
CanvasRenderer:
@ -2679,7 +2503,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 12, y: 0}
m_SizeDelta: {x: 12, y: 8}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1102500227969521661
CanvasRenderer:
@ -2728,6 +2552,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1102500228042339894}
- component: {fileID: 890595536470929407}
- component: {fileID: 6696529076962308442}
m_Layer: 0
m_Name: Handle Slide Area
m_TagString: Untagged
@ -2748,13 +2574,51 @@ RectTransform:
m_Children:
- {fileID: 1102500227969521659}
m_Father: {fileID: 1102500228518806388}
m_RootOrder: 1
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: -8}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &890595536470929407
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500228042339893}
m_CullTransparentMesh: 0
--- !u!114 &6696529076962308442
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500228042339893}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 2100000, guid: e77b464119ec34d8094b62f59f1549af, type: 2}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &1102500228167217149
GameObject:
m_ObjectHideFlags: 0
@ -2806,28 +2670,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 32f2020e7e41e441cb08d73a98d21fda, type: 3}
m_Name:
m_EditorClassIdentifier:
_onChannelChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2127733108409970602}
m_MethodName: OnChannelUpdate
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: ConformalDecals.UI.ColorPickerController+ChannelUpdateEvent, ConformalDecals,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
_value: 0
_channel: 0
_hsl: 0
_hsv: 0
_textBox: {fileID: 1102500228259436432}
_slider: {fileID: 1102500227500736562}
_image: {fileID: 1102500229216677014}
_image: {fileID: 8460595475559546939}
--- !u!1 &1102500228259436525
GameObject:
m_ObjectHideFlags: 0
@ -3433,7 +3281,6 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 6890609385592660779}
- {fileID: 1102500227130160449}
m_Father: {fileID: 6450911886077540277}
m_RootOrder: 1
@ -3531,103 +3378,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 32f2020e7e41e441cb08d73a98d21fda, type: 3}
m_Name:
m_EditorClassIdentifier:
_onChannelChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2127733108409970602}
m_MethodName: OnChannelUpdate
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: ConformalDecals.UI.ColorPickerController+ChannelUpdateEvent, ConformalDecals,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
_value: 0
_channel: 0
_hsl: 1
_hsv: 1
_textBox: {fileID: 0}
_slider: {fileID: 1102500228457808547}
_image: {fileID: 5274020013174875648}
--- !u!1 &1102500228478160619
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1102500228478160620}
- component: {fileID: 1102500228478160622}
- component: {fileID: 1102500228478160621}
m_Layer: 0
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1102500228478160620
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500228478160619}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1102500227791644167}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: -8}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1102500228478160622
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500228478160619}
m_CullTransparentMesh: 0
--- !u!114 &1102500228478160621
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500228478160619}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 2100000, guid: 134450dbb0bea4774bee1b68dc2ea758, type: 2}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
_image: {fileID: 1304730198164346037}
--- !u!1 &1102500228499595048
GameObject:
m_ObjectHideFlags: 0
@ -3707,7 +3463,6 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1102500227191842402}
- {fileID: 1102500228042339894}
m_Father: {fileID: 1102500227428631011}
m_RootOrder: 0
@ -3828,7 +3583,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 12}
m_SizeDelta: {x: 8, y: 12}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1102500228592354944
CanvasRenderer:
@ -4334,6 +4089,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1102500228960856548}
- component: {fileID: 3403960888508789249}
- component: {fileID: 8868464681833934854}
m_Layer: 0
m_Name: Handle Slide Area
m_TagString: Untagged
@ -4354,13 +4111,51 @@ RectTransform:
m_Children:
- {fileID: 1102500227700081973}
m_Father: {fileID: 1102500227791644167}
m_RootOrder: 1
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: -8}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3403960888508789249
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500228960856547}
m_CullTransparentMesh: 0
--- !u!114 &8868464681833934854
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500228960856547}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 2100000, guid: 134450dbb0bea4774bee1b68dc2ea758, type: 2}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &1102500229012921282
GameObject:
m_ObjectHideFlags: 0
@ -4445,6 +4240,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1102500229029945128}
- component: {fileID: 8660443454688195155}
- component: {fileID: 8460595475559546939}
m_Layer: 0
m_Name: Handle Slide Area
m_TagString: Untagged
@ -4465,13 +4262,51 @@ RectTransform:
m_Children:
- {fileID: 1102500227806351779}
m_Father: {fileID: 1102500227500736561}
m_RootOrder: 1
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: -8}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8660443454688195155
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500229029945127}
m_CullTransparentMesh: 0
--- !u!114 &8460595475559546939
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500229029945127}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 2100000, guid: c9824a210db8b42c99428805423811cf, type: 2}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &1102500229130939274
GameObject:
m_ObjectHideFlags: 0
@ -4963,81 +4798,6 @@ MonoBehaviour:
- {fileID: 0}
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &1102500229216677012
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1102500229216677013}
- component: {fileID: 1102500229216677015}
- component: {fileID: 1102500229216677014}
m_Layer: 0
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1102500229216677013
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500229216677012}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1102500227500736561}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: -8}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1102500229216677015
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500229216677012}
m_CullTransparentMesh: 0
--- !u!114 &1102500229216677014
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102500229216677012}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 2100000, guid: c9824a210db8b42c99428805423811cf, type: 2}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &4051115624775287474
GameObject:
m_ObjectHideFlags: 0
@ -5097,7 +4857,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 2100000, guid: a7435be93a5cf4d97b39257e2959a7d9, type: 2}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
@ -5259,66 +5019,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ca2e56a73e04c4a14909d98eae24946e, type: 3}
m_Name:
m_EditorClassIdentifier:
_onColorChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 6150168319998333966}
m_MethodName: OnColorUpdate
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 8593005346929438053}
m_MethodName: OnColorUpdate
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 4885326101323328167}
m_MethodName: OnColorUpdate
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 481203100091675226}
m_MethodName: OnColorUpdate
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 7880243890744815016}
m_MethodName: OnColorUpdate
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: ConformalDecals.UI.ColorPickerController+ColorUpdateEvent, ConformalDecals,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
_value: {r: 0, g: 0, b: 0, a: 1}
_previewImage: {fileID: 1102500229012921284}
_hexTextBox: {fileID: 1102500227401206586}

@ -65,12 +65,17 @@ Material:
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _GradientStep: 0.2
- _Green: 1
- _Hue: 0
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _OutlineGradient: 0.7
- _OutlineOpacity: 0.15
- _OutlineWidth: 2.5
- _Parallax: 0.02
- _Radius: 4
- _Red: 0
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1

@ -65,12 +65,17 @@ Material:
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _GradientStep: 0.2
- _Green: 0
- _Hue: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _OutlineGradient: 0.55
- _OutlineOpacity: 0.15
- _OutlineWidth: 2.5
- _Parallax: 0.02
- _Radius: 4
- _Red: 0
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
@ -84,5 +89,5 @@ Material:
- _UseUIAlphaClip: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0, g: 0, b: 0, a: 1}
- _Color: {r: 0, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

@ -68,7 +68,11 @@ Material:
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _OutlineGradient: 0.55
- _OutlineOpacity: 0.15
- _OutlineWidth: 2.5
- _Parallax: 0.02
- _Radius: 4
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1

@ -65,12 +65,17 @@ Material:
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _GradientStep: 0.2
- _Green: 0
- _Hue: 0
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _OutlineGradient: 0.7
- _OutlineOpacity: 0.15
- _OutlineWidth: 2.5
- _Parallax: 0.02
- _Radius: 4
- _Red: 1
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1

@ -70,6 +70,9 @@ Material:
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _OutlineGradient: 0.3
- _OutlineOpacity: 0.15
- _OutlineWidth: 2.5
- _Parallax: 0.02
- _Radius: 4
- _Red: 1
@ -85,5 +88,5 @@ Material:
- _UseUIAlphaClip: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0, g: 0, b: 0, a: 1}
- _Color: {r: 0.5176471, g: 0.5019608, b: 0.5019608, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

@ -102,6 +102,7 @@
<Compile Include="Util/ParseUtil.cs" />
<Compile Include="UI/BoxSlider.cs" />
<Compile Include="Util\ColorHSL.cs" />
<Compile Include="Util\ColorHSV.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)/Microsoft.CSharp.targets" />
<PropertyGroup>

@ -1,7 +1,5 @@
using System;
using ConformalDecals.Text;
using ConformalDecals.UI;
using ConformalDecals.Util;
using TMPro;
using UnityEngine;
@ -11,29 +9,27 @@ namespace ConformalDecals {
[KSPField(isPersistant = true)] public string font = "Calibri SDF";
[KSPField(isPersistant = true)] public int style;
[KSPField(isPersistant = true)] public bool vertical;
[KSPField(isPersistant = true)] public Color color = Color.black;
[KSPField(isPersistant = true)] public Color fillColor = Color.black;
[KSPField(isPersistant = true)] public Color outlineColor = Color.white;
[KSPField(isPersistant = true)] public float outlineWidth;
private DecalText _text;
private TextEntryController _textEntryController;
public override void OnLoad(ConfigNode node) {
base.OnLoad(node);
}
private TextEntryController _textEntryController;
private ColorPickerController _fillColorPickerController;
private ColorPickerController _outlineColorPickerCOntroller;
public override void OnStart(StartState state) {
base.OnStart(state);
var decalFont = DecalConfig.GetFont(font);
var decalFont = DecalConfig.GetFont(font);
_text = new DecalText {
text = text,
font = decalFont,
style = (FontStyles) style,
vertical = vertical,
color = color,
color = fillColor,
outlineColor = outlineColor,
outlineWidth = outlineWidth
};
@ -43,11 +39,33 @@ namespace ConformalDecals {
_text = newText;
}
public void OnFillColorUpdate(Color rgb, Util.ColorHSV hsv) {
Debug.Log($"new fill color: {rgb}, {hsv}");
}
public void OnOutlineColorUpdate(Color rgb, Util.ColorHSV hsv) {
Debug.Log($"new outline color: {rgb}, {hsv}");
}
[KSPEvent(guiActive = false, guiActiveEditor = true, guiName = "#LOC_ConformalDecals_gui-select-flag")]
public void SetText() {
if (_textEntryController == null) {
_textEntryController = TextEntryController.Create(_text, OnTextUpdate);
}
}
[KSPEvent(guiActive = false, guiActiveEditor = true, guiName = "Set Fill Color")]
public void SetFillColor() {
if (_fillColorPickerController == null) {
_fillColorPickerController = ColorPickerController.Create(fillColor, OnFillColorUpdate);
}
}
[KSPEvent(guiActive = false, guiActiveEditor = true, guiName = "Set Outline Color")]
public void SetOutlineColor() {
if (_outlineColorPickerCOntroller == null) {
_outlineColorPickerCOntroller = ColorPickerController.Create(outlineColor, OnOutlineColorUpdate);
}
}
}
}

@ -30,6 +30,7 @@ namespace ConformalDecals.UI {
get => _value;
set {
_value = value;
_onValueChanged.Invoke(value);
UpdateVisuals();
}
}

@ -1,20 +1,16 @@
using ConformalDecals.Util;
using UnityEngine;
using UnityEngine.UI;
namespace ConformalDecals.UI {
public class ColorBoxSlider : MonoBehaviour {
[SerializeField] private ColorPickerController.ChannelUpdateEvent _onXChannelChanged = new ColorPickerController.ChannelUpdateEvent();
[SerializeField] private ColorPickerController.ChannelUpdateEvent _onYChannelChanged = new ColorPickerController.ChannelUpdateEvent();
[SerializeField] public ColorPickerController.SVUpdateEvent onValueChanged = new ColorPickerController.SVUpdateEvent();
[SerializeField] private Vector2 _value;
[SerializeField] private Vector2Int _channel;
[SerializeField] private bool _hsl;
[SerializeField] private BoxSlider _slider;
[SerializeField] private Image _image;
private static readonly int Hue = Shader.PropertyToID("_Hue");
private bool _ignoreUpdates;
public Vector2 Value {
get => _value;
@ -22,31 +18,46 @@ namespace ConformalDecals.UI {
_value.x = Mathf.Clamp01(value.x);
_value.y = Mathf.Clamp01(value.y);
UpdateSlider();
OnChannelUpdate();
UpdateChannels();
}
}
public void OnColorUpdate(Color rgb, Util.ColorHSV hsv) {
if (_ignoreUpdates) return;
_image.material.SetColor(PropertyIDs._Color, (Vector4) hsv);
_value.x = hsv.s;
_value.y = hsv.v;
UpdateSlider();
}
public void OnSliderUpdate(Vector2 value) {
if (_ignoreUpdates) return;
_value = value;
OnChannelUpdate();
UpdateChannels();
}
public void OnChannelUpdate() {
_onXChannelChanged.Invoke(_value.x, _channel.x, _hsl);
_onYChannelChanged.Invoke(_value.y, _channel.y, _hsl);
private void Awake() {
var boxSlider = gameObject.GetComponentInChildren<BoxSlider>();
boxSlider.OnValueChanged.AddListener(OnSliderUpdate);
}
public void OnColorUpdate(Color rgb, ColorHSL hsl) {
Vector2 newValue;
newValue.x = _hsl ? hsl[_channel.x] : rgb[_channel.x];
newValue.y = _hsl ? hsl[_channel.y] : rgb[_channel.y];
Value = newValue;
private void UpdateChannels() {
_ignoreUpdates = true;
_image.material.SetFloat(Hue, hsl.h);
onValueChanged.Invoke(_value);
_ignoreUpdates = false;
}
public void UpdateSlider() {
private void UpdateSlider() {
_ignoreUpdates = true;
_slider.Value = _value;
_ignoreUpdates = false;
}
}
}

@ -1,15 +1,14 @@
using ConformalDecals.Util;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace ConformalDecals.UI {
public class ColorChannelSlider : MonoBehaviour {
[SerializeField] private ColorPickerController.ChannelUpdateEvent _onChannelChanged = new ColorPickerController.ChannelUpdateEvent();
[SerializeField] public ColorPickerController.ChannelUpdateEvent onChannelChanged = new ColorPickerController.ChannelUpdateEvent();
[SerializeField] private float _value;
[SerializeField] private int _channel;
[SerializeField] private bool _hsl;
[SerializeField] private bool _hsv;
[SerializeField] private Selectable _textBox;
[SerializeField] private Slider _slider;
@ -23,17 +22,27 @@ namespace ConformalDecals.UI {
_value = Mathf.Clamp01(value);
UpdateSlider();
UpdateTextbox();
OnChannelUpdate();
UpdateChannel();
}
}
public void OnColorUpdate(Color rgb, Util.ColorHSV hsv) {
if (_ignoreUpdates) return;
_image.material.SetColor(PropertyIDs._Color, _hsv ? (Color) (Vector4) hsv : rgb);
_value = _hsv ? hsv[_channel] : rgb[_channel];
UpdateSlider();
UpdateTextbox();
}
public void OnTextBoxUpdate(string text) {
if (_ignoreUpdates) return;
if (byte.TryParse(text, out byte byteValue)) {
_value = (float) byteValue / 255;
UpdateSlider();
OnChannelUpdate();
UpdateChannel();
}
else {
// value is invalid, reset value
@ -46,25 +55,20 @@ namespace ConformalDecals.UI {
_value = value;
UpdateTextbox();
OnChannelUpdate();
}
public void OnChannelUpdate() {
_onChannelChanged.Invoke(_value, _channel, _hsl);
UpdateChannel();
}
public void OnColorUpdate(Color rgb, ColorHSL hsl) {
_image.material.SetColor(PropertyIDs._Color, rgb);
Value = _hsl ? hsl[_channel] : rgb[_channel];
private void UpdateChannel() {
onChannelChanged.Invoke(_value, _channel, _hsv);
}
public void UpdateSlider() {
private void UpdateSlider() {
_ignoreUpdates = true;
_slider.value = _value;
_ignoreUpdates = false;
}
public void UpdateTextbox() {
private void UpdateTextbox() {
if (_textBox == null) return;
_ignoreUpdates = true;

@ -8,12 +8,15 @@ using UnityEngine.UI;
namespace ConformalDecals.UI {
public class ColorPickerController : MonoBehaviour {
[Serializable]
public class ColorUpdateEvent : UnityEvent<Color, ColorHSL> { }
public class ColorUpdateEvent : UnityEvent<Color, Util.ColorHSV> { }
[Serializable]
public class ChannelUpdateEvent : UnityEvent<float, int, bool> { }
[SerializeField] private ColorUpdateEvent _onColorChanged = new ColorUpdateEvent();
[Serializable]
public class SVUpdateEvent : UnityEvent<Vector2> { }
[SerializeField] public ColorUpdateEvent onColorChanged = new ColorUpdateEvent();
[SerializeField] private Color _value;
[SerializeField] private Image _previewImage;
@ -29,23 +32,23 @@ namespace ConformalDecals.UI {
}
}
public ColorHSL HSL {
get => ColorHSL.RGB2HSL(_value);
public Util.ColorHSV HSV {
get => Util.ColorHSV.RGB2HSV(_value);
set {
_value = ColorHSL.HSL2RGB(value);
_value = Util.ColorHSV.HSV2RGB(value);
OnColorUpdate();
}
}
public static ColorPickerController Create(Color rgb, UnityAction<Color, ColorHSL> colorUpdateCallback) {
public static ColorPickerController Create(Color rgb, UnityAction<Color, Util.ColorHSV> colorUpdateCallback) {
var menu = Instantiate(UILoader.ColorPickerPrefab, MainCanvasUtil.MainCanvas.transform, true);
menu.AddComponent<DragPanel>();
MenuNavigation.SpawnMenuNavigation(menu, Navigation.Mode.Automatic, true);
var controller = menu.GetComponent<ColorPickerController>();
controller.RGB = rgb;
controller._onColorChanged.AddListener(colorUpdateCallback);
controller.onColorChanged.AddListener(colorUpdateCallback);
return controller;
}
@ -53,9 +56,30 @@ namespace ConformalDecals.UI {
Destroy(gameObject);
}
public void OnChannelUpdate(float value, int channel, bool hsv) {
if (hsv) {
var newHSV = HSV;
newHSV[channel] = value;
HSV = newHSV;
}
else {
var newRGB = RGB;
newRGB[channel] = value;
RGB = newRGB;
}
}
public void OnSVUpdate(Vector2 sv) {
var newHSV = HSV;
newHSV.s = sv.x;
newHSV.v = sv.y;
HSV = newHSV;
}
public void OnColorUpdate() {
_onColorChanged.Invoke(RGB, HSL);
onColorChanged.Invoke(RGB, HSV);
_previewImage.material.SetColor(PropertyIDs._Color, RGB);
UpdateHexColor();
}
public void OnHexColorUpdate(string text) {
@ -70,23 +94,24 @@ namespace ConformalDecals.UI {
}
}
public void UpdateHexColor() {
_ignoreUpdate = true;
((TMP_InputField) _hexTextBox).text = $"{RGB.r:x2}{RGB.g:x2}{RGB.b:x2}";
_ignoreUpdate = false;
}
public void OnChannelUpdate(float value, int channel, bool hsl) {
if (hsl) {
var newHSL = HSL;
newHSL[channel] = value;
HSL = newHSL;
private void Awake() {
foreach (var slider in gameObject.GetComponentsInChildren<ColorChannelSlider>()) {
slider.onChannelChanged.AddListener(OnChannelUpdate);
onColorChanged.AddListener(slider.OnColorUpdate);
}
else {
var newRGB = RGB;
newRGB[channel] = value;
RGB = newRGB;
foreach (var box in gameObject.GetComponentsInChildren<ColorBoxSlider>()) {
box.onValueChanged.AddListener(OnSVUpdate);
onColorChanged.AddListener(box.OnColorUpdate);
}
}
private void UpdateHexColor() {
_ignoreUpdate = true;
var byteColor = (Color32) RGB;
var hexColor = $"{byteColor.r:x2}{byteColor.g:x2}{byteColor.b:x2}";
((TMP_InputField) _hexTextBox).text = hexColor;
_ignoreUpdate = false;
}
}
}

@ -11,7 +11,7 @@ namespace ConformalDecals.UI {
[Serializable]
public class FontUpdateEvent : UnityEvent<DecalFont> { }
[SerializeField] private FontUpdateEvent _onFontChanged = new FontUpdateEvent();
[SerializeField] public FontUpdateEvent onFontChanged = new FontUpdateEvent();
[SerializeField] private GameObject _menuItem;
[SerializeField] private GameObject _menuList;
@ -25,7 +25,7 @@ namespace ConformalDecals.UI {
var controller = menu.GetComponent<FontMenuController>();
controller._currentFont = currentFont;
controller._onFontChanged.AddListener(fontUpdateCallback);
controller.onFontChanged.AddListener(fontUpdateCallback);
controller.Populate(fonts);
return controller;
@ -37,7 +37,7 @@ namespace ConformalDecals.UI {
public void OnFontSelected(DecalFont font) {
_currentFont = font ?? throw new ArgumentNullException(nameof(font));
_onFontChanged.Invoke(_currentFont);
onFontChanged.Invoke(_currentFont);
}
public void Populate(IEnumerable<DecalFont> fonts) {

@ -10,7 +10,7 @@ namespace ConformalDecals.UI {
[Serializable]
public class TextUpdateEvent : UnityEvent<DecalText> { }
[SerializeField] private TextUpdateEvent _onTextUpdate = new TextUpdateEvent();
[SerializeField] public TextUpdateEvent onTextUpdate = new TextUpdateEvent();
[SerializeField] private Selectable _textBox;
[SerializeField] private Button _fontButton;
@ -32,7 +32,7 @@ namespace ConformalDecals.UI {
var controller = window.GetComponent<TextEntryController>();
controller._decalText = text;
controller._onTextUpdate.AddListener(textUpdateCallback);
controller.onTextUpdate.AddListener(textUpdateCallback);
return controller;
}
@ -57,7 +57,7 @@ namespace ConformalDecals.UI {
}
public void OnAnyUpdate() {
_onTextUpdate.Invoke(_decalText);
onTextUpdate.Invoke(_decalText);
}
public void OnTextUpdate(string newText) {

@ -1,4 +1,3 @@
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
@ -63,7 +62,7 @@ namespace ConformalDecals.UI {
ProcessBoxSlider(tag.gameObject, skin.horizontalSlider, skin.horizontalSliderThumb);
break;
case UITag.UIType.Slider:
ProcessSlider(tag.gameObject, skin.horizontalSlider, skin.horizontalSliderThumb, skin.verticalSlider, skin.verticalSliderThumb);
ProcessSlider(tag.gameObject, skin.horizontalSlider, skin.horizontalSliderThumb, skin.horizontalSlider, skin.horizontalSliderThumb);
break;
case UITag.UIType.Box:
ProcessSelectable(tag.gameObject, skin.box);
@ -82,7 +81,10 @@ namespace ConformalDecals.UI {
}
private static void ProcessImage(GameObject gameObject, UIStyle style) {
ProcessImage(gameObject.GetComponent<Image>(), style.normal);
var image = gameObject.GetComponent<Image>();
if (image != null) {
ProcessImage(image, style.normal);
}
}
private static void ProcessImage(Image image, UIStyleState state) {
@ -135,10 +137,9 @@ namespace ConformalDecals.UI {
ProcessSelectable(gameObject, thumbStyle);
var back = gameObject.transform.Find("Background").GetComponent<Image>();
var back = gameObject.transform.Find("Background");
if (back != null) {
back.sprite = sliderStyle.normal.background;
back.type = Image.Type.Sliced;
ProcessImage(back.gameObject, sliderStyle);
}
}
}
@ -146,9 +147,9 @@ namespace ConformalDecals.UI {
private static void ProcessBoxSlider(GameObject gameObject, UIStyle backgroundStyle, UIStyle thumbStyle) {
ProcessSelectable(gameObject, thumbStyle);
var background = gameObject.transform.Find("Background").gameObject;
var background = gameObject.transform.Find("Background");
if (background != null) {
ProcessImage(background, backgroundStyle);
ProcessImage(background.gameObject, backgroundStyle);
}
}

@ -0,0 +1,123 @@
using System;
using System.Globalization;
using UnityEngine;
namespace ConformalDecals.Util {
public struct ColorHSV : IEquatable<Color> {
public float h;
public float s;
public float v;
public float a;
public ColorHSV(float h, float s = 1, float v = 1, float a = 1) {
this.h = h;
this.s = s;
this.v = v;
this.a = a;
}
public override string ToString() {
return $"HSVA({this.h:F3}, {this.s:F3}, {this.v:F3}, {this.a:F3})";
}
public string ToString(string format) {
return
"HSVA(" +
$"{this.h.ToString(format, CultureInfo.InvariantCulture.NumberFormat)}, " +
$"{this.s.ToString(format, CultureInfo.InvariantCulture.NumberFormat)}, " +
$"{this.v.ToString(format, CultureInfo.InvariantCulture.NumberFormat)}, " +
$"{this.a.ToString(format, CultureInfo.InvariantCulture.NumberFormat)})";
}
public bool Equals(ColorHSL other) {
return (this.h.Equals(other.h) && this.s.Equals(other.s) && this.v.Equals(other.l) && this.a.Equals(other.a));
}
public bool Equals(Color other) {
var rgb = HSV2RGB(this);
return rgb.Equals(other);
}
public override bool Equals(object obj) {
if (obj is ColorHSL otherHSL) return Equals(otherHSL);
if (obj is Color otherRGB) return Equals(otherRGB);
return false;
}
public override int GetHashCode() {
return ((Vector4) this).GetHashCode();
}
public float this[int index] {
get {
switch (index) {
case 0:
return this.h;
case 1:
return this.s;
case 2:
return this.v;
case 3:
return this.a;
default:
throw new IndexOutOfRangeException("Invalid Vector3 index!");
}
}
set {
switch (index) {
case 0:
this.h = value;
break;
case 1:
this.s = value;
break;
case 2:
this.v = value;
break;
case 3:
this.a = value;
break;
default:
throw new IndexOutOfRangeException("Invalid Vector3 index!");
}
}
}
public static bool operator ==(ColorHSV lhs, ColorHSV rhs) {
return lhs.Equals(rhs);
}
public static bool operator !=(ColorHSV lhs, ColorHSV rhs) {
return !(lhs == rhs);
}
public static implicit operator Vector4(ColorHSV c) {
return new Vector4(c.h, c.s, c.v, c.a);
}
public static implicit operator ColorHSV(Vector4 v) {
return new ColorHSV(v.x, v.y, v.z, v.w);
}
public static implicit operator ColorHSV(Color rgb) {
return RGB2HSV(rgb);
}
public static implicit operator Color(ColorHSV hsv) {
return HSV2RGB(hsv);
}
public static Color HSV2RGB(ColorHSV hsv) {
var rgb = Color.HSVToRGB(hsv.h, hsv.s, hsv.v, false);
rgb.a = hsv.a;
return rgb;
}
public static ColorHSV RGB2HSV(Color rgb) {
var hsv = new ColorHSV {a = rgb.a};
Color.RGBToHSV(rgb, out hsv.h, out hsv.s, out hsv.v);
return hsv;
}
}
}
Loading…
Cancel
Save