Skip to content

Commit c344514

Browse files
committed
Add MusicPlayerSingleton class in Samples
1 parent 8b1515b commit c344514

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using OpenMusicPlayer.Core;
2+
3+
namespace OpenMusicPlayer.Samples.Singleton
4+
{
5+
public class MusicPlayerSingleton: MusicPlayerCore
6+
{
7+
public static MusicPlayerSingleton Instance {get; private set;}
8+
9+
protected override void Awake()
10+
{
11+
base.Awake();
12+
// Make unique object (Singleton)
13+
if (Instance != null && Instance != this)
14+
{
15+
// Destroy other
16+
Destroy(gameObject);
17+
}
18+
else
19+
{
20+
Instance = this;
21+
// Add don't destroy on load.
22+
DontDestroyOnLoad(this);
23+
}
24+
}
25+
}
26+
}

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/Aestial"
88
},
99
"license": "MIT",
10-
"version": "0.1.7",
10+
"version": "0.1.8",
1111
"unity": "2019.4",
1212
"description": "Open and simple music playback system based on Events and ScriptableObjects playlists",
1313
"keywords": [
@@ -40,7 +40,12 @@
4040
{
4141
"displayName": "HUD Samples",
4242
"description": "Multiple music player HUD views",
43-
"path": "Samples~/HUD"
43+
"path": "Samples~/HUD"
44+
},
45+
{
46+
"displayName": "Singleton Player",
47+
"description": "Don't Destroy On Load singleton wrapper",
48+
"path": "Samples~/Singleton"
4449
}
4550
]
4651
}

0 commit comments

Comments
 (0)