Ejemplo n.º 1
0
    // =================================================================================================================
    // === utility functions ===========================================================================================
    static List <string> GetScenesForBuild(E_ApplicationType inTarget, E_BuildType buildType = E_BuildType.Universal)
    {
        // ...................................................
        // get scenes from editor build settings,
        // exclude disabled ones and scenes which are not levels...
        List <string> listOfScenes = new List <string>();

        // ...................................................
        // add some global scenes...
        listOfScenes.Add("assets/Levels/Multiplayer/mp_core.unity");
        listOfScenes.Add("assets/Levels/Multiplayer/mp_vortex.unity");
        listOfScenes.Add("Assets/Levels/empty.unity");

        // ...................................................
        // add per target scenes...
        switch (inTarget)
        {
        case E_ApplicationType.DedicatedServer:
            listOfScenes.Insert(0, "Assets/Levels/DedicatedServer.unity");
            break;

        case E_ApplicationType.WebPlayerClient:
//			listOfScenes.Add("Assets/Levels/InitGame.unity");
            goto case E_ApplicationType.AndroidClient;

        case E_ApplicationType.OSXClient:
            goto case E_ApplicationType.AndroidClient;

        case E_ApplicationType.PCClient:
            goto case E_ApplicationType.AndroidClient;

        case E_ApplicationType.AndroidClient:
            listOfScenes.Add("Assets/Levels/Gui_16_9.unity");
            //listOfScenes.Add("assets/Levels/Multiplayer/loading.unity");
            //listOfScenes.Add("assets/Levels/Multiplayer/loadingcustomize.unity");
            //listOfScenes.Add("assets/Levels/Multiplayer/loadinggetpremium.unity");
            listOfScenes.Add("assets/Levels/LoadingToGame.unity");
            listOfScenes.Add("assets/Levels/LoadingFromGame.unity");
            listOfScenes.Add("Assets/Levels/MainMenu.unity");
            listOfScenes.Insert(0, "Assets/Levels/InitGame.unity");
            break;

        case E_ApplicationType.IOSClient:
            goto case E_ApplicationType.AndroidClient;

        default:
            Debug.LogError("Unknown target. Abort !!!");
            return(null);
        }

        return(listOfScenes);
    }
Ejemplo n.º 2
0
    // =================================================================================================================
    // === MAIN build function =========================================================================================
    static private string Build(E_ApplicationType inType, string[] levels, string locationPathName, BuildTarget target, BuildOptions options, string defineSymbols)
    {
        // this list will be filled in PostProcess scene callback,
        // so we will clear it here for sure
        m_ModifiedAssets.Clear();

        // set active application type.
        // PostProcess scene callbacks will now what is actual building
        m_ActiveApplicationBuildType = inType;

        // Set define symbols for compiler
        BuildTargetGroup targetGroup       = BuildTargetToGroup(target);
        string           prevDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);

        PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, defineSymbols);

        // This function will create the Real player.
        string retv = BuildPipeline.BuildPlayer(levels, locationPathName, target, options);

        PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, prevDefineSymbols);

        // reset active application type
        m_ActiveApplicationBuildType = E_ApplicationType.Unknown;

        // Reload modified persistant files if needed.
        if (m_ReloadModifiedAssetsAfterBuild == true)
        {
            bool reportProblem = false;
            Debug.Log(" !!! Force reload modified assets !!! ");

            foreach (string assetPath in m_ModifiedAssets)
            {
                if (string.IsNullOrEmpty(assetPath))
                {
                    continue;
                }

                try
                {
                    System.IO.File.SetLastWriteTime(assetPath, System.DateTime.Now);
                }
                catch (System.Exception e)
                {
                    Debug.Log("Unable to restore modified asset: " + e.ToString() + " " + assetPath);
                    reportProblem = true;
                }
                //AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate);
            }

            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);

            if (reportProblem)
            {
                EditorUtility.DisplayDialog("Asset reimport problem", "Some of the modified assets were not re-imported and thus they stay modified. Check the editor log for more details.", "Ok");
            }
        }

        // clear modified assets
        m_ModifiedAssets.Clear();

        // end, return error string if exist.
        return(retv);
    }