Skip to content

Commit 1242128

Browse files
committed
Added HSBColor, BangFilter and RandomValue.
1 parent b041da9 commit 1242128

File tree

12 files changed

+350
-0
lines changed

12 files changed

+350
-0
lines changed

Assets/Klak/Wiring/Basic/HSBColor.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Klak - Creative coding library for Unity
2+
// https://github.com/keijiro/Klak
3+
4+
using UnityEngine;
5+
6+
namespace Klak.Wiring
7+
{
8+
[AddComponentMenu("Klak/Wiring/Convertion/HSB Color")]
9+
public class HSBColor : NodeBase
10+
{
11+
#region Editable properties
12+
13+
[SerializeField, Range(0, 1)]
14+
float _hue = 0;
15+
16+
[SerializeField, Range(0, 1)]
17+
float _saturation = 1;
18+
19+
[SerializeField]
20+
float _brightness = 1;
21+
22+
#endregion
23+
24+
#region Node I/O
25+
26+
[Inlet]
27+
public float hue {
28+
set {
29+
_hue = value;
30+
if (enabled) UpdateAndInvoke();
31+
}
32+
}
33+
34+
[Inlet]
35+
public float saturation {
36+
set {
37+
_saturation = value;
38+
if (enabled) UpdateAndInvoke();
39+
}
40+
}
41+
42+
[Inlet]
43+
public float brightness {
44+
set {
45+
_brightness = value;
46+
if (enabled) UpdateAndInvoke();
47+
}
48+
}
49+
50+
[SerializeField, Outlet]
51+
ColorEvent _colorEvent = new ColorEvent();
52+
53+
#endregion
54+
55+
#region Private members
56+
57+
void UpdateAndInvoke()
58+
{
59+
_colorEvent.Invoke(Color.HSVToRGB(_hue, _saturation, _brightness));
60+
}
61+
62+
#endregion
63+
}
64+
}

Assets/Klak/Wiring/Basic/HSBColor.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Klak - Creative coding library for Unity
2+
// https://github.com/keijiro/Klak
3+
4+
using UnityEngine;
5+
using UnityEditor;
6+
7+
namespace Klak.Wiring
8+
{
9+
[CanEditMultipleObjects]
10+
[CustomEditor(typeof(HSBColor))]
11+
public class HSBColorEditor : Editor
12+
{
13+
SerializedProperty _hue;
14+
SerializedProperty _saturation;
15+
SerializedProperty _brightness;
16+
SerializedProperty _colorEvent;
17+
18+
static GUIContent _textHue = new GUIContent("Initial Hue");
19+
static GUIContent _textSaturation = new GUIContent("Initial Saturation");
20+
static GUIContent _textBrightness = new GUIContent("Initial Brightness");
21+
22+
void OnEnable()
23+
{
24+
_hue = serializedObject.FindProperty("_hue");
25+
_saturation = serializedObject.FindProperty("_saturation");
26+
_brightness = serializedObject.FindProperty("_brightness");
27+
_colorEvent = serializedObject.FindProperty("_colorEvent");
28+
}
29+
30+
public override void OnInspectorGUI()
31+
{
32+
serializedObject.Update();
33+
34+
EditorGUILayout.PropertyField(_hue, _textHue);
35+
EditorGUILayout.PropertyField(_saturation, _textSaturation);
36+
EditorGUILayout.PropertyField(_brightness, _textBrightness);
37+
38+
EditorGUILayout.Space();
39+
40+
EditorGUILayout.PropertyField(_colorEvent);
41+
42+
serializedObject.ApplyModifiedProperties();
43+
}
44+
}
45+
}

Assets/Klak/Wiring/Editor/Basic/HSBColorEditor.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Klak - Creative coding library for Unity
2+
// https://github.com/keijiro/Klak
3+
4+
using UnityEngine;
5+
using UnityEditor;
6+
7+
namespace Klak.Wiring
8+
{
9+
[CanEditMultipleObjects]
10+
[CustomEditor(typeof(BangFilter))]
11+
public class BangFilterEditor : Editor
12+
{
13+
SerializedProperty _state;
14+
SerializedProperty _bangEvent;
15+
16+
static GUIContent _textInitialState = new GUIContent("Opened");
17+
18+
void OnEnable()
19+
{
20+
_state = serializedObject.FindProperty("_state");
21+
_bangEvent = serializedObject.FindProperty("_bangEvent");
22+
}
23+
24+
public override void OnInspectorGUI()
25+
{
26+
serializedObject.Update();
27+
28+
EditorGUILayout.PropertyField(_state, _textInitialState);
29+
30+
EditorGUILayout.Space();
31+
32+
EditorGUILayout.PropertyField(_bangEvent);
33+
34+
serializedObject.ApplyModifiedProperties();
35+
}
36+
}
37+
}

Assets/Klak/Wiring/Editor/Filter/BangFilterEditor.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Klak - Creative coding library for Unity
2+
// https://github.com/keijiro/Klak
3+
4+
using UnityEngine;
5+
using UnityEditor;
6+
7+
namespace Klak.Wiring
8+
{
9+
[CanEditMultipleObjects]
10+
[CustomEditor(typeof(RandomValue))]
11+
public class RandomValueEditor : Editor
12+
{
13+
SerializedProperty _minimum;
14+
SerializedProperty _maximum;
15+
SerializedProperty _sendOnStartUp;
16+
SerializedProperty _outputEvent;
17+
18+
void OnEnable()
19+
{
20+
_minimum = serializedObject.FindProperty("_minimum");
21+
_maximum = serializedObject.FindProperty("_maximum");
22+
_sendOnStartUp = serializedObject.FindProperty("_sendOnStartUp");
23+
_outputEvent = serializedObject.FindProperty("_outputEvent");
24+
}
25+
26+
public override void OnInspectorGUI()
27+
{
28+
serializedObject.Update();
29+
30+
EditorGUILayout.PropertyField(_minimum);
31+
EditorGUILayout.PropertyField(_maximum);
32+
EditorGUILayout.PropertyField(_sendOnStartUp);
33+
34+
EditorGUILayout.Space();
35+
36+
EditorGUILayout.PropertyField(_outputEvent);
37+
38+
serializedObject.ApplyModifiedProperties();
39+
}
40+
}
41+
}

Assets/Klak/Wiring/Editor/Input/RandomValueEditor.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Klak - Creative coding library for Unity
2+
// https://github.com/keijiro/Klak
3+
4+
using UnityEngine;
5+
6+
namespace Klak.Wiring
7+
{
8+
[AddComponentMenu("Klak/Wiring/Filter/Bang Filter")]
9+
public class BangFilter : NodeBase
10+
{
11+
#region Editable properties
12+
13+
[SerializeField]
14+
bool _state;
15+
16+
#endregion
17+
18+
#region Node I/O
19+
20+
[Inlet]
21+
public void Bang()
22+
{
23+
if (_state) _bangEvent.Invoke();
24+
}
25+
26+
[Inlet]
27+
public void Open()
28+
{
29+
_state = true;
30+
}
31+
32+
[Inlet]
33+
public void Close()
34+
{
35+
_state = false;
36+
}
37+
38+
[SerializeField, Outlet]
39+
VoidEvent _bangEvent = new VoidEvent();
40+
41+
#endregion
42+
}
43+
}

Assets/Klak/Wiring/Filter/BangFilter.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)