コード例 #1
0
    public static bool AutoPopulate()
    {
        if (!System.IO.File.Exists(AudioPluginSettingAgent.DeveloperWwiseProjectPath))
        {
            AkWwisePicker.WwiseProjectFound = false;
            return(false);
        }

        AkWwisePicker.WwiseProjectFound = true;

        if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || string.IsNullOrEmpty(s_wwiseProjectPath) ||
            UnityEditor.EditorApplication.isCompiling)
        {
            return(false);
        }

        AkPluginActivator.Update();

        var builder = new AkWwiseWWUBuilder();

        if (!builder.GatherModifiedFiles())
        {
            return(false);
        }

        builder.UpdateFiles();
        return(true);
    }
コード例 #2
0
    public static bool AutoPopulate()
    {
        if (!System.IO.File.Exists(AkUtilities.GetFullPath(UnityEngine.Application.dataPath,
                                                           WwiseSetupWizard.Settings.WwiseProjectPath)))
        {
            AkWwisePicker.WwiseProjectFound = false;
            return(false);
        }

        AkWwisePicker.WwiseProjectFound = true;

        if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || string.IsNullOrEmpty(s_wwiseProjectPath) ||
            UnityEditor.EditorApplication.isCompiling)
        {
            return(false);
        }

        AkPluginActivator.Update();

        var builder = new AkWwiseWWUBuilder();

        if (!builder.GatherModifiedFiles())
        {
            return(false);
        }

        builder.UpdateFiles();
        return(true);
    }
コード例 #3
0
    public void OnPostprocessBuild(BuildTarget target, string path)
    {
#endif
        AkPluginActivator.ActivatePluginsForDeployment(target, false);
        DeleteSoundbanks(destinationSoundBankFolder);
        destinationSoundBankFolder = string.Empty;
    }
コード例 #4
0
    public static bool AutoPopulate()
    {
        if (!File.Exists(AkUtilities.GetFullPath(Application.dataPath, WwiseSetupWizard.Settings.WwiseProjectPath)))
        {
            AkWwisePicker.WwiseProjectFound = false;
            return(false);
        }
        else
        {
            AkWwisePicker.WwiseProjectFound = true;
        }

        if (EditorApplication.isPlayingOrWillChangePlaymode || String.IsNullOrEmpty(s_wwiseProjectPath) || EditorApplication.isCompiling)
        {
            return(false);
        }

        AkPluginActivator.Update();

        if (!AkWwiseProjectInfo.GetData().autoPopulateEnabled)
        {
            return(false);
        }

        AkWwiseWWUBuilder builder = new AkWwiseWWUBuilder();

        if (!builder.GatherModifiedFiles())
        {
            return(false);
        }

        builder.UpdateFiles();
        return(true);
    }
コード例 #5
0
    public static void PerformMigration(int migrateStart)
    {
        UpdateProgressBar(0);

        UnityEngine.Debug.Log("WwiseUnity: Migrating from Unity Integration Version " + migrateStart + " to " + AkUtilities.MigrationStopIndex);

        AkPluginActivator.DeactivateAllPlugins();
        AkPluginActivator.Update();
        AkPluginActivator.ActivatePluginsForEditor();

        // Get the name of the currently opened scene.
        var activeScene     = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
        var loadedScenePath = activeScene.path;

        if (!string.IsNullOrEmpty(loadedScenePath))
        {
            AkBasePathGetter.FixSlashes(ref loadedScenePath, '\\', '/', false);
        }

        UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects);

        // obtain a list of ScriptableObjects before any migration is performed
        ScriptableObjectGuids = UnityEditor.AssetDatabase.FindAssets("t:ScriptableObject", new[] { "Assets" });

        AkUtilities.BeginMigration(migrateStart);
        AkWwiseProjectInfo.GetData().Migrate();
        AkWwiseWWUBuilder.UpdateWwiseObjectReferenceData();

        MigratePrefabs();
        MigrateScenes();
        MigrateScriptableObjects();

        UnityEditor.EditorUtility.UnloadUnusedAssetsImmediate();

        UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects);
        AkUtilities.EndMigration();

        UpdateProgressBar(TotalNumberOfSections);

        // Reopen the scene that was opened before the migration process started.
        if (!string.IsNullOrEmpty(loadedScenePath))
        {
            UnityEditor.SceneManagement.EditorSceneManager.OpenScene(loadedScenePath);
        }

        UnityEngine.Debug.Log("WwiseUnity: Removing lock for launcher.");

        // TODO: Moving one folder up is not nice at all. How to find the current project path?
        try
        {
            System.IO.File.Delete(UnityEngine.Application.dataPath + "/../.WwiseLauncherLockFile");
        }
        catch (System.Exception)
        {
            // Ignore if not present.
        }

        UnityEditor.EditorUtility.ClearProgressBar();
    }
コード例 #6
0
    public static void PerformMigration(int migrateStart, int migrateStop)
    {
        UpdateProgressBar(0f);

        UnityEngine.Debug.Log("WwiseUnity: Migrating incrementally to versions " + migrateStart + " up to " + migrateStop);

        AkPluginActivator.DeactivateAllPlugins();
        AkPluginActivator.Update();
        AkPluginActivator.ActivatePluginsForEditor();

        // Get the name of the currently opened scene.
        var currentScene = AkSceneUtils.GetCurrentScene().Replace('/', '\\');

        var files =
            new System.IO.DirectoryInfo(UnityEngine.Application.dataPath + "/Wwise/Deployment/Components").GetFiles("*.cs",
                                                                                                                    System.IO.SearchOption.AllDirectories);
        var sceneInfo =
            new System.IO.DirectoryInfo(UnityEngine.Application.dataPath).GetFiles("*.unity",
                                                                                   System.IO.SearchOption.AllDirectories);
        var scenes = new string[sceneInfo.Length];

        AkSceneUtils.CreateNewScene();
        AkUtilities.IsMigrating = true;

        for (var i = 0; i < scenes.Length; i++)
        {
            UpdateProgressBar((float)i / scenes.Length);

            var scene = "Assets" + sceneInfo[i].FullName.Substring(UnityEngine.Application.dataPath.Length);
            UnityEngine.Debug.Log("WwiseUnity: Migrating scene " + scene);

            AkSceneUtils.OpenExistingScene(scene);
            MigrateCurrentScene(files, migrateStart - 1, migrateStop - 1);
            AkSceneUtils.SaveCurrentScene(null);
        }

        UpdateProgressBar(1.0f);

        AkSceneUtils.CreateNewScene();

        AkUtilities.IsMigrating = false;

        // Reopen the scene that was opened before the migration process started.
        AkSceneUtils.OpenExistingScene(currentScene);

        UnityEngine.Debug.Log("WwiseUnity: Removing lock for launcher.");

        // TODO: Moving one folder up is not nice at all. How to find the current project path?
        try
        {
            System.IO.File.Delete(UnityEngine.Application.dataPath + "/../.WwiseLauncherLockFile");
        }
        catch (System.Exception)
        {
            // Ignore if not present.
        }

        UnityEditor.EditorUtility.ClearProgressBar();
    }
コード例 #7
0
    public void OnPostprocessBuildInternal(UnityEditor.BuildTarget target, string path)
    {
        AkPluginActivator.ActivatePluginsForDeployment(target, false);
#if !(AK_WWISE_ADDRESSABLES && UNITY_ADDRESSABLES)
        DeleteSoundbanks(destinationSoundBankFolder);
#endif
        destinationSoundBankFolder = string.Empty;
    }
コード例 #8
0
    static void  PostImportFunction()
    {
        // Do nothing in batch mode
        string[] arguments = Environment.GetCommandLineArgs();
        if (Array.IndexOf(arguments, "-nographics") != -1)
        {
            return;
        }

        EditorApplication.hierarchyWindowChanged += CheckWwiseGlobalExistance;
        try
        {
            if (!File.Exists(Application.dataPath + Path.DirectorySeparatorChar + WwiseSettings.WwiseSettingsFilename))
            {
                WwiseSetupWizard.Init();
                return;
            }
            else
            {
                WwiseSetupWizard.Settings = WwiseSettings.LoadSettings();
                AkWwiseProjectInfo.GetData();

#if !UNITY_5
                // Check if there are some new platforms to install.
                InstallNewPlatforms();
#else
                if (string.IsNullOrEmpty(AkWwiseProjectInfo.GetData().CurrentPluginConfig))
                {
                    AkWwiseProjectInfo.GetData().CurrentPluginConfig = AkPluginActivator.CONFIG_PROFILE;
                }
                AkPluginActivator.RefreshPlugins();
#endif
            }

            if (!string.IsNullOrEmpty(WwiseSetupWizard.Settings.WwiseProjectPath))
            {
                AkWwisePicker.PopulateTreeview();
                if (AkWwiseProjectInfo.GetData().autoPopulateEnabled)
                {
                    AkWwiseWWUWatcher.GetInstance().StartWWUWatcher();
                }
            }
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
        }

        //Check if a WwiseGlobal object exists in the current scene
        CheckWwiseGlobalExistance();

        // If demo scene, remove file that should only be there on import
        string filename = Path.Combine(Path.Combine(Path.Combine(Path.Combine(Application.dataPath, "Wwise"), "Editor"), "WwiseSetupWizard"), "AkWwisePopPicker.cs");
        if (File.Exists(filename))
        {
            EditorApplication.delayCall += DeletePopPicker;
        }
    }
コード例 #9
0
 private static void RefreshCallback()
 {
     PostImportFunction();
     if (File.Exists(Path.Combine(Application.dataPath, WwiseSettings.WwiseSettingsFilename)))
     {
         AkPluginActivator.Update();
         AkPluginActivator.ActivatePluginsForEditor();
     }
 }
コード例 #10
0
 private static void RefreshCallback()
 {
     PostImportFunction();
     if (WwiseSettings.Exists)
     {
         AkPluginActivator.Update();
         AkPluginActivator.ActivatePluginsForEditor();
     }
 }
コード例 #11
0
    private static void RefreshPlugins()
    {
        if (string.IsNullOrEmpty(AkWwiseProjectInfo.GetData().CurrentPluginConfig))
        {
            AkWwiseProjectInfo.GetData().CurrentPluginConfig = AkPluginActivator.CONFIG_PROFILE;
        }

        AkPluginActivator.ActivatePluginsForEditor();
    }
コード例 #12
0
    public static bool Populate()
    {
        try
        {
            if (WwiseSetupWizard.Settings.WwiseProjectPath == null)
            {
                WwiseSettings.LoadSettings();
            }

            if (string.IsNullOrEmpty(WwiseSetupWizard.Settings.WwiseProjectPath))
            {
                UnityEngine.Debug.LogError("WwiseUnity: Wwise project needed to populate from Work Units. Aborting.");
                return(false);
            }

            var fullWwiseProjectPath = AkUtilities.GetFullPath(UnityEngine.Application.dataPath, WwiseSetupWizard.Settings.WwiseProjectPath);
            s_wwiseProjectPath = System.IO.Path.GetDirectoryName(fullWwiseProjectPath);

            AkUtilities.IsWwiseProjectAvailable = System.IO.File.Exists(fullWwiseProjectPath);
            if (!AkUtilities.IsWwiseProjectAvailable || UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || string.IsNullOrEmpty(s_wwiseProjectPath) ||
                UnityEditor.EditorApplication.isCompiling)
            {
                return(false);
            }

            AkPluginActivator.Update();

            var builder = new AkWwiseWWUBuilder();
            if (WwiseObjectReference.migrate == null && !builder.GatherModifiedFiles())
            {
                return(false);
            }

            builder.UpdateFiles();

            if (WwiseObjectReference.migrate != null)
            {
                UpdateWwiseObjectReferenceData();
                PopulateWwiseObjectReferences();

                UnityEditor.AssetDatabase.SaveAssets();

                var currentScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
                UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(currentScene);
            }

            return(true);
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.LogError(e.ToString());
            UnityEditor.EditorUtility.ClearProgressBar();
            return(true);
        }
    }
コード例 #13
0
    public static bool Populate()
    {
        try
        {
            if (WwiseSetupWizard.Settings.WwiseProjectPath == null)
            {
                WwiseSettings.LoadSettings();
            }

            if (string.IsNullOrEmpty(WwiseSetupWizard.Settings.WwiseProjectPath))
            {
                UnityEngine.Debug.LogError("WwiseUnity: Wwise project needed to populate from Work Units. Aborting.");
                return(false);
            }

            s_wwiseProjectPath = System.IO.Path.GetDirectoryName(AkUtilities.GetFullPath(UnityEngine.Application.dataPath,
                                                                                         WwiseSetupWizard.Settings.WwiseProjectPath));

            if (!System.IO.File.Exists(AkUtilities.GetFullPath(UnityEngine.Application.dataPath,
                                                               WwiseSetupWizard.Settings.WwiseProjectPath)))
            {
                AkWwisePicker.WwiseProjectFound = false;
                return(false);
            }

            AkWwisePicker.WwiseProjectFound = true;

            if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || string.IsNullOrEmpty(s_wwiseProjectPath) ||
                UnityEditor.EditorApplication.isCompiling)
            {
                return(false);
            }

            AkPluginActivator.Update();

            var builder = new AkWwiseWWUBuilder();
            if (!builder.GatherModifiedFiles())
            {
                return(false);
            }

            builder.UpdateFiles();
            return(true);
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.LogError(e.ToString());
            UnityEditor.EditorUtility.ClearProgressBar();
        }

        return(true);        //There was an error, assume that we need to refresh.
    }
コード例 #14
0
    static void RefreshPlugins()
    {
#if !UNITY_5
        // Check if there are some new platforms to install.
        InstallNewPlatforms();
#else
        if (string.IsNullOrEmpty(AkWwiseProjectInfo.GetData().CurrentPluginConfig))
        {
            AkWwiseProjectInfo.GetData().CurrentPluginConfig = AkPluginActivator.CONFIG_PROFILE;
        }
        AkPluginActivator.RefreshPlugins();
#endif
    }
コード例 #15
0
    public static void ModifySetup()
    {
        string currentConfig = AkPluginActivator.GetCurrentConfig();

        if (String.IsNullOrEmpty(currentConfig))
        {
            currentConfig = AkPluginActivator.CONFIG_PROFILE;
        }

        AkPluginActivator.DeactivateAllPlugins();
        AkPluginActivator.Update();
        AkPluginActivator.ActivatePlugins(currentConfig, true);
    }
コード例 #16
0
    public void OnPreprocessBuild(BuildTarget target, string path)
    {
        if (WwiseSetupWizard.Settings.CopySoundBanksAsPreBuildStep)
        {
            string platformName = GetPlatformName(target);
            if (!CopySoundbanks(WwiseSetupWizard.Settings.GenerateSoundBanksAsPreBuildStep, platformName, ref destinationSoundBankFolder))
            {
                Debug.LogError("WwiseUnity: Soundbank folder has not been copied for <" + target + "> target at <" + path + ">. This will likely result in a build without sound!!!");
            }
        }

        // @todo sjl - only update for target platform
        AkPluginActivator.Update(true);
        AkPluginActivator.ActivatePluginsForDeployment(target, true);
    }
コード例 #17
0
    public void OnPreprocessBuildInternal(UnityEditor.BuildTarget target, string path)
    {
        if (AkWwiseEditorSettings.Instance.CopySoundBanksAsPreBuildStep)
        {
            var platformName = GetPlatformName(target);
            if (!CopySoundbanks(AkWwiseEditorSettings.Instance.GenerateSoundBanksAsPreBuildStep, platformName, ref destinationSoundBankFolder))
            {
                UnityEngine.Debug.LogErrorFormat("WwiseUnity: SoundBank folder has not been copied for <{0}> target at <{1}>. This will likely result in a build without sound!!!", target, path);
            }
        }

        // @todo sjl - only update for target platform
        AkPluginActivator.Update(true);
        AkPluginActivator.ActivatePluginsForDeployment(target, true);
    }
コード例 #18
0
    // Perform all necessary steps to use the Wwise Unity integration.
    private static void Setup()
    {
        UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects);

        AkPluginActivator.DeactivateAllPlugins();

        // 0. Make sure the SoundBank directory exists
        var sbPath = AkUtilities.GetFullPath(UnityEngine.Application.streamingAssetsPath, AkWwiseEditorSettings.Instance.SoundbankPath);

        if (!System.IO.Directory.Exists(sbPath))
        {
            System.IO.Directory.CreateDirectory(sbPath);
        }

        // 1. Disable built-in audio
        if (!DisableBuiltInAudio())
        {
            UnityEngine.Debug.LogWarning(
                "WwiseUnity: Could not disable built-in audio. Please disable built-in audio by going to Project->Project Settings->Audio, and check \"Disable Audio\".");
        }

        // 2. Create a "WwiseGlobal" game object and set the AkSoundEngineInitializer and terminator scripts
        // 3. Set the SoundBank path property on AkSoundEngineInitializer
        CreateWwiseGlobalObject();

        // 5. Disable the built-in audio listener, and add AkAudioListener component to camera
        if (AkWwiseEditorSettings.Instance.CreateWwiseListener)
        {
            AddAkAudioListenerToMainCamera();
        }

        // 6. Enable "Run In Background" in PlayerSettings (PlayerSettings.runInbackground property)
        UnityEditor.PlayerSettings.runInBackground = true;

        AkPluginActivator.Update();
        AkPluginActivator.ActivatePluginsForEditor();

        // 9. Activate WwiseIDs file generation, and point Wwise to the Assets/Wwise folder
        // 10. Change the SoundBanks options so it adds Max Radius information in the Wwise project
        if (!SetSoundbankSettings())
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: Could not modify Wwise Project to generate the header file!");
        }

        // 11. Activate XboxOne network sockets.
        AkXboxOneUtils.EnableXboxOneNetworkSockets();
    }
コード例 #19
0
    static void RefreshCallback()
    {
        PostImportFunction();
        if (File.Exists(Path.Combine(Application.dataPath, WwiseSettings.WwiseSettingsFilename)))
        {
            AkPluginActivator.Update();
            AkPluginActivator.RefreshPlugins();

#if UNITY_5
            // Check if platform is supported and installed
            string Msg;
            if (!CheckPlatform(out Msg))
            {
                EditorUtility.DisplayDialog("Warning", Msg, "OK");
            }
#endif
        }
    }
コード例 #20
0
    // Perform all necessary steps to use the Wwise Unity integration.
    private static void Setup()
    {
        AkPluginActivator.DeactivateAllPlugins();

        // 0. Make sure the soundbank directory exists
        string sbPath = AkUtilities.GetFullPath(Application.streamingAssetsPath, Settings.SoundbankPath);

        if (!Directory.Exists(sbPath))
        {
            Directory.CreateDirectory(sbPath);
        }

        // 1. Disable built-in audio
        if (!DisableBuiltInAudio())
        {
            Debug.LogWarning("WwiseUnity: Could not disable built-in audio. Please disable built-in audio by going to Project->Project Settings->Audio, and check \"Disable Audio\".");
        }

        // 2. Create a "WwiseGlobal" game object and set the AkSoundEngineInitializer and terminator scripts
        // 3. Set the SoundBank path property on AkSoundEngineInitializer
        CreateWwiseGlobalObject();

        // 5. Add AkAudioListener component to camera
        SetListener();

        // 6. Enable "Run In Background" in PlayerSettings (PlayerSettings.runInbackground property)
        PlayerSettings.runInBackground = true;

        AkPluginActivator.Update();
        AkPluginActivator.ActivatePlugins(AkPluginActivator.CONFIG_PROFILE, true);

        // 9. Activate WwiseIDs file generation, and point Wwise to the Assets/Wwise folder
        // 10. Change the SoundBanks options so it adds Max Radius information in the Wwise project
        if (!SetSoundbankSettings())
        {
            Debug.LogWarning("WwiseUnity: Could not modify Wwise Project to generate the header file!");
        }

        // 11. Activate XboxOne network sockets.
        AkXboxOneUtils.EnableXboxOneNetworkSockets();
    }
コード例 #21
0
    private static void RefreshCallback()
    {
        PostImportFunction();
        if (File.Exists(Path.Combine(Application.dataPath, WwiseSettings.WwiseSettingsFilename)))
        {
            AkPluginActivator.Update();
            AkPluginActivator.RefreshPlugins();

            // Check if platform is supported and installed. PluginImporter might contain
            // erroneous data when application is compiling or updating, so skip this if
            // that is the case.
            if (!EditorApplication.isCompiling && !EditorApplication.isUpdating)
            {
                string Msg;
                if (!CheckPlatform(out Msg))
                {
                    EditorUtility.DisplayDialog("Warning", Msg, "OK");
                }
            }
        }
    }
コード例 #22
0
    public static bool Populate()
    {
        try
        {
            if (string.IsNullOrEmpty(AkWwiseEditorSettings.Instance.WwiseProjectPath))
            {
                UnityEngine.Debug.LogError("WwiseUnity: Wwise project needed to populate from Work Units. Aborting.");
                return(false);
            }

            var fullWwiseProjectPath = AkWwiseEditorSettings.WwiseProjectAbsolutePath;
            s_wwiseProjectPath = System.IO.Path.GetDirectoryName(fullWwiseProjectPath);

            AkUtilities.IsWwiseProjectAvailable = System.IO.File.Exists(fullWwiseProjectPath);
            if (!AkUtilities.IsWwiseProjectAvailable || UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || string.IsNullOrEmpty(s_wwiseProjectPath) ||
                (UnityEditor.EditorApplication.isCompiling && !AkUtilities.IsMigrating))
            {
                return(false);
            }

            AkPluginActivator.Update();

            var builder = new AkWwiseWWUBuilder();
            if (!builder.GatherModifiedFiles())
            {
                return(false);
            }

            builder.UpdateFiles();
            return(true);
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.LogError(e.ToString());
            UnityEditor.EditorUtility.ClearProgressBar();
            return(true);
        }
    }
 public static void SetReleaseSetting()
 {
     AkPluginActivator.ActivateRelease();
 }
コード例 #24
0
        private static bool ProcessBuild(string channelName, BuildTarget target, string targetFolder = "", bool debugMode = false, bool il2cpp = false, bool developmentBuild = false, bool isIosHook = false)
        {
            // reimport all shaders
            string shaderFolderPath = "Assets/Standard Assets/Shaders";

            AssetDatabase.ImportAsset(shaderFolderPath, ImportAssetOptions.ImportRecursive | ImportAssetOptions.DontDownloadFromCacheServer);

            TextAsset     mChannelTextAsset = AssetDatabase.LoadAssetAtPath <TextAsset>("Assets/OriginalResRepos/DataPersistent/BuildChannel/ChannelConfig.json");
            ConfigChannel channelConfig     = ConfigUtil.LoadJSONStrConfig <ConfigChannel>(mChannelTextAsset.text);

            // ! 用设置里的配置

            /*
             * if(target==BuildTarget.iOS)
             * {
             *      PlayerSettings.SetPropertyInt("ScriptingBackend", (int)ScriptingImplementation.IL2CPP, BuildTarget.iOS);
             *      //PlayerSettings.SetPropertyInt("Architecture", (int)iPhoneArchitecture.Universal, BuildTargetGroup.iOS);
             *      PlayerSettings.SetGraphicsAPIs(BuildTarget.iOS, new UnityEngine.Rendering.GraphicsDeviceType[] { UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2 });
             * }
             */

            PlayerSettings.productName      = channelConfig.ProductName;
            PlayerSettings.bundleIdentifier = channelConfig.BundleIdentifier;
            PlayerSettings.bundleVersion    = GlobalVars.VERSION;

            /* 安卓要设置version code */
            if (target == BuildTarget.Android)
            {
                PlayerSettings.Android.bundleVersionCode    = Mathf.Max(channelConfig.VersionCode, GlobalVars.BUNDLE_VERSION_CODE);
                PlayerSettings.Android.useAPKExpansionFiles = channelConfig.Obb;
            }

            string DefineSymbols = channelConfig.PreDefines;

            if (debugMode)
            {
                DefineSymbols += ";NG_HSOD_PROFILE";                 // ! 打包机出来的设备上 Debug 模式总是用 PROFILE 设置
            }
            if (target == BuildTarget.iOS && isIosHook)
            {
                DefineSymbols += ";NG_HSOD_IOS_HOOK_RES";                 // ios 分包
            }
            // for behavior manager
            DefineSymbols += ";DLL_RELEASE";
            // avpro
            if (!debugMode)
            {
                AkPluginActivator.ActivateRelease();
                DefineSymbols += ";AVPROVIDEO_DISABLE_DEBUG_GUI;AVPROVIDEO_DISABLE_LOGGING";
            }
            else
            {
                // activate wwise profile
                AkPluginActivator.ActivateProfile();
            }

            BuildOptions mBuildOptions = BuildOptions.SymlinkLibraries;

            if (developmentBuild)
            {
                mBuildOptions |= BuildOptions.Development;
                mBuildOptions |= BuildOptions.ConnectWithProfiler;
                mBuildOptions |= BuildOptions.AllowDebugging;
            }

            // 如果不是安卓只用il2cpp,如果是安卓用参数开关il2cpp
            if (target != BuildTarget.Android || il2cpp)
            {
                PlayerSettings.SetPropertyInt("ScriptingBackend", (int)ScriptingImplementation.IL2CPP, target);
                PlayerSettings.strippingLevel = StrippingLevel.Disabled;
            }
            else
            {
                PlayerSettings.SetPropertyInt("ScriptingBackend", (int)ScriptingImplementation.Mono2x, target);
                PlayerSettings.strippingLevel = StrippingLevel.Disabled;
            }

            var targetGroup = target == BuildTarget.Android ? BuildTargetGroup.Android : BuildTargetGroup.iOS;

            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, DefineSymbols);

            var scenes    = GetBuildScenes(DefineSymbols);
            var buildPath = targetFolder;

            if (scenes == null || scenes.Length == 0 || buildPath == null)
            {
                return(false);
            }

            Debug.Log("Start building player for " + target.ToString());
            Debug.Log("ChannelName= " + channelName);
            Debug.Log("DefineSymbols= " + DefineSymbols);
            Debug.Log("developmentBuild= " + developmentBuild);

            AssetDatabase.Refresh();

            BuildPipeline.BuildPlayer(scenes, buildPath, target, mBuildOptions);

            Debug.Log("Build player finished!");

            return(true);
        }
コード例 #25
0
    // Perform all necessary steps to use the Wwise Unity integration.
    public bool Setup()
    {
        bool NoErrorHappened = true;

        // 0. Make sure the soundbank directory exists
        string sbPath = AkUtilities.GetFullPath(Application.streamingAssetsPath, Settings.SoundbankPath);

        if (!Directory.Exists(sbPath))
        {
            Directory.CreateDirectory(sbPath);
        }

        // 1. Disable built-in audio
        if (!DisableBuiltInAudio())
        {
            EditorUtility.DisplayDialog("Warning", "Could not disable built-in audio. Please disable built-in audio by going to Project->Project Settings->Audio, and check \"Disable Audio\".", "Ok");
        }

        // 2. Create a "WwiseGlobal" game object and set the AkSoundEngineInitializer and terminator scripts
        // 3. Set the SoundBank path property on AkSoundEngineInitializer
        if (!Settings.OldProject)
        {
            CreateWwiseGlobalObject();
        }

        // 4. Set the script order of AkInitializer, AkTerminator, AkGameObj, AkBankLoad (before default time), AkAudioListener by changing the .meta file
        if (!SetAllScriptExecutionOrder())
        {
            EditorUtility.DisplayDialog("Error", "Could not change script exec order!", "Ok");
            NoErrorHappened = false;
        }

        // 5. Add AkAudioListener component to camera
        if (!Settings.OldProject)
        {
            SetListener();
        }

        // 6. Enable "Run In Background" in PlayerSettings (PlayerSettings.runInbackground property)
        PlayerSettings.runInBackground = true;

#if !UNITY_5
        // 7. Install the Profile libraries of the installed platforms. This should actually be a change in the way we build unitypackages.
        if (!InstallAllPlatformProfilePlugins())
        {
            EditorUtility.DisplayDialog("Error", "Could not install some platform plugins!", "Ok");
            NoErrorHappened = false;
        }
#else
        AkPluginActivator.ActivatePlugins(AkPluginActivator.CONFIG_PROFILE, true);
#endif

        // 8. Verify DirectX is installed (windows only)
#if UNITY_EDITOR_WIN
        Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\DirectX\\");
        if (key == null)
        {
            EditorUtility.DisplayDialog("Warning", "Detected the DirectX End-User Runtime is not installed. You might have issues using the Windows version of the plugin", "Ok");
        }
#endif
        // 9. Activate WwiseIDs file generation, and point Wwise to the Assets/Wwise folder
        // 10. Change the SoundBanks options so it adds Max Radius information in the Wwise project
        if (!SetSoundbankSettings())
        {
            EditorUtility.DisplayDialog("Warning", "Could not modify Wwise Project to generate the header file!", "Ok");
        }

        // 11. Generate the WwiseIDs.cs file from the .h file
        // GenerateWwiseIDsCsFile();

        // 12. Refresh UI/Settings files.
        Repaint();

        // 13. Make sure the installed SDK matches the one that was build on the machine
        string[] arguments = Environment.GetCommandLineArgs();
        if (Array.IndexOf(arguments, "-nographics") == -1)
        {
            ValidateVersion();
        }

        // 14. Enable Xbox One profiling sockets
        AkXboxOneUtils.EnableXboxOneNetworkSockets();

        // 15. Populate the picker
        AkWwiseProjectInfo.GetData(); // Load data
        if (!String.IsNullOrEmpty(Settings.WwiseProjectPath))
        {
            AkWwiseProjectInfo.Populate();
            AkWwisePicker.PopulateTreeview();
            if (AkWwiseProjectInfo.GetData().autoPopulateEnabled)
            {
                AkWwiseWWUBuilder.StartWWUWatcher();
            }
        }

        return(NoErrorHappened);
    }