-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b4046cc
commit 39f25ec
Showing
2 changed files
with
13 additions
and
7 deletions.
There are no files selected for viewing
19 changes: 12 additions & 7 deletions
19
Packages/MinimalUtility/Runtime/Internal/DontDestroyObject.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
#nullable enable | ||
|
||
using System.Runtime.CompilerServices; | ||
using UnityEngine; | ||
|
||
namespace MinimalUtility.Internal | ||
{ | ||
internal static class DontDestroyObject | ||
{ | ||
public static Transform Root => Default.transform; | ||
public static Transform Root | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get => Shared.transform; | ||
} | ||
|
||
public static GameObject Default | ||
public static GameObject Shared | ||
{ | ||
get | ||
{ | ||
if (s_default == null) | ||
if (s_shared == null) | ||
{ | ||
s_default = new GameObject("MinimalUtility." + nameof(DontDestroyObject)); | ||
Object.DontDestroyOnLoad(s_default); | ||
s_shared = new GameObject("MinimalUtility." + nameof(DontDestroyObject)); | ||
Object.DontDestroyOnLoad(s_shared); | ||
} | ||
return s_default; | ||
return s_shared; | ||
} | ||
} | ||
|
||
private static GameObject? s_default; | ||
private static GameObject? s_shared; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters