feat: 使用 ResourceSystem 异步加载精灵与关卡配置
Made-with: Cursor
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -11,9 +11,12 @@ using Cinemachine;
|
||||
using UnityEngine.Rendering;
|
||||
using AibisDream.Kit;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
public class MemoryProcess : MonoBehaviour
|
||||
{
|
||||
private const string MemorySpritePath = "Sprite/Memory/{0}.png";
|
||||
|
||||
public BubbleSlotGroup bubbleSlotGroup;
|
||||
public GameObject memoryView;
|
||||
public GameObject projector;
|
||||
@@ -327,12 +330,15 @@ public class MemoryProcess : MonoBehaviour
|
||||
{
|
||||
fadeMaterial.SetFloat("_DirectionalDistortionFade", -15);
|
||||
FavoritesManager.Instance.CloseFavorites();
|
||||
Sprite memSprite = Resources.Load<Sprite>("Art/Memory/" + memName);
|
||||
var memoryKey = string.Format(MemorySpritePath, memName);
|
||||
var memoryHandle = ResourceSystem.LoadAsync<Sprite>(memoryKey);
|
||||
yield return memoryHandle;
|
||||
Sprite memSprite = memoryHandle.Status == AsyncOperationStatus.Succeeded ? memoryHandle.Result : null;
|
||||
memoryFinishedspRender.sprite = memSprite;
|
||||
memoryFinishedImageNoColor.sprite = memSprite;
|
||||
if (memSprite == null)
|
||||
{
|
||||
Debug.LogError("Memory not found: " + memName);
|
||||
Debug.LogError("Memory not found: " + memoryKey);
|
||||
}
|
||||
|
||||
// AudioManager.PlayMemoryAudio("mem_" + memName);
|
||||
@@ -390,12 +396,17 @@ public class MemoryProcess : MonoBehaviour
|
||||
yield break;
|
||||
}
|
||||
|
||||
Sprite memorySprite = Resources.Load<Sprite>("Art/Memory/" + PunchTape.MemoryIndex);
|
||||
var searchMemoryKey = string.Format(MemorySpritePath, PunchTape.MemoryIndex);
|
||||
var searchMemoryHandle = ResourceSystem.LoadAsync<Sprite>(searchMemoryKey);
|
||||
yield return searchMemoryHandle;
|
||||
Sprite memorySprite = searchMemoryHandle.Status == AsyncOperationStatus.Succeeded
|
||||
? searchMemoryHandle.Result
|
||||
: null;
|
||||
memoryFinishedspRender.sprite = memorySprite;
|
||||
memoryFinishedImageNoColor.sprite = memorySprite;
|
||||
if (memorySprite == null)
|
||||
{
|
||||
Debug.LogError("Memory not found: " + PunchTape.MemoryIndex);
|
||||
Debug.LogError("Memory not found: " + searchMemoryKey);
|
||||
}
|
||||
|
||||
MemoryProcessVloume.weight = 1;
|
||||
|
||||
Reference in New Issue
Block a user