gabec
New Member
Posts: 16
Posts: 16
|
Post by gabec on Feb 14, 2017 23:46:19 GMT
Hi, I'm trying to Start/Stop a playlist via code, my playlist as i have it in the MA Prefab is called "Attack Mode" but I can't seem to get this right
I'm entering DarkTonic.MasterAudio.PlaylistController.StartPlaylist("Attack Mode"); but it doesn't work. Also tried "AttackMode". I know I'm missing something basic here, wondering if I need to make my "Attack Mode" name in the prefab one word?
Thanks much
EDIT: The NRE i get is "An object reference is required to access non-static member 'DarkTonic.MasterAudio.PlaylistController.StartPlaylist(string)'
|
|
|
Post by DarkTonic Dev on Feb 15, 2017 0:30:29 GMT
You need another "MasterAudio". It's both the namespace and the class name. And you don't need "PlaylistController" at all if you only have one.
This will work. But it's a bit long.
DarkTonic.MasterAudio.MasterAudio.StartPlaylist("Attack Mode");
But it's better to just put a using statement at the top of the class so you don't have to keep typing that stuff, like this.
using DarkTonic.MasterAudio;
public class X : MonoBehaviour { void MethodX() { MasterAudio.StartPlaylist("Attack Mode"); } }
|
|
gabec
New Member
Posts: 16
Posts: 16
|
Post by gabec on Feb 15, 2017 1:21:08 GMT
Wow that worked, thanks so much great info here, going in my notes. Thanks for the quick reply as usual!
|
|
|
Post by DarkTonic Dev on Feb 15, 2017 1:41:47 GMT
No sweat!
|
|