1.修复一些错误2.准备专门提供基于距离的spline3.tracydll存在崩溃问题
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
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>();
|
||||
}
|
||||
|
||||
public const bool DefaultIsDoubleSide = true;
|
||||
public const int DefaultSidesCount = 12;
|
||||
[Content] public bool IsDoubleSide = DefaultIsDoubleSide;
|
||||
[Content] public int SidesCount = DefaultSidesCount;
|
||||
|
||||
protected override IEnumerator DoSomethingDuringApplyScript()
|
||||
{
|
||||
if (MyDefaultMaterial == null)
|
||||
MyDefaultMaterial = Resources.Load<Material>("Tube/Default");
|
||||
yield return base.DoSomethingDuringApplyScript();
|
||||
}
|
||||
|
||||
public override void SetupMeshGenerator(TubeGenerator meshGenerater)
|
||||
{
|
||||
base.SetupMeshGenerator(meshGenerater);
|
||||
meshGenerater.doubleSided = IsDoubleSide;
|
||||
meshGenerater.sides = SidesCount;
|
||||
}
|
||||
|
||||
public override IEnumerator UnloadScript()
|
||||
{
|
||||
yield return base.UnloadScript();
|
||||
// Reset
|
||||
{
|
||||
IsDoubleSide = DefaultIsDoubleSide;
|
||||
SidesCount = DefaultSidesCount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 禁用双面渲染,用于优化性能
|
||||
/// </summary>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void DisableDoubleSide()
|
||||
{
|
||||
IsDoubleSide = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置面数,越高越圆润
|
||||
/// </summary>
|
||||
/// <param name="sides"></param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetSides(int sides)
|
||||
{
|
||||
SidesCount = Mathf.Min(3, sides);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user