69 lines
1.8 KiB
C#
69 lines
1.8 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using Convention;
|
|||
|
|
using Dreamteck.Splines;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
namespace Demo.Game
|
|||
|
|
{
|
|||
|
|
public class SplineTubeRenderer : BasicSplineRenderer<TubeGenerator>
|
|||
|
|
{
|
|||
|
|
public static SplineTubeRenderer Make()
|
|||
|
|
{
|
|||
|
|
return new GameObject().AddComponent<SplineTubeRenderer>();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[Content] public bool IsDoubleSide = true;
|
|||
|
|
[Content] public int SidesCount = 12;
|
|||
|
|
|
|||
|
|
public override IEnumerator LoadScript(string script)
|
|||
|
|
{
|
|||
|
|
MyLineMaterial = Resources.Load<Material>("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();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 禁用双面渲染,用于优化性能
|
|||
|
|
/// </summary>
|
|||
|
|
[ScriptableCall(@"
|
|||
|
|
<summary>
|
|||
|
|
禁用双面渲染,用于优化性能
|
|||
|
|
</summary>
|
|||
|
|
")]
|
|||
|
|
public void DisableDoubleSide()
|
|||
|
|
{
|
|||
|
|
IsDoubleSide = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 设置面数,越高越圆润
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sides"></param>
|
|||
|
|
[ScriptableCall(@"
|
|||
|
|
<summary>
|
|||
|
|
设置面数,越高越圆润
|
|||
|
|
</summary>
|
|||
|
|
<param name=""sides""></param>
|
|||
|
|
")]
|
|||
|
|
public void SetSides(int sides)
|
|||
|
|
{
|
|||
|
|
SidesCount = Mathf.Min(3, sides);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|