规范命名空间

具体来说就是 SepCore 开头,然后接所属的模块名,比如 SepCore.Entity,SepCore.Simulation,SepCore.Procedure
This commit is contained in:
SepComet
2026-06-03 16:57:40 +08:00
parent 5de3fdc795
commit edd7088804
210 changed files with 461 additions and 547 deletions
@@ -2,68 +2,71 @@ using System;
using System.Collections.Generic;
using SepCore.Definition;
using GameFramework.Resource;
using CustomUtility;
using SepCore.CustomUtility;
using UnityEngine;
using UnityGameFramework.Runtime;
public class SpriteCacheComponent : GameFrameworkComponent
namespace SepCore.SpriteCache
{
[SerializeField] private float _pixelsPerUnit = 100f;
[SerializeField] private Vector2 _defaultPivot = new(0.5f, 0.5f);
private Dictionary<string, Sprite> _spriteCache;
private ResourceComponent _resource;
void Start()
public class SpriteCacheComponent : GameFrameworkComponent
{
_spriteCache = new Dictionary<string, Sprite>();
_resource = GameEntry.Resource;
}
[SerializeField] private float _pixelsPerUnit = 100f;
[SerializeField] private Vector2 _defaultPivot = new(0.5f, 0.5f);
public void GetSprite(string assetName, Action<Sprite> callback)
{
if (_spriteCache.TryGetValue(assetName, out var sprite))
private Dictionary<string, Sprite> _spriteCache;
private ResourceComponent _resource;
void Start()
{
callback?.Invoke(sprite);
return;
_spriteCache = new Dictionary<string, Sprite>();
_resource = GameEntry.Resource;
}
else
public void GetSprite(string assetName, Action<Sprite> callback)
{
_resource.LoadAsset
(
AssetUtility.GetUITextureIconAsset(assetName),
Constant.AssetPriority.UIFormAsset,
new LoadAssetCallbacks(
(resourcePath, asset, duration, userData) =>
{
Log.Debug(resourcePath);
Texture2D texture = asset as Texture2D;
if (texture != null)
if (_spriteCache.TryGetValue(assetName, out var sprite))
{
callback?.Invoke(sprite);
return;
}
else
{
_resource.LoadAsset
(
AssetUtility.GetUITextureIconAsset(assetName),
Constant.AssetPriority.UIFormAsset,
new LoadAssetCallbacks(
(resourcePath, asset, duration, userData) =>
{
Sprite newSprite = Sprite.Create(
texture,
new Rect(0, 0, texture.width, texture.height),
_defaultPivot,
_pixelsPerUnit);
_spriteCache.TryAdd(assetName, newSprite);
callback?.Invoke(newSprite);
Log.Debug(resourcePath);
Texture2D texture = asset as Texture2D;
if (texture != null)
{
Sprite newSprite = Sprite.Create(
texture,
new Rect(0, 0, texture.width, texture.height),
_defaultPivot,
_pixelsPerUnit);
_spriteCache.TryAdd(assetName, newSprite);
callback?.Invoke(newSprite);
}
},
(resourcePath, status, errorMessage, userData) =>
{
Log.Error("Can not load icon '{0}' from '{1}' with error message '{2}'.",
assetName,
resourcePath,
errorMessage);
}
},
(resourcePath, status, errorMessage, userData) =>
{
Log.Error("Can not load icon '{0}' from '{1}' with error message '{2}'.",
assetName,
resourcePath,
errorMessage);
}
)
);
)
);
}
}
private void OnDestroy()
{
_spriteCache.Clear();
_resource = null;
}
}
private void OnDestroy()
{
_spriteCache.Clear();
_resource = null;
}
}
}