-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
113 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using UnityEngine; | ||
|
||
namespace Klak.Wiring | ||
{ | ||
[AddComponentMenu("Klak/Wiring/Convertion/Component Vector")] | ||
public class ComponentVector : NodeBase | ||
{ | ||
#region Editable properties | ||
|
||
[SerializeField] | ||
Vector3 _vector; | ||
public Vector3 vector { | ||
get { return _vector; } | ||
set { _vector = value; } | ||
} | ||
|
||
#endregion | ||
|
||
#region Node I/O | ||
|
||
[Inlet] | ||
public float x { | ||
set { | ||
if (!enabled) return; | ||
_vector.x = value; | ||
} | ||
} | ||
|
||
[Inlet] | ||
public float y { | ||
set { | ||
if (!enabled) return; | ||
_vector.y = value; | ||
} | ||
} | ||
|
||
[Inlet] | ||
public float z { | ||
set { | ||
if (!enabled) return; | ||
_vector.z = value; | ||
} | ||
} | ||
|
||
[SerializeField, Outlet] | ||
Vector3Event _vectorEvent = new Vector3Event(); | ||
|
||
#endregion | ||
|
||
Vector3 _prevVector; | ||
|
||
#region Monobehaviour | ||
|
||
void Update() | ||
{ | ||
if (_vector != _prevVector) | ||
{ | ||
_vectorEvent.Invoke(_vector); | ||
_prevVector = _vector; | ||
} | ||
} | ||
|
||
#endregion | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,24 @@ | ||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
namespace Klak.Wiring | ||
{ | ||
[CanEditMultipleObjects] | ||
[CustomEditor(typeof(ComponentVector))] | ||
public class ComponentVectorEditor : Editor { | ||
|
||
public override bool RequiresConstantRepaint() | ||
{ | ||
return true; | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
serializedObject.Update(); | ||
|
||
DrawPropertiesExcluding(serializedObject, new string[] {"m_Script"}); | ||
|
||
serializedObject.ApplyModifiedProperties(); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Assets/Klak/Wiring/Editor/Basic/ComponentVectorEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.