Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
48eedfc590
BIN
Assets/_DDD/_Addressables/AI/Customer/Subtree/CustomerDefault.asset
(Stored with Git LFS)
BIN
Assets/_DDD/_Addressables/AI/Customer/Subtree/CustomerDefault.asset
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/_DDD/_Addressables/AI/Customer/Subtree/OrderSubtree.asset
(Stored with Git LFS)
BIN
Assets/_DDD/_Addressables/AI/Customer/Subtree/OrderSubtree.asset
(Stored with Git LFS)
Binary file not shown.
@ -1210,9 +1210,6 @@ PrefabInstance:
|
|||||||
- targetCorrespondingSourceObject: {fileID: 7462519206451630147, guid: ceeea618d8ee23642a0e56b3f963448c, type: 3}
|
- targetCorrespondingSourceObject: {fileID: 7462519206451630147, guid: ceeea618d8ee23642a0e56b3f963448c, type: 3}
|
||||||
insertIndex: -1
|
insertIndex: -1
|
||||||
addedObject: {fileID: 3825874317044733320}
|
addedObject: {fileID: 3825874317044733320}
|
||||||
- targetCorrespondingSourceObject: {fileID: 7462519206451630147, guid: ceeea618d8ee23642a0e56b3f963448c, type: 3}
|
|
||||||
insertIndex: -1
|
|
||||||
addedObject: {fileID: 1122074513716966771}
|
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: ceeea618d8ee23642a0e56b3f963448c, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: ceeea618d8ee23642a0e56b3f963448c, type: 3}
|
||||||
--- !u!1 &4266090516809920735 stripped
|
--- !u!1 &4266090516809920735 stripped
|
||||||
GameObject:
|
GameObject:
|
||||||
@ -1255,23 +1252,3 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: af69e82818254bfa9cabb2dbf9430850, type: 3}
|
m_Script: {fileID: 11500000, guid: af69e82818254bfa9cabb2dbf9430850, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
--- !u!114 &1122074513716966771
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 4266090516809920735}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 201f9e6d7ca7404baa9945950292a392, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
_interactionType: 4
|
|
||||||
_executionParameters:
|
|
||||||
_holdTime: 0
|
|
||||||
_displayParameters:
|
|
||||||
_messageKey:
|
|
||||||
_interactionAvailableFlows: 2
|
|
||||||
_aiInteractionPoints: []
|
|
||||||
autoInitialize: 1
|
|
||||||
|
@ -426,7 +426,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 81e01dd8c1cc3404d805400eba1bb4ae, type: 3}
|
m_Script: {fileID: 11500000, guid: 81e01dd8c1cc3404d805400eba1bb4ae, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_availableInteractions: 5
|
_availableInteractions: 7
|
||||||
_nearColliders:
|
_nearColliders:
|
||||||
- {fileID: 0}
|
- {fileID: 0}
|
||||||
- {fileID: 0}
|
- {fileID: 0}
|
||||||
|
@ -45,3 +45,4 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_persistent: 1
|
_persistent: 1
|
||||||
|
_enableDebugLog: 1
|
||||||
|
@ -45,3 +45,4 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_persistent: 1
|
_persistent: 1
|
||||||
|
_inventoryTestDataSo: {fileID: 11400000, guid: 29d0dee3b70fbc44d992ea47012bc366, type: 2}
|
||||||
|
BIN
Assets/_DDD/_ScriptAssets/So/ManagerDefinitionSo.asset
(Stored with Git LFS)
BIN
Assets/_DDD/_ScriptAssets/So/ManagerDefinitionSo.asset
(Stored with Git LFS)
Binary file not shown.
@ -9,7 +9,7 @@ namespace DDD
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IAISharedBlackboard
|
public interface IAISharedBlackboard
|
||||||
{
|
{
|
||||||
void SetCurrentInteractionTarget(GameObject targetGameObject);
|
void SetBlackboardGameObject(string key, GameObject inGameObject);
|
||||||
GameObject GetCurrentInteractionTarget();
|
GameObject GetBlackboardGameObject(string key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#if UNITY_EDITOR
|
|
||||||
using UnityEditor.AddressableAssets;
|
|
||||||
#endif
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.AddressableAssets;
|
using UnityEngine.AddressableAssets;
|
||||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||||
@ -15,7 +11,34 @@ namespace DDD
|
|||||||
{
|
{
|
||||||
public class AssetManager : Singleton<AssetManager>, IManager
|
public class AssetManager : Singleton<AssetManager>, IManager
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<string, AsyncOperationHandle> _cachedHandles = new();
|
private struct CachedAsset
|
||||||
|
{
|
||||||
|
public AsyncOperationHandle Handle;
|
||||||
|
public int ReferenceCount;
|
||||||
|
|
||||||
|
public CachedAsset(AsyncOperationHandle handle, int count = 1)
|
||||||
|
{
|
||||||
|
Handle = handle;
|
||||||
|
ReferenceCount = count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private struct CachedScene
|
||||||
|
{
|
||||||
|
public AsyncOperationHandle<SceneInstance> Handle;
|
||||||
|
public int ReferenceCount;
|
||||||
|
|
||||||
|
public CachedScene(AsyncOperationHandle<SceneInstance> handle, int count = 1)
|
||||||
|
{
|
||||||
|
Handle = handle;
|
||||||
|
ReferenceCount = count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SerializeField] private bool _enableDebugLog = false;
|
||||||
|
|
||||||
|
private readonly Dictionary<string, CachedAsset> _cachedAssets = new();
|
||||||
|
private readonly Dictionary<string, CachedScene> _cachedScenes = new();
|
||||||
|
|
||||||
protected override void OnApplicationQuit()
|
protected override void OnApplicationQuit()
|
||||||
{
|
{
|
||||||
@ -24,110 +47,284 @@ protected override void OnApplicationQuit()
|
|||||||
ReleaseAllCached();
|
ReleaseAllCached();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PreInit()
|
public void PreInit() { }
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task Init()
|
public async Task Init()
|
||||||
{
|
{
|
||||||
await Addressables.InitializeAsync().Task;
|
await Addressables.InitializeAsync().Task;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PostInit()
|
public void PostInit() { }
|
||||||
|
|
||||||
|
private string GetSafeAssetName(AssetReference assetReference)
|
||||||
{
|
{
|
||||||
|
var editorAssetName = assetReference.editorAsset.name;
|
||||||
|
if (string.IsNullOrWhiteSpace(editorAssetName) == false) return editorAssetName;
|
||||||
|
|
||||||
|
return assetReference.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<T> LoadAsset<T>(string key) where T : UnityEngine.Object
|
public async Task<T> LoadAssetAsync<T>(AssetReference assetReference) where T : Object
|
||||||
{
|
{
|
||||||
if (_cachedHandles.TryGetValue(key, out var handle))
|
var guidKey = assetReference.AssetGUID;
|
||||||
|
|
||||||
|
if (_cachedAssets.TryGetValue(guidKey, out var cachedAsset))
|
||||||
{
|
{
|
||||||
if (handle.IsValid() && handle.Result is T result)
|
if (cachedAsset.Handle.IsValid() && cachedAsset.Handle.Result is T result)
|
||||||
|
{
|
||||||
|
cachedAsset.ReferenceCount++;
|
||||||
|
_cachedAssets[guidKey] = cachedAsset;
|
||||||
|
|
||||||
|
if (_enableDebugLog) Debug.Log($"[AssetManager] 에셋 참조 카운트 증가: {GetSafeAssetName(assetReference)} -> {cachedAsset.ReferenceCount}\n실제 키 값: {guidKey}");
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
Debug.LogWarning($"[AssetManager] Type mismatch or invalid handle for key: {key}");
|
|
||||||
return handle.Result as T;
|
_cachedAssets.Remove(guidKey);
|
||||||
|
Debug.LogWarning($"[AssetManager] 무효한 핸들 제거됨: {GetSafeAssetName(assetReference)}\n실제 키 값: {guidKey}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ 새로 로드
|
var newHandle = Addressables.LoadAssetAsync<T>(guidKey);
|
||||||
var newHandle = Addressables.LoadAssetAsync<T>(key);
|
|
||||||
await newHandle.Task;
|
await newHandle.Task;
|
||||||
|
|
||||||
if (newHandle.Status == AsyncOperationStatus.Succeeded)
|
if (newHandle.Status == AsyncOperationStatus.Succeeded)
|
||||||
{
|
{
|
||||||
_cachedHandles[key] = newHandle;
|
_cachedAssets[guidKey] = new CachedAsset(newHandle, 1);
|
||||||
|
if (_enableDebugLog) Debug.Log($"[AssetManager] 에셋 로드 및 캐싱 완료: {GetSafeAssetName(assetReference)} (참조수: {_cachedAssets[guidKey].ReferenceCount})\n실제 키 값: {guidKey}");
|
||||||
return newHandle.Result;
|
return newHandle.Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.LogError($"[AssetManager] Failed to load asset: {key}");
|
if (newHandle.IsValid())
|
||||||
|
{
|
||||||
|
Addressables.Release(newHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.LogError($"[AssetManager] 에셋 로드 실패: {GetSafeAssetName(assetReference)}\n실제 키 값: {guidKey}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ScriptSingleton을 위한 동기 로딩
|
||||||
|
/// </summary>
|
||||||
|
public T LoadAsset<T>(string key) where T : Object
|
||||||
|
{
|
||||||
|
if (_cachedAssets.TryGetValue(key, out var cachedAsset))
|
||||||
|
{
|
||||||
|
if (cachedAsset.Handle.IsValid() && cachedAsset.Handle.Result is T result)
|
||||||
|
{
|
||||||
|
cachedAsset.ReferenceCount++;
|
||||||
|
_cachedAssets[key] = cachedAsset;
|
||||||
|
|
||||||
|
if (_enableDebugLog) Debug.Log($"[AssetManager] 동기 로딩 - 에셋 참조 카운트 증가: {key} -> {cachedAsset.ReferenceCount}");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
_cachedAssets.Remove(key);
|
||||||
|
Debug.LogWarning($"[AssetManager] 무효한 핸들 제거됨: {key}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var handle = Addressables.LoadAssetAsync<T>(key);
|
||||||
|
var loaded = handle.WaitForCompletion();
|
||||||
|
|
||||||
|
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||||
|
{
|
||||||
|
_cachedAssets[key] = new CachedAsset(handle, 1);
|
||||||
|
if (_enableDebugLog) Debug.Log($"[AssetManager] 동기 로딩 - 에셋 로드 및 캐싱 완료: {key} (참조수: {key})");
|
||||||
|
return loaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handle.IsValid())
|
||||||
|
{
|
||||||
|
Addressables.Release(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.LogError($"[AssetManager] 동기 로딩 - 에셋 로드 실패: {key}");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<List<T>> LoadAssetsByLabel<T>(string label) where T : UnityEngine.Object
|
public async Task<List<T>> LoadAssetsByLabel<T>(string label) where T : Object
|
||||||
{
|
{
|
||||||
var handle = Addressables.LoadAssetsAsync<T>(label, null);
|
if (_cachedAssets.TryGetValue(label, out var cachedAsset))
|
||||||
|
{
|
||||||
|
if (cachedAsset.Handle.IsValid() && cachedAsset.Handle.Result is IList<T> cachedResult)
|
||||||
|
{
|
||||||
|
cachedAsset.ReferenceCount++;
|
||||||
|
_cachedAssets[label] = cachedAsset;
|
||||||
|
|
||||||
|
if (_enableDebugLog) Debug.Log($"[AssetManager] 라벨 에셋 참조 카운트 증가: {label} -> {cachedAsset.ReferenceCount}");
|
||||||
|
return cachedResult.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
_cachedAssets.Remove(label);
|
||||||
|
if (_enableDebugLog) Debug.LogWarning($"[AssetManager] 무효한 라벨 핸들 제거됨: {label}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var handle = Addressables.LoadAssetsAsync<T>(label);
|
||||||
await handle.Task;
|
await handle.Task;
|
||||||
|
|
||||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||||
|
{
|
||||||
|
_cachedAssets[label] = new CachedAsset(handle, 1);
|
||||||
|
if (_enableDebugLog) Debug.Log($"[AssetManager] 라벨 에셋 로드 및 캐싱 완료: {label} (참조수: {_cachedAssets[label].ReferenceCount})");
|
||||||
return handle.Result.ToList();
|
return handle.Result.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
Debug.LogError($"[AssetManager] Failed to load assets with label: {label}");
|
if (handle.IsValid())
|
||||||
|
{
|
||||||
|
Addressables.Release(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.LogError($"[AssetManager] 라벨 에셋 로드 실패: {label}");
|
||||||
return new List<T>();
|
return new List<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<SceneInstance> LoadScene(AssetReference assetReference, LoadSceneMode mode = LoadSceneMode.Additive, bool activateOnLoad = true)
|
public void ReleaseAsset(AssetReference assetReference)
|
||||||
{
|
{
|
||||||
|
var guidKey = assetReference.AssetGUID;
|
||||||
|
|
||||||
|
if (_cachedAssets.TryGetValue(guidKey, out var cachedAsset))
|
||||||
|
{
|
||||||
|
cachedAsset.ReferenceCount--;
|
||||||
|
|
||||||
|
if (cachedAsset.ReferenceCount <= 0)
|
||||||
|
{
|
||||||
|
if (cachedAsset.Handle.IsValid())
|
||||||
|
{
|
||||||
|
Addressables.Release(cachedAsset.Handle);
|
||||||
|
if (_enableDebugLog) Debug.Log($"[AssetManager] 에셋 실제 해제됨: {GetSafeAssetName(assetReference)}\n실제 키 값: {guidKey}");
|
||||||
|
}
|
||||||
|
_cachedAssets.Remove(guidKey);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_cachedAssets[guidKey] = cachedAsset;
|
||||||
|
if (_enableDebugLog) Debug.Log($"[AssetManager] 에셋 참조 카운트 감소: {GetSafeAssetName(assetReference)} -> {cachedAsset.ReferenceCount}\n실제 키 값: {guidKey}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_enableDebugLog) Debug.LogWarning($"[AssetManager] 캐시에서 에셋을 찾을 수 없음: {GetSafeAssetName(assetReference)}\n실제 키 값: {guidKey}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReleaseAsset(string key)
|
||||||
|
{
|
||||||
|
if (_cachedAssets.TryGetValue(key, out var cachedAsset))
|
||||||
|
{
|
||||||
|
cachedAsset.ReferenceCount--;
|
||||||
|
|
||||||
|
if (cachedAsset.ReferenceCount <= 0)
|
||||||
|
{
|
||||||
|
if (cachedAsset.Handle.IsValid())
|
||||||
|
{
|
||||||
|
Addressables.Release(cachedAsset.Handle);
|
||||||
|
if (_enableDebugLog) Debug.Log($"[AssetManager] 에셋 실제 해제됨: {key}");
|
||||||
|
}
|
||||||
|
_cachedAssets.Remove(key);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_cachedAssets[key] = cachedAsset;
|
||||||
|
if (_enableDebugLog) Debug.Log($"[AssetManager] 에셋 참조 카운트 감소: {key} -> {cachedAsset.ReferenceCount}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_enableDebugLog) Debug.LogWarning($"[AssetManager] 캐시에서 에셋을 찾을 수 없음: {key}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<SceneInstance> LoadScene(AssetReference assetReference, LoadSceneMode mode = LoadSceneMode.Additive, bool activateOnLoad = true)
|
||||||
|
{
|
||||||
|
var guidKey = assetReference.AssetGUID;
|
||||||
|
|
||||||
|
if (_cachedScenes.TryGetValue(guidKey, out var cachedScene))
|
||||||
|
{
|
||||||
|
if (cachedScene.Handle.IsValid())
|
||||||
|
{
|
||||||
|
cachedScene.ReferenceCount++;
|
||||||
|
_cachedScenes[guidKey] = cachedScene;
|
||||||
|
|
||||||
|
if (_enableDebugLog) Debug.Log($"[AssetManager] 씬 참조 카운트 증가: {GetSafeAssetName(assetReference)} -> {cachedScene.ReferenceCount}\n실제 키 값: {guidKey}");
|
||||||
|
return cachedScene.Handle.Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
_cachedScenes.Remove(guidKey);
|
||||||
|
if (_enableDebugLog) Debug.LogWarning($"[AssetManager] 무효한 씬 핸들 제거됨: {GetSafeAssetName(assetReference)}\n실제 키 값: {guidKey}");
|
||||||
|
}
|
||||||
|
|
||||||
var handle = Addressables.LoadSceneAsync(assetReference, mode, activateOnLoad);
|
var handle = Addressables.LoadSceneAsync(assetReference, mode, activateOnLoad);
|
||||||
await handle.Task;
|
await handle.Task;
|
||||||
|
|
||||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||||
|
{
|
||||||
|
_cachedScenes[guidKey] = new CachedScene(handle, 1);
|
||||||
|
var sceneName = handle.Result.Scene.name;
|
||||||
|
if (_enableDebugLog) Debug.Log($"[AssetManager] 씬 로드 및 캐싱 완료: {sceneName} (참조수: {_cachedScenes[guidKey].ReferenceCount})\n실제 키 값: {guidKey}");
|
||||||
return handle.Result;
|
return handle.Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handle.IsValid())
|
||||||
|
{
|
||||||
|
Addressables.UnloadSceneAsync(handle);
|
||||||
|
}
|
||||||
|
|
||||||
Debug.LogError($"Scene load failed: {assetReference}");
|
Debug.LogError($"[AssetManager] 씬 로드 실패: {GetSafeAssetName(assetReference)}\n실제 키 값: {guidKey}");
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task UnloadScene(SceneInstance sceneInstance)
|
|
||||||
{
|
|
||||||
var handle = Addressables.UnloadSceneAsync(sceneInstance);
|
|
||||||
await handle.Task;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ReleaseAllCached()
|
public async Task UnloadScene(AssetReference assetReference)
|
||||||
{
|
{
|
||||||
if (_cachedHandles.Count == 0) return;
|
var guidKey = assetReference.AssetGUID;
|
||||||
|
|
||||||
foreach (var kvp in _cachedHandles)
|
if (_cachedScenes.TryGetValue(guidKey, out var cachedScene))
|
||||||
{
|
{
|
||||||
var handle = kvp.Value;
|
cachedScene.ReferenceCount--;
|
||||||
if (handle.IsValid())
|
|
||||||
|
if (cachedScene.ReferenceCount <= 0)
|
||||||
{
|
{
|
||||||
Addressables.Release(handle);
|
if (cachedScene.Handle.IsValid())
|
||||||
//Debug.Log($"[AssetManager] Released handle for key: {kvp.Key}");
|
{
|
||||||
|
var sceneName = cachedScene.Handle.Result.Scene.name;
|
||||||
|
await Addressables.UnloadSceneAsync(cachedScene.Handle).Task;
|
||||||
|
if (_enableDebugLog) Debug.Log($"[AssetManager] 씬 실제 언로드됨: {sceneName}\n실제 키 값: {guidKey}");
|
||||||
|
}
|
||||||
|
_cachedScenes.Remove(guidKey);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_cachedScenes[guidKey] = cachedScene;
|
||||||
|
if (_enableDebugLog) Debug.Log($"[AssetManager] 씬 참조 카운트 감소: {GetSafeAssetName(assetReference)} -> {cachedScene.ReferenceCount}\n실제 키 값: {guidKey}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_cachedHandles.Clear();
|
else
|
||||||
|
{
|
||||||
Debug.Log("[AssetManager] 모든 캐시된 Addressable 리소스를 해제했습니다.");
|
if (_enableDebugLog) Debug.LogWarning($"[AssetManager] 캐시에서 씬을 찾을 수 없음: {GetSafeAssetName(assetReference)}\n실제 키 값: {guidKey}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool HasLabel(string addressKey, string label)
|
public void ReleaseAllCached()
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
foreach (var kvp in _cachedAssets)
|
||||||
var settings = AddressableAssetSettingsDefaultObject.Settings;
|
{
|
||||||
if (settings == null) return false;
|
var cachedAsset = kvp.Value;
|
||||||
|
if (cachedAsset.Handle.IsValid())
|
||||||
|
{
|
||||||
|
Addressables.Release(cachedAsset.Handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_cachedAssets.Clear();
|
||||||
|
|
||||||
|
foreach (var kvp in _cachedScenes)
|
||||||
|
{
|
||||||
|
var cachedScene = kvp.Value;
|
||||||
|
if (cachedScene.Handle.IsValid())
|
||||||
|
{
|
||||||
|
Addressables.UnloadSceneAsync(cachedScene.Handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_cachedScenes.Clear();
|
||||||
|
|
||||||
var entry = settings.groups
|
if (_enableDebugLog) Debug.Log("[AssetManager] 모든 캐시된 Addressable 리소스를 강제 해제했습니다.");
|
||||||
.SelectMany(g => g.entries)
|
|
||||||
.FirstOrDefault(e => e.address == addressKey);
|
|
||||||
|
|
||||||
if (entry == null) return false;
|
|
||||||
|
|
||||||
return entry.labels.Contains(label);
|
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
3
Assets/_DDD/_Scripts/Game.meta
Normal file
3
Assets/_DDD/_Scripts/Game.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c82c9604b41d4755b70d679f3a0a3947
|
||||||
|
timeCreated: 1756279729
|
@ -1,4 +1,4 @@
|
|||||||
namespace DDD
|
namespace DDD.Restaurant
|
||||||
{
|
{
|
||||||
public interface IMovementConstraint
|
public interface IMovementConstraint
|
||||||
{
|
{
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
namespace DDD
|
namespace DDD
|
||||||
{
|
{
|
||||||
public class DataSo<T> : ScriptableObject where T : IId
|
public class DataAsset<T> : ScriptableObject where T : IId
|
||||||
{
|
{
|
||||||
[FormerlySerializedAs("Datas")] [SerializeField] protected List<T> _datas = new();
|
[FormerlySerializedAs("Datas")] [SerializeField] protected List<T> _datas = new();
|
||||||
|
|
@ -32,7 +32,7 @@ public void PostInit()
|
|||||||
|
|
||||||
private async Task LoadAllGameDataSo()
|
private async Task LoadAllGameDataSo()
|
||||||
{
|
{
|
||||||
var soList = await AssetManager.LoadAssetsByLabel<ScriptableObject>(SoLabel);
|
var soList = await AssetManager.Instance.LoadAssetsByLabel<ScriptableObject>(SoLabel);
|
||||||
|
|
||||||
foreach (var so in soList)
|
foreach (var so in soList)
|
||||||
{
|
{
|
||||||
@ -45,7 +45,7 @@ private async Task LoadAllGameDataSo()
|
|||||||
|
|
||||||
private async Task LoadSpriteAtlas()
|
private async Task LoadSpriteAtlas()
|
||||||
{
|
{
|
||||||
List<SpriteAtlas> spriteAtlases = await AssetManager.LoadAssetsByLabel<SpriteAtlas>(DataConstants.AtlasLabel);
|
List<SpriteAtlas> spriteAtlases = await AssetManager.Instance.LoadAssetsByLabel<SpriteAtlas>(DataConstants.AtlasLabel);
|
||||||
_spriteAtlas = new Dictionary<string, Sprite>(spriteAtlases.Count);
|
_spriteAtlas = new Dictionary<string, Sprite>(spriteAtlases.Count);
|
||||||
|
|
||||||
foreach (var atlas in spriteAtlases)
|
foreach (var atlas in spriteAtlases)
|
@ -21,19 +21,9 @@ public async Task LoadData()
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var gameLocalizationDataHandle = _gameLocalizationData.LoadAssetAsync<GameLocalizationData>();
|
|
||||||
var test = AssetManager.LoadAsset<GameLocalizationData>(_gameLocalizationData.AssetGUID);
|
|
||||||
var popupUiDataHandle = _uiData.LoadAssetAsync<UiData>();
|
|
||||||
|
|
||||||
await gameLocalizationDataHandle.Task;
|
LocalizationData = await AssetManager.Instance.LoadAssetAsync<GameLocalizationData>(_gameLocalizationData);
|
||||||
await popupUiDataHandle.Task;
|
UiData = await AssetManager.Instance.LoadAssetAsync<UiData>(_uiData);
|
||||||
|
|
||||||
LocalizationData = gameLocalizationDataHandle.Result;
|
|
||||||
UiData = popupUiDataHandle.Result;
|
|
||||||
|
|
||||||
Debug.Assert(LocalizationData != null, "GameLocalizationData is null");
|
|
||||||
Debug.Assert(UiData != null, "UiData is null");
|
|
||||||
|
|
||||||
_isLoaded = true;
|
_isLoaded = true;
|
||||||
}
|
}
|
||||||
@ -41,8 +31,16 @@ public async Task LoadData()
|
|||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
{
|
{
|
||||||
if (_isLoaded == false) return;
|
if (_isLoaded == false) return;
|
||||||
|
|
||||||
|
var assetManager = AssetManager.Instance;
|
||||||
|
if (!assetManager) return;
|
||||||
|
|
||||||
_gameLocalizationData.ReleaseAsset();
|
AssetManager.Instance.ReleaseAsset(_gameLocalizationData);
|
||||||
|
AssetManager.Instance.ReleaseAsset(_uiData);
|
||||||
|
|
||||||
|
LocalizationData = null;
|
||||||
|
UiData = null;
|
||||||
|
|
||||||
_isLoaded = false;
|
_isLoaded = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,13 +18,6 @@ public static class GameEvents
|
|||||||
public static InventoryChangedEvent InventoryChangedEvent = new();
|
public static InventoryChangedEvent InventoryChangedEvent = new();
|
||||||
public static SmartVariablesDirtyEvent SmartVariablesDirtyEvent = new();
|
public static SmartVariablesDirtyEvent SmartVariablesDirtyEvent = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RestaurantEvents
|
|
||||||
{
|
|
||||||
public static ItemSlotSelectedEvent ItemSlotSelectedEvent = new();
|
|
||||||
public static TodayMenuAddedEvent TodayMenuAddedEvent = new();
|
|
||||||
public static TodayMenuRemovedEvent TodayMenuRemovedEvent = new();
|
|
||||||
}
|
|
||||||
|
|
||||||
// public static class VoyageEvents
|
// public static class VoyageEvents
|
||||||
// {
|
// {
|
||||||
@ -105,20 +98,4 @@ public class SmartVariablesDirtyEvent : IEvent
|
|||||||
{
|
{
|
||||||
public SmartVariablesDomain DomainFlags;
|
public SmartVariablesDomain DomainFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region RestaurantInteractionEvents
|
|
||||||
|
|
||||||
public class ItemSlotSelectedEvent : IEvent
|
|
||||||
{
|
|
||||||
public ItemModel Model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TodayMenuAddedEvent : IEvent {}
|
|
||||||
|
|
||||||
public class TodayMenuRemovedEvent : IEvent
|
|
||||||
{
|
|
||||||
public InventoryCategoryType InventoryCategoryType;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
@ -10,7 +10,6 @@ public enum InteractionType : uint
|
|||||||
None = 0u,
|
None = 0u,
|
||||||
RestaurantManagement = 1u << 0,
|
RestaurantManagement = 1u << 0,
|
||||||
RestaurantOrder = 1u << 1,
|
RestaurantOrder = 1u << 1,
|
||||||
RestaurantMeal = 1u << 2,
|
|
||||||
RestaurantCook = 1u << 3,
|
RestaurantCook = 1u << 3,
|
||||||
All = 0xFFFFFFFFu
|
All = 0xFFFFFFFFu
|
||||||
}
|
}
|
||||||
@ -41,7 +40,7 @@ public interface IInteractable
|
|||||||
{
|
{
|
||||||
bool CanInteract();
|
bool CanInteract();
|
||||||
bool IsInteractionHidden();
|
bool IsInteractionHidden();
|
||||||
bool OnInteracted(IInteractor interactor, ScriptableObject causerPayload = null);
|
void OnInteracted(IInteractor interactor, ScriptableObject causerPayload = null);
|
||||||
InteractionType GetInteractionType();
|
InteractionType GetInteractionType();
|
||||||
GameObject GetInteractableGameObject();
|
GameObject GetInteractableGameObject();
|
||||||
void InitializeInteraction(InteractionType interactionType);
|
void InitializeInteraction(InteractionType interactionType);
|
@ -39,7 +39,7 @@ public static void Broadcast<T>(T evt) where T : IEvent
|
|||||||
{
|
{
|
||||||
foreach (var handler in list.Cast<IEventHandler<T>>())
|
foreach (var handler in list.Cast<IEventHandler<T>>())
|
||||||
{
|
{
|
||||||
handler.Invoke(evt);
|
handler.HandleEvent(evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,6 @@ namespace DDD
|
|||||||
{
|
{
|
||||||
public interface IEventHandler<in T> where T : IEvent
|
public interface IEventHandler<in T> where T : IEvent
|
||||||
{
|
{
|
||||||
void Invoke(T evt);
|
void HandleEvent(T evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using DDD.Restaurant;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Localization.SmartFormat.PersistentVariables;
|
using UnityEngine.Localization.SmartFormat.PersistentVariables;
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ public void PostInit()
|
|||||||
EventBus.Register<SmartVariablesDirtyEvent>(this);
|
EventBus.Register<SmartVariablesDirtyEvent>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Invoke(SmartVariablesDirtyEvent evt)
|
public void HandleEvent(SmartVariablesDirtyEvent evt)
|
||||||
{
|
{
|
||||||
var flags = evt.DomainFlags;
|
var flags = evt.DomainFlags;
|
||||||
if (flags == SmartVariablesDomain.All)
|
if (flags == SmartVariablesDomain.All)
|
@ -84,7 +84,7 @@ public async Task PreloadAll()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var instance = await AssetManager.LoadScene(flowAssetPair.Value, activateOnLoad:false);
|
var instance = await AssetManager.Instance.LoadScene(flowAssetPair.Value, activateOnLoad:false);
|
||||||
if (!instance.Scene.IsValid())
|
if (!instance.Scene.IsValid())
|
||||||
{
|
{
|
||||||
Debug.LogError($"[SceneManager] {flowAssetPair.Key}의 씬 로딩 실패");
|
Debug.LogError($"[SceneManager] {flowAssetPair.Key}의 씬 로딩 실패");
|
||||||
@ -114,7 +114,7 @@ public async Task PreloadScene(GameFlowState gameFlowState)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var loadedInstance = await AssetManager.LoadScene(assetRef);
|
var loadedInstance = await AssetManager.Instance.LoadScene(assetRef);
|
||||||
if (!loadedInstance.Scene.IsValid())
|
if (!loadedInstance.Scene.IsValid())
|
||||||
{
|
{
|
||||||
Debug.LogError($"[SceneManager] {gameFlowState}의 씬 로딩 실패");
|
Debug.LogError($"[SceneManager] {gameFlowState}의 씬 로딩 실패");
|
||||||
@ -170,7 +170,7 @@ public async Task UnloadScene(GameFlowState gameFlowState)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_loadedSceneDatas.Remove(gameFlowState);
|
_loadedSceneDatas.Remove(gameFlowState);
|
||||||
await AssetManager.UnloadScene(sceneData.SceneInstance.Value);
|
await AssetManager.Instance.UnloadScene(assetRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +68,7 @@ private void UpdateTimeScale()
|
|||||||
|
|
||||||
public bool IsPaused => Mathf.Approximately(CurrentTimeScale, 0f);
|
public bool IsPaused => Mathf.Approximately(CurrentTimeScale, 0f);
|
||||||
|
|
||||||
public void Invoke(TimeScaleChangeEvent evt)
|
public void HandleEvent(TimeScaleChangeEvent evt)
|
||||||
{
|
{
|
||||||
if (evt.NewTimeScale < 1f)
|
if (evt.NewTimeScale < 1f)
|
||||||
{
|
{
|
@ -18,6 +18,6 @@ public InventoryItemData(string id, int quantity)
|
|||||||
Quantity = quantity;
|
Quantity = quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemData ItemData => InventoryManager.Instance.GetItemDataByIdOrNull(Id);
|
public ItemDataEntry ItemDataEntry => InventoryManager.Instance.GetItemDataByIdOrNull(Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,7 +19,7 @@ public class InventoryManager : Singleton<InventoryManager>, IManager
|
|||||||
{
|
{
|
||||||
[Title("아이템 전체 목록")]
|
[Title("아이템 전체 목록")]
|
||||||
[ShowInInspector, ReadOnly]
|
[ShowInInspector, ReadOnly]
|
||||||
private Dictionary<string, ItemData> _allItemDataLookup;
|
private Dictionary<string, ItemDataEntry> _allItemDataLookup;
|
||||||
|
|
||||||
[Title("아이템 보유 목록")]
|
[Title("아이템 보유 목록")]
|
||||||
[ShowInInspector, ReadOnly]
|
[ShowInInspector, ReadOnly]
|
||||||
@ -27,6 +27,7 @@ public class InventoryManager : Singleton<InventoryManager>, IManager
|
|||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
[Title("테스트용")]
|
[Title("테스트용")]
|
||||||
|
[SerializeField]
|
||||||
private InventoryTestDataSo _inventoryTestDataSo;
|
private InventoryTestDataSo _inventoryTestDataSo;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ public void PostInit()
|
|||||||
|
|
||||||
private void InitializeItemData()
|
private void InitializeItemData()
|
||||||
{
|
{
|
||||||
var itemDataSo = DataManager.Instance.GetDataSo<ItemDataSo>();
|
var itemDataSo = DataManager.Instance.GetDataSo<ItemDataAsset>();
|
||||||
Debug.Assert(itemDataSo != null, "itemDataSo != null");
|
Debug.Assert(itemDataSo != null, "itemDataSo != null");
|
||||||
|
|
||||||
_allItemDataLookup = itemDataSo.GetDataList()
|
_allItemDataLookup = itemDataSo.GetDataList()
|
||||||
@ -62,12 +63,8 @@ private void InitializeItemData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
private async void ApplyEditorTestData()
|
private void ApplyEditorTestData()
|
||||||
{
|
{
|
||||||
_inventoryTestDataSo = await AssetManager.LoadAsset<InventoryTestDataSo>(DataConstants.InventoryTestDataSo);
|
|
||||||
|
|
||||||
if (_inventoryTestDataSo == null || !_inventoryTestDataSo.UseTestData) return;
|
|
||||||
|
|
||||||
foreach (var entry in _inventoryTestDataSo.TestItems)
|
foreach (var entry in _inventoryTestDataSo.TestItems)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(entry.ItemId)) continue;
|
if (string.IsNullOrWhiteSpace(entry.ItemId)) continue;
|
||||||
@ -132,12 +129,12 @@ public bool RemoveItem(string id, int quantity = 1)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IReadOnlyDictionary<string, ItemData> AllItemDataLookup => _allItemDataLookup;
|
public IReadOnlyDictionary<string, ItemDataEntry> AllItemDataLookup => _allItemDataLookup;
|
||||||
public IReadOnlyDictionary<string, InventoryItemData> InventoryItems => _inventoryItemDatas;
|
public IReadOnlyDictionary<string, InventoryItemData> InventoryItems => _inventoryItemDatas;
|
||||||
public bool ContainInventoryItem(string id) => _inventoryItemDatas.ContainsKey(id);
|
public bool ContainInventoryItem(string id) => _inventoryItemDatas.ContainsKey(id);
|
||||||
public bool TryGetInventoryItemData(string id, out InventoryItemData inventoryItemData) => _inventoryItemDatas.TryGetValue(id, out inventoryItemData);
|
public bool TryGetInventoryItemData(string id, out InventoryItemData inventoryItemData) => _inventoryItemDatas.TryGetValue(id, out inventoryItemData);
|
||||||
public int GetItemCount(string id) => _inventoryItemDatas.TryGetValue(id, out var itemData) ? itemData.Quantity : 0;
|
public int GetItemCount(string id) => _inventoryItemDatas.TryGetValue(id, out var itemData) ? itemData.Quantity : 0;
|
||||||
public ItemData GetItemDataByIdOrNull(string id)
|
public ItemDataEntry GetItemDataByIdOrNull(string id)
|
||||||
{
|
{
|
||||||
_allItemDataLookup.TryGetValue(id, out var itemData);
|
_allItemDataLookup.TryGetValue(id, out var itemData);
|
||||||
return itemData;
|
return itemData;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user