using System.Collections; using System.Collections.Generic; using Dreamteck.Splines; using UnityEngine; namespace Demo.Game { public class SplineNode : ScriptableObject { public static SplineNode Make() { return new GameObject("", typeof(Node)).AddComponent(); } public Node MyNode; public float NodeSize = 1; public Color NodeColor = Color.white; public bool IsSetupNodeRotation = false; public Vector3 NodeRotation = Vector3.zero; public int MyNodeContent = 0; public override IEnumerator LoadScript(string script) { MyNode = GetComponent(); yield return base.LoadScript(script); } public void AddTo(SplineCore core) { MyNodeContent = core.NodeContent; core.MySplineComputer.SetPointColor(MyNodeContent, NodeColor); core.MySplineComputer.SetPointSize(MyNodeContent, NodeSize); core.MySplineComputer.SetPointNormal(MyNodeContent, IsSetupNodeRotation ? NodeRotation.normalized : transform.up); MyNode.AddConnection(core.MySplineComputer, MyNodeContent); } /// /// 设置节点大小,默认为1 /// /// [ScriptableCall(@" 设置节点大小,默认为1 ")] public void SetNodeSize(string size) { NodeSize = Parse(size); } /// /// 设置节点颜色,默认为(1,1,1,1) /// /// /// /// /// [ScriptableCall(@" 设置节点颜色,默认为(1,1,1,1) ")] public void SetNodeColor(string r, string g, string b, string a) { NodeColor = new(Parse(r), Parse(g), Parse(b), Parse(a)); } /// /// 设置节点旋转,节点正面forward向量为法线 /// /// /// /// [ScriptableCall(@" 设置节点旋转,节点正面forward向量为法线 ")] public void SetNodeRotation(string x, string y, string z) { IsSetupNodeRotation = true; this.transform.localEulerAngles = NodeRotation = new(Parse(x), Parse(y), Parse(z)); } } }