改改改,没有AI闹麻了

Signed-off-by: TRAfoer <lhf190@outlook.com>
This commit is contained in:
2025-07-10 23:31:25 +08:00
parent 135f61a857
commit 2b00c51435
10 changed files with 17995 additions and 5762 deletions

View File

@@ -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,