Exemple #1
0
        internal SFXPlayer(AudioClipsStorer clipsStorer)
        {
            var updater = SharedServices.GetService <IUpdateScheduler>();

            if (updater == null)
            {
                updater = new UnityUpdateScheduler();
                SharedServices.RegisterService(updater);
            }
            var dispatcher = SharedServices.GetService <EventDispatcher>();

            if (dispatcher == null)
            {
                dispatcher = new EventDispatcher();
                SharedServices.RegisterService(dispatcher);
            }

            updater.ScheduleUpdate(this);
            dispatcher.AddListener <SceneManagementService.SceneUnloadedEvent>(OnSceneUnloaded);
            _clipStorer = clipsStorer;
            for (int i = 0; i < 10; ++i)
            {
                CreateHandler();
            }
        }
 void Start()
 {
     _text    = GetComponent <Text>();
     _tmpText = GetComponent <TextMeshProUGUI>();
     if (_text == null && _tmpText == null)
     {
         Debug.LogError("Added a LocalizedText component to a gameobject with no ui text");
         return;
     }
     if (string.IsNullOrEmpty(_key))
     {
         if (_text != null)
         {
             _key = _text.text;
         }
         else if (_tmpText != null)
         {
             _key = _tmpText.text;
         }
     }
     _service = SharedServices.GetService <ILocalizationService>();
     if (_service == null)
     {
         _service = new LocalLocalizationService();
         _service.Initialize(UpdateText);
         SharedServices.RegisterService <ILocalizationService>(_service);
     }
     _service.OnLocalizationChanged += UpdateText;
 }
Exemple #3
0
 internal MusicPlayer(AudioClipsStorer clipStorer)
 {
     if (!SharedServices.HasService <ICoroutineRunner>())
     {
         SharedServices.RegisterService <ICoroutineRunner>(new CoroutineRunner());
     }
     _clipStorer = clipStorer;
     _source     = new GameObject("MusicPlayer").AddComponent <AudioSource>();
     UnityEngine.Object.DontDestroyOnLoad(_source.gameObject);
     _source.playOnAwake  = false;
     _source.spatialBlend = 0f;
 }