-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Klak - Creative coding library for Unity | ||
// https://github.com/keijiro/Klak | ||
|
||
using UnityEngine; | ||
|
||
namespace Klak.Wiring | ||
{ | ||
[AddComponentMenu("Klak/Wiring/Convertion/HSB Color")] | ||
public class HSBColor : NodeBase | ||
{ | ||
#region Editable properties | ||
|
||
[SerializeField, Range(0, 1)] | ||
float _hue = 0; | ||
|
||
[SerializeField, Range(0, 1)] | ||
float _saturation = 1; | ||
|
||
[SerializeField] | ||
float _brightness = 1; | ||
|
||
#endregion | ||
|
||
#region Node I/O | ||
|
||
[Inlet] | ||
public float hue { | ||
set { | ||
_hue = value; | ||
if (enabled) UpdateAndInvoke(); | ||
} | ||
} | ||
|
||
[Inlet] | ||
public float saturation { | ||
set { | ||
_saturation = value; | ||
if (enabled) UpdateAndInvoke(); | ||
} | ||
} | ||
|
||
[Inlet] | ||
public float brightness { | ||
set { | ||
_brightness = value; | ||
if (enabled) UpdateAndInvoke(); | ||
} | ||
} | ||
|
||
[SerializeField, Outlet] | ||
ColorEvent _colorEvent = new ColorEvent(); | ||
|
||
#endregion | ||
|
||
#region Private members | ||
|
||
void UpdateAndInvoke() | ||
{ | ||
_colorEvent.Invoke(Color.HSVToRGB(_hue, _saturation, _brightness)); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Klak - Creative coding library for Unity | ||
// https://github.com/keijiro/Klak | ||
|
||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
namespace Klak.Wiring | ||
{ | ||
[CanEditMultipleObjects] | ||
[CustomEditor(typeof(HSBColor))] | ||
public class HSBColorEditor : Editor | ||
{ | ||
SerializedProperty _hue; | ||
SerializedProperty _saturation; | ||
SerializedProperty _brightness; | ||
SerializedProperty _colorEvent; | ||
|
||
static GUIContent _textHue = new GUIContent("Initial Hue"); | ||
static GUIContent _textSaturation = new GUIContent("Initial Saturation"); | ||
static GUIContent _textBrightness = new GUIContent("Initial Brightness"); | ||
|
||
void OnEnable() | ||
{ | ||
_hue = serializedObject.FindProperty("_hue"); | ||
_saturation = serializedObject.FindProperty("_saturation"); | ||
_brightness = serializedObject.FindProperty("_brightness"); | ||
_colorEvent = serializedObject.FindProperty("_colorEvent"); | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
serializedObject.Update(); | ||
|
||
EditorGUILayout.PropertyField(_hue, _textHue); | ||
EditorGUILayout.PropertyField(_saturation, _textSaturation); | ||
EditorGUILayout.PropertyField(_brightness, _textBrightness); | ||
|
||
EditorGUILayout.Space(); | ||
|
||
EditorGUILayout.PropertyField(_colorEvent); | ||
|
||
serializedObject.ApplyModifiedProperties(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Klak - Creative coding library for Unity | ||
// https://github.com/keijiro/Klak | ||
|
||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
namespace Klak.Wiring | ||
{ | ||
[CanEditMultipleObjects] | ||
[CustomEditor(typeof(BangFilter))] | ||
public class BangFilterEditor : Editor | ||
{ | ||
SerializedProperty _state; | ||
SerializedProperty _bangEvent; | ||
|
||
static GUIContent _textInitialState = new GUIContent("Opened"); | ||
|
||
void OnEnable() | ||
{ | ||
_state = serializedObject.FindProperty("_state"); | ||
_bangEvent = serializedObject.FindProperty("_bangEvent"); | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
serializedObject.Update(); | ||
|
||
EditorGUILayout.PropertyField(_state, _textInitialState); | ||
|
||
EditorGUILayout.Space(); | ||
|
||
EditorGUILayout.PropertyField(_bangEvent); | ||
|
||
serializedObject.ApplyModifiedProperties(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Klak - Creative coding library for Unity | ||
// https://github.com/keijiro/Klak | ||
|
||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
namespace Klak.Wiring | ||
{ | ||
[CanEditMultipleObjects] | ||
[CustomEditor(typeof(RandomValue))] | ||
public class RandomValueEditor : Editor | ||
{ | ||
SerializedProperty _minimum; | ||
SerializedProperty _maximum; | ||
SerializedProperty _sendOnStartUp; | ||
SerializedProperty _outputEvent; | ||
|
||
void OnEnable() | ||
{ | ||
_minimum = serializedObject.FindProperty("_minimum"); | ||
_maximum = serializedObject.FindProperty("_maximum"); | ||
_sendOnStartUp = serializedObject.FindProperty("_sendOnStartUp"); | ||
_outputEvent = serializedObject.FindProperty("_outputEvent"); | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
serializedObject.Update(); | ||
|
||
EditorGUILayout.PropertyField(_minimum); | ||
EditorGUILayout.PropertyField(_maximum); | ||
EditorGUILayout.PropertyField(_sendOnStartUp); | ||
|
||
EditorGUILayout.Space(); | ||
|
||
EditorGUILayout.PropertyField(_outputEvent); | ||
|
||
serializedObject.ApplyModifiedProperties(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Klak - Creative coding library for Unity | ||
// https://github.com/keijiro/Klak | ||
|
||
using UnityEngine; | ||
|
||
namespace Klak.Wiring | ||
{ | ||
[AddComponentMenu("Klak/Wiring/Filter/Bang Filter")] | ||
public class BangFilter : NodeBase | ||
{ | ||
#region Editable properties | ||
|
||
[SerializeField] | ||
bool _state; | ||
|
||
#endregion | ||
|
||
#region Node I/O | ||
|
||
[Inlet] | ||
public void Bang() | ||
{ | ||
if (_state) _bangEvent.Invoke(); | ||
} | ||
|
||
[Inlet] | ||
public void Open() | ||
{ | ||
_state = true; | ||
} | ||
|
||
[Inlet] | ||
public void Close() | ||
{ | ||
_state = false; | ||
} | ||
|
||
[SerializeField, Outlet] | ||
VoidEvent _bangEvent = new VoidEvent(); | ||
|
||
#endregion | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Klak - Creative coding library for Unity | ||
// https://github.com/keijiro/Klak | ||
|
||
using UnityEngine; | ||
|
||
namespace Klak.Wiring | ||
{ | ||
[AddComponentMenu("Klak/Wiring/Input/Random Value")] | ||
public class RandomValue : NodeBase | ||
{ | ||
#region Editable properties | ||
|
||
[SerializeField] | ||
float _minimum = 0; | ||
|
||
[SerializeField] | ||
float _maximum = 1; | ||
|
||
[SerializeField] | ||
bool _sendOnStartUp = false; | ||
|
||
#endregion | ||
|
||
#region Node I/O | ||
|
||
[Inlet] | ||
public void Bang() | ||
{ | ||
if (!enabled) return; | ||
|
||
_outputEvent.Invoke(Random.Range(_minimum, _maximum)); | ||
} | ||
|
||
[SerializeField, Outlet] | ||
FloatEvent _outputEvent = new FloatEvent(); | ||
|
||
#endregion | ||
|
||
#region MonoBehaviour functions | ||
|
||
void Start() | ||
{ | ||
if (_sendOnStartUp) Bang(); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.