using System; using System.Collections; using Convention; using Dreamteck.Splines; using Dreamteck.Splines.Editor; using UnityEngine; namespace Demo.Game { public class SplineTubeRenderer : BasicSplineRenderer { public static SplineTubeRenderer Make() { return new GameObject().AddComponent(); } [Content] public bool IsDoubleSide = true; [Content] public int SidesCount = 12; public override IEnumerator LoadScript(string script) { MyLineMaterial = Resources.Load("Tube/Default"); yield return base.LoadScript(script); } public override void SetupMeshGenerator(TubeGenerator meshGenerater) { base.SetupMeshGenerator(meshGenerater); meshGenerater.doubleSided = IsDoubleSide; meshGenerater.sides = SidesCount; } public override IEnumerator UnloadScript() { if (string.IsNullOrEmpty(LinesAssetBundlePath) == false) yield return this.UnloadAssetBundle(LinesAssetBundlePath); LinesAssetBundlePath = ""; yield return base.UnloadScript(); } /// /// 禁用双面渲染,用于优化性能 /// [ScriptableCall(@" 禁用双面渲染,用于优化性能 ")] public void DisableDoubleSide() { IsDoubleSide = false; } /// /// 设置面数,越高越圆润 /// /// [ScriptableCall(@" 设置面数,越高越圆润 ")] public void SetSides(int sides) { SidesCount = Mathf.Min(3, sides); } } }