It's an experimental project, I'm still not happy with the way nodes are created, a simple node like SetPosition ends up having 35 lines, and that's not what I want. I'll keep experimenting and see what I can get.
using UnityEngine; public class GetElapsedTimeNode : Node { private void Start() { SetTitle("Get Elapsed Time"); AddParameterOutput<float>((_) => Time.time); } }
using UnityEngine; public class CosNode : Node { private void Start() { SetTitle("Cos"); var rad = AddParameterInput<float>((socket) => (float) (socket.Connection ? socket.Connection.Evaluate : default(float)), "Rad"); AddParameterOutput<float>((socket) => Mathf.Cos((float) rad.Evaluate), "Cos"); } }
using UnityEngine; public class SetPositionNode : Node { private Socket _target; private Socket _x; private Socket _y; private Socket _z; private Socket _next; private void Start() { SetTitle("Set Position"); AddExecutionInput((socket) => SetPosition()); _next = AddExecutionOutput((socket) => { socket.Connection?.Execute(); }); _target = AddParameterInput<GameObject>((socket) => (GameObject) (socket.Connection ? socket.Connection.Evaluate : null), "Target"); _x = AddParameterInput<float>((socket) => (float) (socket.Connection ? socket.Connection.Evaluate : default(float)), "X"); _y = AddParameterInput<float>((socket) => (float) (socket.Connection ? socket.Connection.Evaluate : default(float)), "Y"); _z = AddParameterInput<float>((socket) => (float) (socket.Connection ? socket.Connection.Evaluate : default(float)), "Z"); } private void SetPosition() { var target = (GameObject) _target.Evaluate; if (target != null) { var position = new Vector3((float) _x.Evaluate, (float) _y.Evaluate, (float) _z.Evaluate); target.transform.position = position; } _next.Execute(); } }
Here’s how we suggest you go about proposing a change to this project:
- Fork this project to your account.
- Create a branch for the change you intend to make.
- Make your changes to your fork.
- Send a pull request from your fork’s branch to our
master
branch.
Using the web-based interface to make changes is fine too, and will help you by automatically forking the project and prompting to send a pull request too.