Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite902a9f

Browse files
committed
Add Init for existing instance and basic editor mode support
1 parenta61f77a commite902a9f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

‎Assets/Scripts/MonoSingleton.cs‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,25 @@ protected virtual void Awake ()
5050
if(instance==null)
5151
{
5252
instance=thisasT;
53-
DontDestroyOnLoad(gameObject);
53+
54+
if(Application.isPlaying)
55+
{
56+
DontDestroyOnLoad(gameObject);
57+
}
58+
59+
// Init existing instance
60+
Init();
5461
}
5562
else
5663
{
57-
Destroy(gameObject);
64+
if(Application.isPlaying)
65+
{
66+
Destroy(gameObject);
67+
}
68+
else
69+
{
70+
DestroyImmediate(gameObject);
71+
}
5872
}
5973
}
6074

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp