示例#1
0
    public void Init(AkInitializer akInitializer)
    {
        if (akInitializer == null)
        {
            UnityEngine.Debug.LogError("WwiseUnity: AkInitializer must not be null. Sound engine will not be initialized.");
            return;
        }

#if UNITY_EDITOR
        if (UnityEngine.Application.isPlaying && !IsTheSingleOwningInitializer(akInitializer))
        {
            UnityEngine.Debug.LogError("WwiseUnity: Sound engine is already initialized.");
            return;
        }

        var arguments = System.Environment.GetCommandLineArgs();
        if (System.Array.IndexOf(arguments, "-nographics") >= 0 &&
            System.Array.IndexOf(arguments, "-wwiseEnableWithNoGraphics") < 0)
        {
            return;
        }

        var isInitialized = false;
        try
        {
            isInitialized       = AkSoundEngine.IsInitialized();
            IsSoundEngineLoaded = true;
        }
        catch (System.DllNotFoundException)
        {
            IsSoundEngineLoaded = false;
            UnityEngine.Debug.LogWarning("WwiseUnity: AkSoundEngine is not loaded.");
            return;
        }
#else
        bool isInitialized = AkSoundEngine.IsInitialized();
#endif

        AkLogger.Instance.Init();

        if (isInitialized)
        {
#if UNITY_EDITOR
            if (AkWwiseInitializationSettings.ResetSoundEngine(UnityEngine.Application.isPlaying || UnityEditor.BuildPipeline.isBuildingPlayer))
            {
                UnityEditor.EditorApplication.update += LateUpdate;
            }
#else
            UnityEngine.Debug.LogError("WwiseUnity: Sound engine is already initialized.");
#endif
            return;
        }

#if UNITY_EDITOR
        if (UnityEditor.BuildPipeline.isBuildingPlayer)
        {
            return;
        }
#endif

        if (!AkWwiseInitializationSettings.InitializeSoundEngine())
        {
            return;
        }

#if UNITY_EDITOR
        OnEnableEditorListener(akInitializer.gameObject);
        UnityEditor.EditorApplication.update += LateUpdate;
#endif
    }
    public void Init(AkInitializer akInitializer)
    {
#if UNITY_EDITOR
        if (!WasInitializedInPlayMode(akInitializer))
        {
            return;
        }

        var arguments = System.Environment.GetCommandLineArgs();
        if (System.Array.IndexOf(arguments, "-nographics") >= 0 &&
            System.Array.IndexOf(arguments, "-wwiseEnableWithNoGraphics") < 0)
        {
            return;
        }

        var isInitialized = false;
        try
        {
            isInitialized       = AkSoundEngine.IsInitialized();
            IsSoundEngineLoaded = true;
        }
        catch (System.DllNotFoundException)
        {
            IsSoundEngineLoaded = false;
            UnityEngine.Debug.LogWarning("WwiseUnity: AkSoundEngine is not loaded.");
            return;
        }
#else
        bool isInitialized = AkSoundEngine.IsInitialized();
#endif

        AkLogger.Instance.Init();

        if (isInitialized)
        {
#if UNITY_EDITOR
            if (AkWwiseInitializationSettings.ResetSoundEngine(UnityEngine.Application.isPlaying || UnityEditor.BuildPipeline.isBuildingPlayer))
            {
                UnityEditor.EditorApplication.update += LateUpdate;
            }
#endif
            return;
        }

#if UNITY_EDITOR
        if (UnityEditor.BuildPipeline.isBuildingPlayer)
        {
            return;
        }
#endif

        if (!AkWwiseInitializationSettings.InitializeSoundEngine())
        {
            return;
        }

#if UNITY_EDITOR
#if UNITY_2017_2_OR_NEWER
        UnityEditor.EditorApplication.pauseStateChanged += OnPauseStateChanged;
#else
        UnityEditor.EditorApplication.playmodeStateChanged += OnEditorPlaymodeStateChanged;
#endif

        OnEnableEditorListener(akInitializer.gameObject);
        UnityEditor.EditorApplication.update += LateUpdate;
#endif
    }