Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Runtime/AddresssablesExtensions/LifetimeManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static ReleaseHandleOnDestroy AddAutoReleaseTrigger(AsyncOperationHandle
{
_ = targetGO ?? throw new ArgumentNullException(nameof(targetGO));

var trigger = targetGO.AddComponent<ReleaseHandleOnDestroy>();
var trigger = targetGO.GetComponent<ReleaseHandleOnDestroy>() ?? targetGO.AddComponent<ReleaseHandleOnDestroy>();

trigger.OnDestroyEvent += () => Addressables.Release(operationHandle);

Expand Down
8 changes: 4 additions & 4 deletions Runtime/ManageAddressables.BaseMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public static void Instantiate(AssetReference reference,
/// <param name="targetGO">The object to which the trigger will be attached.</param>
public static void AddAutoReleaseAssetTrigger(string key, GameObject targetGO)
{
targetGO.AddComponent<ReleaseHandleOnDestroy>().OnDestroyEvent +=
(targetGO.GetComponent<ReleaseHandleOnDestroy>() ?? targetGO.AddComponent<ReleaseHandleOnDestroy>()).OnDestroyEvent +=
() => ReleaseAsset(key);
}

Expand All @@ -248,7 +248,7 @@ public static void AddAutoReleaseAssetTrigger(string key, GameObject targetGO)
/// <param name="targetGO">The object to which the trigger will be attached.</param>
public static void AddAutoReleaseAssetTrigger(AssetReference assetReference, GameObject targetGO)
{
targetGO.AddComponent<ReleaseHandleOnDestroy>().OnDestroyEvent +=
(targetGO.GetComponent<ReleaseHandleOnDestroy>() ?? targetGO.AddComponent<ReleaseHandleOnDestroy>()).OnDestroyEvent +=
() => ReleaseAsset(assetReference);
}

Expand All @@ -261,7 +261,7 @@ public static void AddAutoReleaseAssetTrigger(AssetReference assetReference, Gam
/// <param name="targetGO">The object to which the trigger will be attached.</param>
public static void AddAutoReleaseInstanceTrigger(string key, GameObject targetGO)
{
targetGO.AddComponent<ReleaseHandleOnDestroy>().OnDestroyEvent +=
(targetGO.GetComponent<ReleaseHandleOnDestroy>() ?? targetGO.AddComponent<ReleaseHandleOnDestroy>()).OnDestroyEvent +=
() => ReleaseInstance(key, targetGO);
}

Expand All @@ -274,7 +274,7 @@ public static void AddAutoReleaseInstanceTrigger(string key, GameObject targetGO
/// <param name="targetGO">The object to which the trigger will be attached.</param>
public static void AddAutoReleaseInstanceTrigger(AssetReference assetReference, GameObject targetGO)
{
targetGO.AddComponent<ReleaseHandleOnDestroy>().OnDestroyEvent +=
(targetGO.GetComponent<ReleaseHandleOnDestroy>() ?? targetGO.AddComponent<ReleaseHandleOnDestroy>()).OnDestroyEvent +=
() => ReleaseInstance(assetReference, targetGO);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Runtime/ManageAddressables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private static void ReleaseInstanceInternal(string key, GameObject instance)
return;
}

var index = instanceList.FindIndex(x => x.GetInstanceID() == instance.GetInstanceID());
var index = instanceList.FindIndex(x => x == instance);

if (index < 0)
{
Expand Down
1 change: 1 addition & 0 deletions Runtime/ReleaseHandleOnDestroy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace AddressablesMaster
{
[DisallowMultipleComponent]
public class ReleaseHandleOnDestroy : MonoBehaviour
{
public void OnDestroy()
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.inc8877.addressables-master",
"version": "1.0.2",
"version": "1.0.3",
"displayName": "AddressablesMaster",
"description": "Use Sync, Async(.NET / UniTask), Coroutine, Lifetime management tools for addressables assets with caching support",
"homepage": "https://github.com/inc8877/AddressablesMaster#readme",
Expand All @@ -18,7 +18,7 @@
"url": "https://github.com/inc8877/AddressablesMaster.git"
},
"dependencies": {
"com.unity.addressables": "1.6.0"
"com.unity.addressables": "2.9.1"
},
"author": {
"name": "Volodymyr Bozhko",
Expand Down