This commit is contained in:
SoulliesOfficial
2026-04-03 10:53:11 -04:00
parent e7b890686d
commit 1bc9af280b
177 changed files with 4029 additions and 3302 deletions

View File

@@ -12,6 +12,7 @@ namespace Ichni.RhythmGame.ThemeBundles.Basic
public class Custom2DShape : EnvironmentObject
{
#region [] Exposed Fields
public string spriteThemeBundleName;
public string spriteName = "None";
public SpriteRenderer spriteRenderer;
#endregion
@@ -19,21 +20,18 @@ namespace Ichni.RhythmGame.ThemeBundles.Basic
#region [] Lifecycle & Factory
public static Custom2DShape GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated, string themeBundleName, string objectName, GameElement parentElement,
bool isStatic, string spriteName)
bool isStatic, string spriteThemeBundleName, string spriteName)
{
// 通过 EnvironmentObject.GenerateElement 创建 GameObject 并获取组件
Custom2DShape obj = EnvironmentObject.GenerateElement(elementName, id, tags,
isFirstGenerated, themeBundleName, objectName, parentElement, isStatic).GetComponent<Custom2DShape>();
obj.spriteThemeBundleName = spriteThemeBundleName;
obj.spriteName = spriteName;
return obj;
}
public override void FirstSetUpObject(bool isFirstGenerated)
public override void AfterInitialize()
{
if (spriteRenderer == null)
spriteRenderer = GetComponentInChildren<SpriteRenderer>();
UpdateSprite();
Refresh();
}
@@ -54,14 +52,24 @@ namespace Ichni.RhythmGame.ThemeBundles.Basic
if (spriteRenderer != null && !string.IsNullOrEmpty(spriteName) && spriteName != "None")
{
// 通过 ThemeBundleManager 获取 Sprite
Sprite sp = ThemeBundleManager.instance.GetObject<Sprite>(themeBundleName, spriteName);
Sprite sp = ThemeBundleManager.instance.GetObject<Sprite>(spriteThemeBundleName, spriteName);
if (sp == null)
{
// 如果没有找到 Sprite则从 Texture2D 列表中获取并动态创建 Sprite
Texture2D tex = ThemeBundleManager.instance.GetObject<Texture2D>(spriteThemeBundleName, spriteName);
if (tex != null)
{
sp = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
}
}
if (sp != null)
{
spriteRenderer.sprite = sp;
}
else
{
Debug.LogWarning($"[Custom2DShape] 无法在包 '{themeBundleName}' 中找到 Sprite: {spriteName}");
Debug.LogWarning($"[Custom2DShape] 无法在包 '{spriteThemeBundleName}' 中找到 Sprite/Texture: {spriteName}");
}
}
}
@@ -73,6 +81,12 @@ namespace Ichni.RhythmGame.ThemeBundles.Basic
if (spriteRenderer != null)
{
spriteRenderer.color = colorSubmodule.currentBaseColor;
if (colorSubmodule.emissionEnabled)
{
// 如果启用了发光,尝试设置发光颜色(需要对应的 Shader 支持)
spriteRenderer.material.SetFloat("_EnableEmission", 1);
spriteRenderer.material.SetColor("_EmissionColor", colorSubmodule.GetCurrentEmissionColor());
}
}
}
#endregion
@@ -87,21 +101,23 @@ namespace Ichni.RhythmGame.ThemeBundles.Basic
[System.Serializable]
public class Custom2DShape_BM : EnvironmentObject_BM
{
public string spriteThemeBundleName;
public string spriteName = "None";
public Custom2DShape_BM() { }
public Custom2DShape_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM parentElement,
string themeBundleName, string objectName, bool isStatic, string spriteName)
string themeBundleName, string objectName, bool isStatic, string spriteThemeBundleName, string spriteName)
: base(elementName, elementGuid, tags, parentElement, themeBundleName, objectName, isStatic)
{
this.spriteThemeBundleName = spriteThemeBundleName;
this.spriteName = spriteName;
}
public override void ExecuteBM()
{
matchedElement = Custom2DShape.GenerateElement(elementName, elementGuid, tags, false,
themeBundleName, objectName, GetElement(attachedElementGuid), isStatic, spriteName);
themeBundleName, objectName, GetElement(attachedElementGuid), isStatic, spriteThemeBundleName, spriteName);
}
}
}