自定义曲线编辑器, Trail界面跟进
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Lean.Pool;
|
||||
using UniRx;
|
||||
@@ -75,6 +76,25 @@ namespace Ichni.RhythmGame
|
||||
parentElement.matchedBM as GameElement_BM,
|
||||
trackPercent.ConvertToBM());
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
base.SetUpInspector();
|
||||
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
var container = inspector.GenerateContainer("Track Percent Point");
|
||||
var trackPercentButton = inspector.GenerateButton(this, container, "Track Percent", () =>
|
||||
{
|
||||
inspector.GenerateCompositeParameterWindow(this, "Track Percent", nameof(trackPercent)).SetAsFlexibleFloat();
|
||||
});
|
||||
|
||||
var generateTrailButton = inspector.GenerateButton(this, container, "Generate Trail", () =>
|
||||
{
|
||||
Trail.GenerateElement("New Trail", Guid.NewGuid(), new List<string>(),
|
||||
true, this, 1, true,
|
||||
1, AnimationCurve.Constant(0,1, 1));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -12,20 +13,32 @@ namespace Ichni.RhythmGame
|
||||
public Material renderMaterial;
|
||||
|
||||
public float visibleTimeLength;
|
||||
public bool isAutoOrient;
|
||||
public float widthMultiplier;
|
||||
public AnimationCurve widthCurve;
|
||||
|
||||
public TransformSubmodule transformSubmodule { get; set; }
|
||||
|
||||
public static Trail GenerateElement(string name, Guid id, List<string> tags, bool isFirstGenerated,
|
||||
GameElement parentElement, float visibleTimeLength, Material material = null)
|
||||
GameElement parentElement, float visibleTimeLength, bool isAutoOrient, float widthMultiplier,
|
||||
AnimationCurve widthCurve, Material material = null)
|
||||
{
|
||||
Trail trail = Instantiate(EditorManager.instance.basePrefabs.trail).GetComponent<Trail>();
|
||||
Trail trail = Instantiate(EditorManager.instance.basePrefabs.trail, parentElement.transform).GetComponent<Trail>();
|
||||
trail.trailRenderer = trail.GetComponent<TrailRenderer>();
|
||||
|
||||
trail.Initialize(name, id, tags, isFirstGenerated, parentElement);
|
||||
trail.renderMaterial =
|
||||
material == null ? EditorManager.instance.basePrefabs.defaultTrailMaterial : material;
|
||||
|
||||
trail.renderMaterial = material == null ? EditorManager.instance.basePrefabs.defaultTrailMaterial : material;
|
||||
trail.trailRenderer.material = trail.renderMaterial;
|
||||
trail.visibleTimeLength = visibleTimeLength;
|
||||
trail.isAutoOrient = isAutoOrient;
|
||||
trail.widthMultiplier = widthMultiplier;
|
||||
trail.widthCurve = widthCurve;
|
||||
|
||||
trail.trailRenderer.time = visibleTimeLength;
|
||||
trail.trailRenderer.alignment = isAutoOrient ? LineAlignment.View : LineAlignment.TransformZ;
|
||||
trail.trailRenderer.widthMultiplier = widthMultiplier;
|
||||
trail.trailRenderer.widthCurve = widthCurve;
|
||||
|
||||
return trail;
|
||||
}
|
||||
@@ -42,7 +55,25 @@ namespace Ichni.RhythmGame
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Trail_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
||||
visibleTimeLength, renderMaterial);
|
||||
visibleTimeLength, isAutoOrient, widthMultiplier, widthCurve, renderMaterial);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
base.SetUpInspector();
|
||||
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
Inspector inspectorMain = EditorManager.instance.uiManager.inspector;
|
||||
var container = inspector.GenerateContainer("Trail");
|
||||
var visibleTimeLengthInputField = inspector.GenerateInputField(this, container, "Visible Time Length", nameof(visibleTimeLength));
|
||||
var isAutoOrientToggle = inspector.GenerateToggle(this, container, "Is Auto Orient", nameof(isAutoOrient));
|
||||
var widthMultiplierInputField = inspector.GenerateInputField(this, container, "Width Multiplier", nameof(widthMultiplier));
|
||||
var widthCurveButton = inspector.GenerateButton(this, container, "Width Curve", () =>
|
||||
{
|
||||
var widthCurveWindow = inspector.GenerateCompositeParameterWindow(this, "Width Curve", nameof(widthCurve));
|
||||
widthCurveWindow.SetAsCustomCurve();
|
||||
widthCurveWindow.closeButton.onClick.AddListener(() => trailRenderer.widthCurve = widthCurve);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +98,9 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public float visibleTimeLength;
|
||||
public string renderMaterialName;
|
||||
public bool isAutoOrient;
|
||||
public float widthMultiplier;
|
||||
public AnimationCurve widthCurve;
|
||||
|
||||
public Trail_BM()
|
||||
{
|
||||
@@ -74,24 +108,29 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
|
||||
public Trail_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
|
||||
float visibleTimeLength, Material renderMaterial) : base(elementName, elementGuid, tags,
|
||||
float visibleTimeLength, bool isAutoOrient, float widthMultiplier,
|
||||
AnimationCurve widthCurve, Material renderMaterial) : base(elementName, elementGuid, tags,
|
||||
attachedElement)
|
||||
{
|
||||
this.visibleTimeLength = visibleTimeLength;
|
||||
this.renderMaterialName = renderMaterial.name;
|
||||
this.isAutoOrient = isAutoOrient;
|
||||
this.widthMultiplier = widthMultiplier;
|
||||
this.widthCurve = widthCurve;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = Trail.GenerateElement(elementName, elementGuid, tags,
|
||||
false, GetElement(attachedElementGuid),
|
||||
visibleTimeLength); //TODO: Implement Material
|
||||
visibleTimeLength, isAutoOrient, widthMultiplier, widthCurve);
|
||||
}
|
||||
|
||||
public override GameElement DuplicateBM(GameElement parent)
|
||||
{
|
||||
return Trail.GenerateElement(elementName, elementGuid, tags,
|
||||
false, parent, visibleTimeLength); //TODO: Implement Material
|
||||
false, parent, visibleTimeLength,
|
||||
isAutoOrient, widthMultiplier, widthCurve);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user