推进同化RScript
This commit is contained in:
@@ -22,12 +22,37 @@ namespace Demo.Game
|
||||
public abstract class BasicSplineRenderer : Updatement<SplineClipDuration>, IAssetBundleLoader, IDependOnSplineCore
|
||||
{
|
||||
[Content] public SplineCore MySplineCore { get; set; }
|
||||
[Content] public MeshRenderer MyMeshRenderer;
|
||||
[Content] private MeshFilter m_MeshFilter;
|
||||
[Content] private MeshRenderer m_MyMeshRenderer;
|
||||
[Header("LineRenderer.Material")]
|
||||
[Content] public string LinesAssetBundlePath;
|
||||
[Content] public AssetBundle LinesAssetBundle;
|
||||
[Content] public string LineMaterial;
|
||||
[Content] public Material MyLineMaterial;
|
||||
[Content] public Material LineDefaultMaterial;
|
||||
|
||||
public override void ResetEnterGameStatus()
|
||||
{
|
||||
base.ResetEnterGameStatus();
|
||||
MyMeshRenderer.material = LineDefaultMaterial;
|
||||
}
|
||||
|
||||
public MeshFilter MyMeshFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_MeshFilter == null)
|
||||
m_MeshFilter = this.GetOrAddComponent<MeshFilter>();
|
||||
return m_MeshFilter;
|
||||
}
|
||||
}
|
||||
public MeshRenderer MyMeshRenderer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_MyMeshRenderer == null)
|
||||
m_MyMeshRenderer = this.GetOrAddComponent<MeshRenderer>();
|
||||
return m_MyMeshRenderer;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract Vector3 EvaluateClipFromPosition(float time);
|
||||
|
||||
@@ -37,26 +62,6 @@ namespace Demo.Game
|
||||
|
||||
public abstract SplineSample EvaluateClipTo(float time);
|
||||
|
||||
public override IEnumerator LoadScript(string script)
|
||||
{
|
||||
yield return base.LoadScript(script);
|
||||
// Bind and Init Spline
|
||||
var splineGameObject = MySplineCore.gameObject;
|
||||
this.GetOrAddComponent<MeshFilter>();
|
||||
MyMeshRenderer = this.GetOrAddComponent<MeshRenderer>();
|
||||
MyMeshRenderer.enabled = true;
|
||||
if (string.IsNullOrEmpty(LinesAssetBundlePath) == false)
|
||||
{
|
||||
var ir = LinesAssetBundle.LoadAssetAsync<Material>(LineMaterial);
|
||||
ir.completed += x =>
|
||||
{
|
||||
MyLineMaterial = ir.asset as Material;
|
||||
};
|
||||
yield return ir;
|
||||
}
|
||||
MyMeshRenderer.material = MyLineMaterial;
|
||||
}
|
||||
|
||||
public override IEnumerator UnloadScript()
|
||||
{
|
||||
if (string.IsNullOrEmpty(LinesAssetBundlePath) == false)
|
||||
@@ -73,15 +78,15 @@ namespace Demo.Game
|
||||
/// <param name="to"></param>
|
||||
/// <param name="curveType">可取值为30种缓动曲线</param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void Add(string time, float from, float to, string curveType)
|
||||
public void Add(float time, float from, float to, string curveType)
|
||||
{
|
||||
ManualAddEntry(time, new(from, to), Enum.Parse<MathExtension.EaseCurveType>(curveType));
|
||||
}
|
||||
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public IEnumerator LoadSpline(string path)
|
||||
public void LoadSpline(string path)
|
||||
{
|
||||
yield return this.LoadSplineTool(path);
|
||||
this.LoadSplineTool(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,14 +102,15 @@ namespace Demo.Game
|
||||
/// <param name="ab"></param>
|
||||
/// <param name="material"></param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public IEnumerator LoadMaterial(string ab, string material)
|
||||
public void LoadMaterial(string ab, string material)
|
||||
{
|
||||
yield return this.LoadAssetBundle(ab, x =>
|
||||
{
|
||||
LinesAssetBundlePath = ab;
|
||||
LinesAssetBundle = x;
|
||||
LineMaterial = material;
|
||||
});
|
||||
MyMeshRenderer.enabled = true;
|
||||
LinesAssetBundlePath = ab;
|
||||
this.LoadAssetBundle(ab, x =>
|
||||
{
|
||||
LinesAssetBundle = x;
|
||||
LineDefaultMaterial = LinesAssetBundle.LoadAsset<Material>(material);
|
||||
});
|
||||
}
|
||||
|
||||
protected override SplineClipDuration Lerp(SplineClipDuration begin, SplineClipDuration end, float t)
|
||||
@@ -117,11 +123,9 @@ namespace Demo.Game
|
||||
{
|
||||
[Content] public TMeshGenerator MyMeshGenerator;
|
||||
|
||||
public override IEnumerator LoadScript(string script)
|
||||
protected override IEnumerator DoSomethingDuringApplyScript()
|
||||
{
|
||||
yield return base.LoadScript(script);
|
||||
// Setup Mesh Generater
|
||||
MyMeshRenderer.material = MyLineMaterial;
|
||||
yield return base.DoSomethingDuringApplyScript();
|
||||
MyMeshGenerator = this.GetOrAddComponent<TMeshGenerator>();
|
||||
MyMeshGenerator.spline = MySplineCore.MySplineComputer;
|
||||
SetupMeshGenerator(MyMeshGenerator);
|
||||
@@ -142,9 +146,9 @@ namespace Demo.Game
|
||||
/// </summary>
|
||||
/// <param name="mode">Clip, UniformClip, Clamp, UniformClamp</param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetUVMode(string mode)
|
||||
public void SetUVMode(MeshGenerator.UVMode mode)
|
||||
{
|
||||
MyUVMode = Enum.Parse<MeshGenerator.UVMode>(mode);
|
||||
MyUVMode = mode;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user