-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #258 from DMagic1/dev
Version 17.2
- Loading branch information
Showing
128 changed files
with
5,845 additions
and
3,609 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
"MAJOR":1, | ||
"MINOR":1, | ||
"PATCH":7, | ||
"BUILD":1 | ||
"BUILD":2 | ||
}, | ||
"KSP_VERSION":{ | ||
"MAJOR":1, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using UnityEngine; | ||
|
||
namespace SCANsat.Unity.HSVPicker.Enum | ||
{ | ||
public enum ColorValues | ||
{ | ||
R, | ||
G, | ||
B, | ||
A, | ||
|
||
Hue, | ||
Saturation, | ||
Value, | ||
|
||
Hex | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using UnityEngine; | ||
using System; | ||
using UnityEngine.Events; | ||
|
||
namespace SCANsat.Unity.HSVPicker.Events | ||
{ | ||
[Serializable] | ||
public class ColorChangedEvent : UnityEvent<Color> | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using UnityEngine; | ||
using UnityEngine.Events; | ||
|
||
namespace SCANsat.Unity.HSVPicker.Events | ||
{ | ||
public class HSVChangedEvent : UnityEvent<float, float, float> | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
using System.Collections; | ||
|
||
namespace SCANsat.Unity.HSVPicker.UI | ||
{ | ||
[RequireComponent(typeof(Image))] | ||
public class ColorImage : MonoBehaviour | ||
{ | ||
public ColorPicker picker; | ||
private bool _isActive; | ||
|
||
private Image image; | ||
|
||
public bool IsActive | ||
{ | ||
get { return _isActive; } | ||
set { _isActive = value; } | ||
} | ||
|
||
public Color CurrentColor | ||
{ | ||
get { return image.color; } | ||
} | ||
|
||
private void Awake() | ||
{ | ||
image = GetComponent<Image>(); | ||
picker.onValueChanged.AddListener(ColorChanged); | ||
} | ||
|
||
private void OnDestroy() | ||
{ | ||
picker.onValueChanged.RemoveListener(ColorChanged); | ||
} | ||
|
||
private void ColorChanged(Color newColor) | ||
{ | ||
if (_isActive) | ||
image.color = newColor; | ||
} | ||
|
||
public void SetColor(Color newColor) | ||
{ | ||
image.color = newColor; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
using System; | ||
using SCANsat.Unity.HSVPicker.Enum; | ||
|
||
namespace SCANsat.Unity.HSVPicker.UI | ||
{ | ||
/// <summary> | ||
/// Displays one of the color values of aColorPicker | ||
/// </summary> | ||
[RequireComponent(typeof(InputField))] | ||
public class ColorInput : MonoBehaviour | ||
{ | ||
public ColorPicker hsvpicker; | ||
|
||
/// <summary> | ||
/// Which value this slider can edit. | ||
/// </summary> | ||
public ColorValues type; | ||
|
||
private InputField inputField; | ||
|
||
private void Awake() | ||
{ | ||
inputField = GetComponent<InputField>(); | ||
|
||
inputField.onValueChanged.AddListener(InputChanged); | ||
} | ||
|
||
private void OnDestroy() | ||
{ | ||
inputField.onValueChanged.RemoveListener(InputChanged); | ||
} | ||
|
||
private void InputChanged(string input) | ||
{ | ||
if (string.IsNullOrEmpty(input)) | ||
return; | ||
|
||
float original = 0; | ||
|
||
switch(type) | ||
{ | ||
case ColorValues.R: | ||
original = hsvpicker.R; | ||
break; | ||
case ColorValues.G: | ||
original = hsvpicker.G; | ||
break; | ||
case ColorValues.B: | ||
original = hsvpicker.B; | ||
break; | ||
} | ||
|
||
float f = original; | ||
|
||
if (!float.TryParse(input, out f)) | ||
return; | ||
|
||
if (f < 0) | ||
return; | ||
else if (input.StartsWith("1.")) | ||
f = 1; | ||
else if (f >= 1 && f <= 255) | ||
{ | ||
f = Mathf.RoundToInt(f); | ||
|
||
f /= 255; | ||
} | ||
else if (f > 255) | ||
return; | ||
|
||
hsvpicker.AssignColor(type, f); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
using System; | ||
using SCANsat.Unity.HSVPicker.Enum; | ||
|
||
namespace SCANsat.Unity.HSVPicker.UI | ||
{ | ||
[RequireComponent(typeof(TextHandler))] | ||
public class ColorLabel : MonoBehaviour | ||
{ | ||
public ColorPicker picker; | ||
public ColorValues type; | ||
|
||
private TextHandler label; | ||
|
||
private void Awake() | ||
{ | ||
label = GetComponent<TextHandler>(); | ||
} | ||
|
||
private void OnEnable() | ||
{ | ||
if (Application.isPlaying && picker != null) | ||
{ | ||
picker.onValueChanged.AddListener(ColorChanged); | ||
picker.onHSVChanged.AddListener(HSVChanged); | ||
} | ||
} | ||
|
||
private void OnDestroy() | ||
{ | ||
if (picker != null) | ||
{ | ||
picker.onValueChanged.RemoveListener(ColorChanged); | ||
picker.onHSVChanged.RemoveListener(HSVChanged); | ||
} | ||
} | ||
|
||
private void ColorChanged(Color color) | ||
{ | ||
UpdateValue(); | ||
} | ||
|
||
private void HSVChanged(float hue, float sateration, float value) | ||
{ | ||
UpdateValue(); | ||
} | ||
|
||
private void UpdateValue() | ||
{ | ||
if (picker == null) | ||
{ | ||
label.OnTextUpdate.Invoke("-"); | ||
} | ||
else | ||
{ | ||
float valueOne = 0; | ||
float valueTwo = 0; | ||
float valueThree = 0; | ||
|
||
|
||
if (type == ColorValues.R) | ||
{ | ||
valueOne = picker.GetValue(ColorValues.R) * 255; | ||
valueTwo = picker.GetValue(ColorValues.G) * 255; | ||
valueThree = picker.GetValue(ColorValues.B) * 255; | ||
|
||
label.OnTextUpdate.Invoke(string.Format("{0:N0},{1:N0},{2:N0}", Mathf.FloorToInt(valueOne), Mathf.FloorToInt(valueTwo), Mathf.FloorToInt(valueThree))); | ||
} | ||
else if (type == ColorValues.Hue) | ||
{ | ||
valueOne = picker.GetValue(ColorValues.Hue) * 360; | ||
valueTwo = picker.GetValue(ColorValues.Saturation) * 255; | ||
valueThree = picker.GetValue(ColorValues.Value) * 255; | ||
|
||
label.OnTextUpdate.Invoke(string.Format("{0:N0},{1:N0},{2:N0}", Mathf.FloorToInt(valueOne), Mathf.FloorToInt(valueTwo), Mathf.FloorToInt(valueThree))); | ||
} | ||
else if (type == ColorValues.Hex) | ||
{ | ||
valueOne = picker.GetValue(ColorValues.R) * 255; | ||
valueTwo = picker.GetValue(ColorValues.G) * 255; | ||
valueThree = picker.GetValue(ColorValues.B) * 255; | ||
|
||
label.OnTextUpdate.Invoke(string.Format("#{0:X2}{1:X2}{2:X2}", Mathf.FloorToInt(valueOne), Mathf.FloorToInt(valueTwo), Mathf.FloorToInt(valueThree))); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.