@@ -12,12 +12,15 @@ namespace Ichni.Editor
|
||||
public class DynamicUIHintText : DynamicUIElement
|
||||
{
|
||||
public TMP_Text text;
|
||||
|
||||
public override void Initialize(IBaseElement baseElement, string title, string parameterName)
|
||||
{
|
||||
base.Initialize(baseElement, title, parameterName);
|
||||
}
|
||||
public void SetContent(string content)
|
||||
{
|
||||
text.text = content;
|
||||
}
|
||||
|
||||
|
||||
public void SetUpdatingContent(Func<string> content)
|
||||
{
|
||||
Observable.EveryUpdate().Subscribe(_ => text.text = content()).AddTo(gameObject);
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
@@ -19,14 +21,14 @@ namespace Ichni.RhythmGame
|
||||
public List<float> blendSpeedList;
|
||||
public List<float> blendTimeList;
|
||||
public int currentSkyboxIndex = 0;
|
||||
|
||||
|
||||
public List<string> themeBundleListForSelection;
|
||||
public List<string> skyboxNameListForSelection;
|
||||
public string selectedThemeBundle;
|
||||
public string selectedSkybox;
|
||||
|
||||
|
||||
public static SkyboxSubsetter GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
bool isFirstGenerated, GameElement parentElement, List<string> themeBundleList,List<string> skyboxList,
|
||||
bool isFirstGenerated, GameElement parentElement, List<string> themeBundleList, List<string> skyboxList,
|
||||
List<float> blendTimeList, List<float> blendSpeedList)
|
||||
{
|
||||
SkyboxSubsetter skyboxSubsetter = Instantiate(EditorManager.instance.basePrefabs.emptyObject)
|
||||
@@ -63,7 +65,7 @@ namespace Ichni.RhythmGame
|
||||
skyboxBlender.makeFirstMaterialSkybox = true;
|
||||
skyboxBlender.InspectorAndAwakeChanges();
|
||||
}
|
||||
|
||||
|
||||
private void AddSkybox(string skyboxThemeBundleName, string skyboxObjectName)
|
||||
{
|
||||
Material skybox = ThemeBundleManager.instance.GetObject<Material>(skyboxThemeBundleName, skyboxObjectName);
|
||||
@@ -75,7 +77,7 @@ namespace Ichni.RhythmGame
|
||||
skyboxBlender.skyboxMaterials.Add(skybox);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (skyBoxThemeBundleList.Count > 1)
|
||||
@@ -88,17 +90,17 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
float startTime = index == 0 ? -delay : blendTimeList[index - 1];
|
||||
float endTime = index >= blendTimeList.Count ? finalTime : blendTimeList[index];
|
||||
if(songTime >= startTime && songTime < endTime && currentSkyboxIndex != index)
|
||||
if (songTime >= startTime && songTime < endTime && currentSkyboxIndex != index)
|
||||
{
|
||||
currentSkyboxIndex = index;
|
||||
if(currentSkyboxIndex != 0) skyboxBlender.blendSpeed = blendSpeedList[currentSkyboxIndex - 1];
|
||||
if (currentSkyboxIndex != 0) skyboxBlender.blendSpeed = blendSpeedList[currentSkyboxIndex - 1];
|
||||
skyboxBlender.Blend(currentSkyboxIndex, false);
|
||||
DynamicGI.UpdateEnvironment();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new SkyboxSubsetter_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
||||
@@ -112,28 +114,82 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
Inspector inspectorMain = EditorManager.instance.uiManager.inspector;
|
||||
|
||||
|
||||
var container = inspector.GenerateContainer("Skybox Subsetter");
|
||||
DynamicUISubcontainer mainSettings = container.GenerateSubcontainer(3);
|
||||
|
||||
|
||||
var blendSpeedListButton = inspector.GenerateButton(this, mainSettings, "Blend Speed List", () =>
|
||||
{
|
||||
inspector.GenerateCompositeParameterWindow(this, "Blend Speed List", nameof(blendSpeedList))
|
||||
.SetAsFloatList();
|
||||
});
|
||||
|
||||
|
||||
var blendTimeListButton = inspector.GenerateButton(this, mainSettings, "Blend Time List", () =>
|
||||
{
|
||||
inspector.GenerateCompositeParameterWindow(this, "Blend Time List", nameof(blendTimeList))
|
||||
.SetAsFloatList();
|
||||
});
|
||||
|
||||
|
||||
DynamicUISubcontainer materialSettings = container.GenerateSubcontainer(3);
|
||||
// 新增:显示skybox配置情况//这他妈是什么
|
||||
|
||||
DynamicUISubcontainer Textsettings = container.GenerateSubcontainer(2);
|
||||
for (int i = 0; i < (skyBoxThemeBundleList?.Count ?? 0); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 安全访问元素:检查索引是否在所有列表的有效范围内
|
||||
string bundleName = i < skyBoxThemeBundleList.Count ? skyBoxThemeBundleList[i] : "<Missing Bundle>";
|
||||
string name = i < skyboxNameList.Count ? skyboxNameList[i] : "<Missing Name>";
|
||||
|
||||
inspector.GenerateHintText(this, Textsettings, $"{i + 1}. [{bundleName}] {name}\n");
|
||||
|
||||
// 创建局部变量解决闭包问题
|
||||
int index = i;
|
||||
inspector.GenerateButton(this, Textsettings, "Remove Skybox", () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// 移除前检查所有列表的索引有效性
|
||||
if (index < skyBoxThemeBundleList.Count)
|
||||
skyBoxThemeBundleList.RemoveAt(index);
|
||||
else
|
||||
Debug.LogError($"Cannot remove: skyBoxThemeBundleList index {index} out of range");
|
||||
|
||||
if (index < skyboxNameList.Count)
|
||||
skyboxNameList.RemoveAt(index);
|
||||
else
|
||||
Debug.LogError($"Cannot remove: skyboxNameList index {index} out of range");
|
||||
|
||||
if (index < skyboxMaterialList.Count)
|
||||
skyboxMaterialList.RemoveAt(index);
|
||||
else
|
||||
Debug.LogError($"Cannot remove: skyboxMaterialList index {index} out of range");
|
||||
|
||||
if (index < skyboxBlender.skyboxMaterials.Count)
|
||||
skyboxBlender.skyboxMaterials.RemoveAt(index);
|
||||
else
|
||||
Debug.LogError($"Cannot remove: skyboxMaterials index {index} out of range");
|
||||
|
||||
inspectorMain.SetInspector(this);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"Error during removal: {ex.Message}");
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"Error generating UI for index {i}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log((mainSettings == null) + " " + (themeBundleListForSelection == null) + " " + (selectedThemeBundle == null));
|
||||
var themeBundleDropdown =
|
||||
var themeBundleDropdown =
|
||||
inspector.GenerateDropdown(this, materialSettings, "Theme Bundle", themeBundleListForSelection, nameof(selectedThemeBundle))
|
||||
.AddListenerFunction(() => inspectorMain.SetInspector(this));
|
||||
|
||||
|
||||
if (selectedThemeBundle != String.Empty && ThemeBundleManager.instance.TryGetThemeBundle(selectedThemeBundle, out ThemeBundle themeBundle))
|
||||
{
|
||||
skyboxNameListForSelection = themeBundle.assetList_Material.ConvertAll(x => x.name);
|
||||
@@ -143,14 +199,16 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
else
|
||||
{
|
||||
var objectNameDropdown =
|
||||
var objectNameDropdown =
|
||||
inspector.GenerateDropdown(this, materialSettings, "Material Name", new List<string>(), nameof(selectedSkybox));
|
||||
objectNameDropdown.dropdown.interactable = false;
|
||||
} // 如果没有选择主题包,则材质名称下拉框不可用
|
||||
|
||||
|
||||
var setMaterialButton = inspector.GenerateButton(this, materialSettings, "Add Skybox", () =>
|
||||
{
|
||||
AddSkybox(selectedThemeBundle, selectedSkybox);
|
||||
inspectorMain.SetInspector(this);
|
||||
|
||||
});
|
||||
|
||||
if (selectedThemeBundle == String.Empty || selectedSkybox == String.Empty)
|
||||
@@ -171,11 +229,11 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public SkyboxSubsetter_BM()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public SkyboxSubsetter_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
|
||||
List<string> skyBoxThemeBundleList, List<string> skyboxNameList, List<float> blendTimeList, List<float> blendSpeedList)
|
||||
List<string> skyBoxThemeBundleList, List<string> skyboxNameList, List<float> blendTimeList, List<float> blendSpeedList)
|
||||
: base(elementName, elementGuid, tags, attachedElement)
|
||||
{
|
||||
this.skyBoxThemeBundleList = skyBoxThemeBundleList;
|
||||
@@ -183,7 +241,7 @@ namespace Ichni.RhythmGame
|
||||
this.blendTimeList = blendTimeList;
|
||||
this.blendSpeedList = blendSpeedList;
|
||||
}
|
||||
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = SkyboxSubsetter.GenerateElement(elementName, elementGuid, tags, false,
|
||||
|
||||
@@ -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