scriptableObject 메모리 누수 방지

This commit is contained in:
NTG 2025-08-26 18:55:57 +09:00
parent 8bfb378818
commit 851e95cdcc
3 changed files with 17 additions and 4 deletions

View File

@ -10,5 +10,11 @@ private void OnEnable()
LevelState = CreateInstance<GameLevelState>(); LevelState = CreateInstance<GameLevelState>();
UiState = CreateInstance<UiState>(); UiState = CreateInstance<UiState>();
} }
private void OnDisable()
{
if (LevelState) DestroyImmediate(LevelState);
if (UiState) DestroyImmediate(UiState);
}
} }
} }

View File

@ -11,8 +11,8 @@ public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable in
var cookwareTypePayload = targetPayloadSo as CookwareTypePayload; var cookwareTypePayload = targetPayloadSo as CookwareTypePayload;
var evt = GameEvents.OpenPopupUiEvent; var evt = GameEvents.OpenPopupUiEvent;
//evt.UiType = typeof(CookUi); evt.UiType = typeof(CookUi);
//evt.Payload = cookwareTypePayload.CookwareType; evt.Payload = cookwareTypePayload.CookwareType;
EventBus.Broadcast(evt); EventBus.Broadcast(evt);
return true; return true;
} }

View File

@ -1,5 +1,3 @@
using UnityEngine;
namespace DDD namespace DDD
{ {
public class RestaurantState : ScriptSingleton<RestaurantState> public class RestaurantState : ScriptSingleton<RestaurantState>
@ -18,5 +16,14 @@ private void OnEnable()
PlayerState = CreateInstance<RestaurantPlayerState>(); PlayerState = CreateInstance<RestaurantPlayerState>();
CustomerState = CreateInstance<RestaurantCustomerState>(); CustomerState = CreateInstance<RestaurantCustomerState>();
} }
private void OnDisable()
{
if (ManagementState) DestroyImmediate(ManagementState);
if (RunState) DestroyImmediate(RunState);
if (EnvironmentState) DestroyImmediate(EnvironmentState);
if (PlayerState) DestroyImmediate(PlayerState);
if (CustomerState) DestroyImmediate(CustomerState);
}
} }
} }