@@ -13,6 +13,10 @@ namespace Ichni.RhythmGame
|
||||
public TrailRenderer trailRenderer { get; set; }
|
||||
public Material renderMaterial;
|
||||
|
||||
// Add these fields for material selection in inspector
|
||||
public string materialThemeBundleName;
|
||||
public string materialName;
|
||||
|
||||
public float visibleTimeLength;
|
||||
public bool isAutoOrient;
|
||||
public float widthMultiplier;
|
||||
@@ -58,6 +62,18 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
transformSubmodule = new TransformSubmodule(this);
|
||||
}
|
||||
|
||||
// 新增:通过主题包名和材质名获取材质的方法
|
||||
public Material GetMaterialFromThemeBundle()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(materialThemeBundleName) && !string.IsNullOrEmpty(materialName))
|
||||
{
|
||||
var mat = ThemeBundleManager.instance.GetObject<Material>(materialThemeBundleName, materialName);
|
||||
if (mat != null)
|
||||
return mat;
|
||||
}
|
||||
return EditorManager.instance.basePrefabs.defaultTrailMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Trail
|
||||
@@ -65,7 +81,7 @@ namespace Ichni.RhythmGame
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Trail_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
||||
visibleTimeLength, isAutoOrient, widthMultiplier, widthCurve, renderMaterial, gradient);
|
||||
visibleTimeLength, isAutoOrient, widthMultiplier, widthCurve, materialThemeBundleName, materialName, gradient);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
@@ -95,6 +111,44 @@ namespace Ichni.RhythmGame
|
||||
widthCurveWindow.closeButton.onClick.AddListener(() => trailRenderer.widthCurve = widthCurve);
|
||||
});
|
||||
|
||||
// ----------- 新增:材质设置 -----------
|
||||
var materialSettings = container.GenerateSubcontainer(3);
|
||||
|
||||
// 主题包下拉框
|
||||
if (ThemeBundleManager.instance != null)
|
||||
{
|
||||
var themeBundleDropdown = inspector
|
||||
.GenerateDropdown(this, materialSettings, "Theme Bundle", ThemeBundleManager.instance.selectedThemeBundleList, "materialThemeBundleName")
|
||||
.AddListenerFunction(() => inspectorMain.SetInspector(this));
|
||||
// 材质名下拉框
|
||||
if (!string.IsNullOrEmpty(materialThemeBundleName) && ThemeBundleManager.instance.TryGetThemeBundle(materialThemeBundleName, out ThemeBundle themeBundle))
|
||||
{
|
||||
List<string> materialNameList = themeBundle.assetList_Material.ConvertAll(x => x.name);
|
||||
var objectNameDropdown = inspector.GenerateDropdown(this, materialSettings, "Material Name", materialNameList, "materialName")
|
||||
.AddListenerFunction(() => inspectorMain.SetInspector(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
var objectNameDropdown = inspector.GenerateDropdown(this, materialSettings, "Material Name", new List<string>(), "materialName");
|
||||
objectNameDropdown.dropdown.interactable = false;
|
||||
}
|
||||
// 应用材质按钮
|
||||
var applyMaterialButton = inspector.GenerateButton(this, materialSettings, "Apply Material", () =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(materialThemeBundleName) && !string.IsNullOrEmpty(materialName))
|
||||
{
|
||||
Material mat = ThemeBundleManager.instance.GetObject<Material>(materialThemeBundleName, materialName);
|
||||
if (mat != null)
|
||||
{
|
||||
renderMaterial = mat;
|
||||
if (trailRenderer != null)
|
||||
trailRenderer.material = renderMaterial;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// ----------- 材质设置结束 -----------
|
||||
|
||||
var colorSettings = container.GenerateSubcontainer(3);
|
||||
var gradientColorKeysButton = inspector.GenerateButton(this, colorSettings, "Gradient Color Keys", () =>
|
||||
{
|
||||
@@ -170,6 +224,8 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public float visibleTimeLength;
|
||||
public string renderMaterialName;
|
||||
public string materialThemeBundleName; // 新增
|
||||
public string materialName; // 新增
|
||||
public bool isAutoOrient;
|
||||
public float widthMultiplier;
|
||||
public AnimationCurve widthCurve;
|
||||
@@ -182,11 +238,14 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public Trail_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
|
||||
float visibleTimeLength, bool isAutoOrient, float widthMultiplier,
|
||||
AnimationCurve widthCurve, Material renderMaterial, Gradient gradient) : base(elementName, elementGuid, tags,
|
||||
AnimationCurve widthCurve, string materialThemeBundleName, string materialName, Gradient gradient) : base(elementName, elementGuid, tags,
|
||||
attachedElement)
|
||||
{
|
||||
this.visibleTimeLength = visibleTimeLength;
|
||||
this.renderMaterialName = renderMaterial.name;
|
||||
// 新增:保存主题包名和材质名
|
||||
this.materialThemeBundleName = materialThemeBundleName;
|
||||
this.materialName = materialName;
|
||||
|
||||
this.isAutoOrient = isAutoOrient;
|
||||
this.widthMultiplier = widthMultiplier;
|
||||
this.widthCurve = widthCurve;
|
||||
@@ -195,16 +254,28 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
// 新增:根据bm里的主题包名和材质名获取材质
|
||||
Material mat = null;
|
||||
if (!string.IsNullOrEmpty(materialThemeBundleName) && !string.IsNullOrEmpty(materialName))
|
||||
{
|
||||
mat = ThemeBundleManager.instance.GetObject<Material>(materialThemeBundleName, materialName);
|
||||
}
|
||||
matchedElement = Trail.GenerateElement(elementName, elementGuid, tags,
|
||||
false, GetElement(attachedElementGuid),
|
||||
visibleTimeLength, isAutoOrient, widthMultiplier, widthCurve, gradient);
|
||||
visibleTimeLength, isAutoOrient, widthMultiplier, widthCurve, gradient, mat);
|
||||
}
|
||||
|
||||
public override GameElement DuplicateBM(GameElement parent)
|
||||
{
|
||||
// 新增:根据bm里的主题包名和材质名获取材质
|
||||
Material mat = null;
|
||||
if (!string.IsNullOrEmpty(materialThemeBundleName) && !string.IsNullOrEmpty(materialName))
|
||||
{
|
||||
mat = ThemeBundleManager.instance.GetObject<Material>(materialThemeBundleName, materialName);
|
||||
}
|
||||
return Trail.GenerateElement(elementName, Guid.NewGuid(), tags,
|
||||
false, parent, visibleTimeLength,
|
||||
isAutoOrient, widthMultiplier, widthCurve, gradient);
|
||||
isAutoOrient, widthMultiplier, widthCurve, gradient, mat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user