Ejemplo n.º 1
0
        private AudioSource PlayObject(GameObject go, string clipName, float volume, float time, AudioMixerGroup mixerGroup = null, bool isLoop = false, bool fadeIn = false)
        {
            AudioSource audioSource = go.GetOrCreateComponent <AudioSource>();

#if DATA_GENER
            if (isLocalization)
            {
                if (LanguageManager.ContainKey(clipName))
                {
                    clipName = LanguageManager.GetWord(clipName);
                }
            }
#endif
            audioSource.clip = ResourcesLoaderHelper.Instance.LoadResource <AudioClip>(clipName);
            audioSource.outputAudioMixerGroup = mixerGroup;
            audioSource.loop   = isLoop;
            audioSource.volume = volume;
            audioSource.Play();
            if (time > 0)
            {
                CoroutineTaskManager.Instance.WaitSecondTodo(() =>
                {
                    if (audioSource == null)
                    {
                        return;
                    }
                    audioSource.Stop();
                }, time);
            }
            return(audioSource);
        }
Ejemplo n.º 2
0
        private void Fix()
        {
            UILocalization local = target as UILocalization;
            Text           txt   = local.gameObject.GetComponent <Text>();
            Image          img   = local.gameObject.GetComponent <Image>();

            int id;

            if (string.IsNullOrEmpty(local.key) || int.TryParse(local.key.Substring(1), out id))
            {
                local.key = LanguageManager.GetAvalibleKey();
            }

            if (txt != null)
            {
                string key = local.key;

                if (LanguageManager.TryGetKey(txt.text, out key))
                {
                    local.key = key;
                    return;
                }
                else
                {
                    LanguageManager.Refresh();
                    if (!LanguageManager.ContainKey(local.key))
                    {
                        LanguageManager.AddNewWord(local.key, txt.text);
                        AssetDatabase.Refresh();
                    }
                    else
                    {
                        local.key = "_" + local.key;
                        Fix();
                    }
                    LanguageManager.Refresh();
                }
            }
            else
            {
                Debug.logger.LogError("DataGener", "不存在Text");
            }
        }