Esempio n. 1
0
        private void Start()
        {
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("Base component is invalid.");
                return;
            }

            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("Event component is invalid.");
                return;
            }

            if (baseComponent.EditorResourceMode)
            {
                m_SoundManager.SetResourceManager(baseComponent.EditorResourceHelper);
            }
            else
            {
                m_SoundManager.SetResourceManager(GameFrameworkEntry.GetModule <IResourceManager>());
            }

            SoundHelperBase soundHelper = Utility.Helper.CreateHelper(m_SoundHelperTypeName, m_CustomSoundHelper);

            if (soundHelper == null)
            {
                Log.Error("Can not create sound helper.");
                return;
            }

            soundHelper.name = string.Format("Sound Helper");
            Transform transform = soundHelper.transform;

            transform.SetParent(this.transform);
            transform.localScale = Vector3.one;

            m_SoundManager.SetSoundHelper(soundHelper);

            if (m_InstanceRoot == null)
            {
                m_InstanceRoot = (new GameObject("Sound Instances")).transform;
                m_InstanceRoot.SetParent(gameObject.transform);
            }

            foreach (SoundGroup soundGroup in m_SoundGroups)
            {
                if (!AddSoundGroup(soundGroup.Name, soundGroup.AvoidBeingReplacedBySamePriority, soundGroup.Mute, soundGroup.Volume, soundGroup.AgentHelperCount))
                {
                    Log.Warning("Add sound group '{0}' failure.", soundGroup.Name);
                    continue;
                }
            }

            m_AudioListener = gameObject.GetOrAddComponent <AudioListener>();
            RefreshAudioListener();
        }
        private void Start()
        {
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("Base component is invalid.");
                return;
            }

            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("Event component is invalid.");
                return;
            }

            if (baseComponent.EditorResourceMode)
            {
                m_SoundManager.SetResourceManager(baseComponent.EditorResourceHelper);
            }
            else
            {
                m_SoundManager.SetResourceManager(GameFrameworkEntry.GetModule <IResourceManager>());
            }

            SoundHelperBase soundHelper = Helper.CreateHelper(m_SoundHelperTypeName, m_CustomSoundHelper);

            if (soundHelper == null)
            {
                Log.Error("Can not create sound helper.");
                return;
            }

            soundHelper.name = "Sound Helper";
            Transform transform = soundHelper.transform;

            transform.SetParent(this.transform);
            transform.localScale = Vector3.one;

            m_SoundManager.SetSoundHelper(soundHelper);

            if (m_InstanceRoot == null)
            {
                m_InstanceRoot = (new GameObject("Sound Instances")).transform;
                m_InstanceRoot.SetParent(gameObject.transform);
                m_InstanceRoot.localScale = Vector3.one;
            }

            for (int i = 0; i < m_SoundGroups.Length; i++)
            {
                if (!AddSoundGroup(m_SoundGroups[i].Name, m_SoundGroups[i].AvoidBeingReplacedBySamePriority, m_SoundGroups[i].Mute, m_SoundGroups[i].Volume, m_SoundGroups[i].AgentHelperCount))
                {
                    Log.Warning("Add sound group '{0}' failure.", m_SoundGroups[i].Name);
                    continue;
                }
            }
        }
Esempio n. 3
0
        private void Start()
        {
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("Base component is invalid.");
                return;
            }

            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("Event component is invalid.");
                return;
            }

            if (baseComponent.EditorResourceMode)
            {
                m_SoundManager.SetResourceManager(baseComponent.EditorResourceHelper);
            }
            else
            {
                m_SoundManager.SetResourceManager(GameFrameworkEntry.GetModule <IResourceManager>());
            }

            m_SoundManager.SetObjectPoolManager(GameFrameworkEntry.GetModule <IObjectPoolManager>());
            m_SoundManager.AssetCapacity = m_AssetCapacity;

            if (m_SoundHelper == null)
            {
                m_SoundHelper      = (new GameObject()).AddComponent <DefaultSoundHelper>();
                m_SoundHelper.name = string.Format("Sound Helper");
                Transform transform = m_SoundHelper.transform;
                transform.SetParent(this.transform);
                transform.localScale = Vector3.one;
            }

            m_SoundManager.SetSoundHelper(m_SoundHelper);

            if (m_InstanceRoot == null)
            {
                m_InstanceRoot = (new GameObject("Sound Instances")).transform;
                m_InstanceRoot.SetParent(gameObject.transform);
            }

            foreach (SoundGroup soundGroup in m_SoundGroups)
            {
                if (!AddSoundGroup(soundGroup.Name, soundGroup.AvoidBeingReplacedBySamePriority, soundGroup.Mute, soundGroup.Volume, soundGroup.AgentHelperCount))
                {
                    Log.Warning("Add sound group '{0}' failed.", soundGroup.Name);
                    continue;
                }
            }
        }