diff --git a/Assets/Klak/Wiring/Editor/Output/IntegerOutEditor.cs b/Assets/Klak/Wiring/Editor/Output/IntegerOutEditor.cs new file mode 100644 index 0000000..7ea7569 --- /dev/null +++ b/Assets/Klak/Wiring/Editor/Output/IntegerOutEditor.cs @@ -0,0 +1,33 @@ +// +// Klak - Utilities for creative coding with Unity +// +// Copyright (C) 2016 Keijiro Takahashi +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +using UnityEngine; +using UnityEditor; + +namespace Klak.Wiring +{ + [CustomEditor(typeof(IntegerOut))] + public class IntegerOutEditor : GenericOutEditor + { + } +} diff --git a/Assets/Klak/Wiring/Output/IntegerOut.cs b/Assets/Klak/Wiring/Output/IntegerOut.cs new file mode 100644 index 0000000..0b89683 --- /dev/null +++ b/Assets/Klak/Wiring/Output/IntegerOut.cs @@ -0,0 +1,66 @@ +// +// Klak - Utilities for creative coding with Unity +// +// Copyright (C) 2016 Keijiro Takahashi +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +using UnityEngine; +using System.Reflection; + +namespace Klak.Wiring +{ + [AddComponentMenu("Klak/Wiring/Output/Generic/Integer Out")] + public class IntegerOut : NodeBase + { + #region Editable properties + + [SerializeField] + Component _target; + + [SerializeField] + string _propertyName; + + #endregion + + #region Node I/O + + [Inlet] + public int input { + set { + if (!enabled || _target == null || _propertyInfo == null) return; + _propertyInfo.SetValue(_target, value, null); + } + } + + #endregion + + #region Private members + + PropertyInfo _propertyInfo; + + void OnEnable() + { + if (_target == null || string.IsNullOrEmpty(_propertyName)) return; + _propertyInfo = _target.GetType().GetProperty(_propertyName); + } + + #endregion + } +} diff --git a/Assets/Klak/Wiring/System/NodeBase.cs b/Assets/Klak/Wiring/System/NodeBase.cs index 492a698..a128385 100644 --- a/Assets/Klak/Wiring/System/NodeBase.cs +++ b/Assets/Klak/Wiring/System/NodeBase.cs @@ -57,6 +57,9 @@ public class VoidEvent : UnityEvent {} [Serializable] public class FloatEvent : UnityEvent {} + [Serializable] + public class IntegerEvent: UnityEvent {} + [Serializable] public class Vector3Event : UnityEvent {}