删除图鉴内容
This commit is contained in:
@@ -577,45 +577,7 @@ public static IEnumerator LoadTexture(string fileName, GLoader loader, Action<NT
|
||||
return tempPath;
|
||||
}
|
||||
|
||||
public static IEnumerator WriteTempBeforeOpenCoroutine_()
|
||||
{
|
||||
System.Diagnostics.Stopwatch stopwatch = System.Diagnostics.Stopwatch.StartNew();
|
||||
|
||||
var levelUnlocks = ConfigSystem.GetConfig<LevelUnlock>();
|
||||
var FreeImageLibrary_ = ConfigSystem.GetConfig<FreeImageLibrary>();
|
||||
var ADImageLibrary_ = ConfigSystem.GetConfig<ADImageLibrary>();
|
||||
var SpecialImageLibrary_ = ConfigSystem.GetConfig<SpecialImageLibrary>();
|
||||
var VIPImageLibrary_ = ConfigSystem.GetConfig<VIPImageLibrary>();
|
||||
for (int i = 0; i < GameHelper.GetCommonModel().MultiModal - 1; i++)
|
||||
{
|
||||
GetDecryptedImagePath(levelUnlocks[i].Name, FolderNames.AlbumName);
|
||||
yield return null;
|
||||
}
|
||||
var LevelUnlockListNew = DataMgr.LevelUnlockListNew.Value;
|
||||
for (int i = 0; i <LevelUnlockListNew.Count; i++)
|
||||
{
|
||||
switch (LevelUnlockListNew[i].type)
|
||||
{
|
||||
case 0:
|
||||
GetDecryptedImagePath(FreeImageLibrary_[LevelUnlockListNew[i].config_index].Name, FolderNames.AlbumName);
|
||||
break;
|
||||
case 1:
|
||||
GetDecryptedImagePath(ADImageLibrary_[LevelUnlockListNew[i].config_index].Name, FolderNames.AlbumName);
|
||||
break;
|
||||
case 2:
|
||||
GetDecryptedImagePath(SpecialImageLibrary_[LevelUnlockListNew[i].config_index].Name, FolderNames.AlbumName);
|
||||
break;
|
||||
case 3:
|
||||
GetDecryptedImagePath(VIPImageLibrary_[LevelUnlockListNew[i].config_index].Name, FolderNames.AlbumName);
|
||||
break;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
|
||||
stopwatch.Stop();
|
||||
UnityEngine.Debug.Log($"WriteTempBeforeOpen 协程执行耗时: {stopwatch.ElapsedMilliseconds} 毫秒");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -628,136 +590,10 @@ public static IEnumerator LoadTexture(string fileName, GLoader loader, Action<NT
|
||||
onReady?.Invoke();
|
||||
}
|
||||
|
||||
public static void SaveImageToAlbum(string fileName, string encryptedFolder, Action onSuccess = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 加密图片路径
|
||||
string encryptedPath = Path.Combine(getResPath(), encryptedFolder, fileName + ".jpg");
|
||||
|
||||
if (!File.Exists(encryptedPath))
|
||||
{
|
||||
Debug.LogWarning($"加密图片不存在: {encryptedPath}");
|
||||
return;
|
||||
}
|
||||
|
||||
// 解密为字节数组
|
||||
byte[] decryptedBytes = Rescrypt.DecryptFileToBytes(encryptedPath);
|
||||
|
||||
// 写入临时路径(系统可访问)
|
||||
string tempPath = Path.Combine(Application.temporaryCachePath, fileName + "_temp.jpg");
|
||||
File.WriteAllBytes(tempPath, decryptedBytes);
|
||||
BrigdeIOS.SaveImageWithCustomDate(tempPath);
|
||||
|
||||
// 保存到系统相册
|
||||
// NativeGallery.SaveImageToGallery(tempPath, "MyAlbum", fileName + ".jpg", (bool success, string path) =>
|
||||
// {
|
||||
// if (success)
|
||||
// {
|
||||
// GameHelper.ShowTips("save_successed", true);
|
||||
// onSuccess?.Invoke();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.LogWarning("保存到相册失败");
|
||||
// }
|
||||
//
|
||||
// // 可选:清理临时文件
|
||||
// if (File.Exists(tempPath))
|
||||
// File.Delete(tempPath);
|
||||
// });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"保存加密图片到相册失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void SaveVideoToAlbum(string fileName, Action onSuccess = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
string localPath = Path.Combine(getResPath(), FolderNames.VideoName, fileName + ".mp4");
|
||||
BrigdeIOS.SaveVideoWithCustomDate(localPath);
|
||||
// File.SetCreationTime(localPath, DateTime.Now);
|
||||
// File.SetCreationTimeUtc(localPath, DateTime.Now);
|
||||
// File.SetLastWriteTime(localPath, DateTime.Now);
|
||||
// File.SetLastWriteTimeUtc(localPath, DateTime.Now);
|
||||
// // CrazyAsyKit.StartCoroutine(GetSaveVideo(fileName, (isSuccess) =>
|
||||
// // {
|
||||
//
|
||||
// // }));
|
||||
// NativeGallery.SaveVideoToGallery(localPath, "MyAlbum", "my_video.mp4", (bool success, string path) =>
|
||||
// {
|
||||
// if (success)
|
||||
// {
|
||||
// GameHelper.ShowTips("save_successed", true);
|
||||
// onSuccess?.Invoke();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"保存加密视频到相册失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void SetVideoLoader(VideoPlayer player, GLoader loader, string fileName,
|
||||
Action<VideoPlayer> action = null, bool play = true)
|
||||
{
|
||||
|
||||
VideoLoadScheduler.EnqueueLoad(player, fileName, loader, videoPlayer =>
|
||||
{
|
||||
Debug.Log("RendererList------视频加载成功!-" + fileName);
|
||||
Debug.Log("[绑定播放器 EnqueueLoad]=========1=== ");
|
||||
if (videoPlayer != null)
|
||||
{
|
||||
Debug.Log("视频加载成功!");
|
||||
action?.Invoke(videoPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("视频加载失败!");
|
||||
VideoPlayerPool.Instance.ReturnPlayer(player);
|
||||
action?.Invoke(null);
|
||||
}
|
||||
}, play);
|
||||
}
|
||||
|
||||
public static void SetImageMosaic(GLoader loader, int num = 80)
|
||||
{
|
||||
var shader = Resources.Load<Shader>("LoveLegendAssets/Shader/Mosaic");
|
||||
if (shader == null)
|
||||
{
|
||||
Debug.LogError("找不到 Shader:Custom/Mosaic。请确保 shader 名称正确并已包含到构建中。");
|
||||
return;
|
||||
}
|
||||
|
||||
var material = new Material(shader);
|
||||
material.SetFloat("_BlockSize", num); // 假设你 shader 中的 blockSize 参数是这个
|
||||
loader.material = material;
|
||||
}
|
||||
|
||||
#region 材质处理
|
||||
|
||||
public static void SetImageBlur(GLoader loader)
|
||||
{
|
||||
if (loader == null || loader.isDisposed || loader.texture == null || loader.material.name == "Custom/Blur") return;
|
||||
if (loader.material != null) MaterialPool.Return(loader.material);
|
||||
loader.material = MaterialPool.GetBlur();
|
||||
}
|
||||
|
||||
public static void CancelImageBlur(GLoader loader)
|
||||
{
|
||||
if (loader == null || loader.isDisposed || loader.texture == null || loader.material == null || loader.material.name != "Custom/Blur") return;
|
||||
|
||||
if (loader.material != null) MaterialPool.Return(loader.material);
|
||||
loader.material = MaterialPool.GetNormal();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
@@ -771,78 +607,6 @@ public static IEnumerator LoadTexture(string fileName, GLoader loader, Action<NT
|
||||
private static Sprite _currentBackgroundSprite;
|
||||
private static SpriteRenderer _spriteRenderer;
|
||||
private static NTexture _currentNTexture; // 新增:缓存 NTexture
|
||||
public static void setGamebg(string fileName)
|
||||
{
|
||||
// 只获取一次组件
|
||||
if (_spriteRenderer == null)
|
||||
{
|
||||
var go = GameObject.Find("game_bg");
|
||||
if (go == null)
|
||||
{
|
||||
Debug.LogError("找不到名为 'game_bg' 的 GameObject!");
|
||||
return;
|
||||
}
|
||||
_spriteRenderer = go.GetComponent<SpriteRenderer>();
|
||||
if (_spriteRenderer == null)
|
||||
{
|
||||
Debug.LogError("'game_bg' 上没有找到 SpriteRenderer 组件!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (_spriteRenderer && _spriteRenderer.sprite && _spriteRenderer.sprite.texture.name == fileName)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 调用统一的 SetImgLoader,不需要再自己写下载逻辑
|
||||
SetImgLoader(null, fileName, nTex =>
|
||||
{
|
||||
if (nTex != null && nTex.nativeTexture != null)
|
||||
{
|
||||
Debug.Log("背景图片加载成功!");
|
||||
|
||||
var tex2D = nTex.nativeTexture as Texture2D;
|
||||
if (tex2D == null)
|
||||
{
|
||||
Debug.LogError("NTexture 转换失败!");
|
||||
return;
|
||||
}
|
||||
tex2D.name = fileName;
|
||||
// 创建 Sprite
|
||||
var sprite = Sprite.Create(
|
||||
tex2D,
|
||||
new Rect(0, 0, tex2D.width, tex2D.height),
|
||||
new Vector2(0.5f, 0.5f)
|
||||
);
|
||||
_spriteRenderer.sprite = sprite;
|
||||
|
||||
if (_currentNTexture != null)
|
||||
{
|
||||
_currentNTexture.Dispose();
|
||||
_currentNTexture = null;
|
||||
}
|
||||
if (_currentBackgroundSprite != null)
|
||||
{
|
||||
Object.Destroy(_currentBackgroundSprite);
|
||||
_currentBackgroundSprite = null;
|
||||
}
|
||||
|
||||
_currentNTexture = nTex;
|
||||
_currentBackgroundSprite = sprite;
|
||||
|
||||
var currentWidth = _spriteRenderer.sprite.bounds.size.x;
|
||||
var scaleFactor = 64f / currentWidth;
|
||||
|
||||
// 等比缩放
|
||||
_spriteRenderer.transform.localScale = new Vector3(scaleFactor, scaleFactor, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("背景图片加载失败!");
|
||||
}
|
||||
}, "LevelAlbums/", FolderNames.AlbumName, true, false, true); // ✅ 背景一般是立刻需要的,走优先下载
|
||||
}
|
||||
|
||||
|
||||
public static void GetCardIcon(bool isLogo = false, UnityAction<NTexture> action = null)
|
||||
|
||||
Reference in New Issue
Block a user