GooglePlayInstant/Editor/QuickDeploy/LoadingScreenGenerator.cs
/// <summary>
/// Creates a scene in the current project that acts as a loading scene until assetbundles are
/// downloaded from the CDN. Takes in a loadingScreenImagePath, a path to the image shown in the loading scene,
/// and an assetbundle URL. Replaces the current loading scene with a new one if it exists.
/// </summary>
Creates a scene in the current project that acts as a loading scene until assetbundles are
downloaded from the CDN. Takes in a loadingScreenImagePath, a path to the image shown in the loading scene,
and an assetbundle URL. Replaces the current loading scene with a new one if it exists.
Creates a scene in the current project that acts as a loading scene until assetbundles are downloaded from the CDN . Takes in a loadingScreenImagePath a path to the image shown in the loading scene and an assetbundle URL . Replaces the current loading scene with a new one if it exists .
public static void GenerateScene(string assetBundleUrl, string loadingScreenImagePath)
        {
            if (string.IsNullOrEmpty(assetBundleUrl))
            {
                throw new ArgumentException("AssetBundle URL text field cannot be null or empty.");
            }
            if (!File.Exists(loadingScreenImagePath))
            {
                throw new FileNotFoundException(string.Format("Loading screen image file cannot be found: {0}",
                    loadingScreenImagePath));
            }
            EditorSceneManager.CloseScene(SceneManager.GetSceneByName(Path.GetFileNameWithoutExtension(SceneName)),
                true);
            var loadingScreenScene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);
            var loadingScreenGameObject = new GameObject(CanvasName);
            AddImageToScene(loadingScreenGameObject, loadingScreenImagePath);
            AddScript(loadingScreenGameObject);
            LoadingBar.AddComponent(loadingScreenGameObject);
            bool saveOk = EditorSceneManager.SaveScene(loadingScreenScene, SceneFilePath);
            if (!saveOk)
            {
                var warningMessage = string.Format("Issue while saving scene {0}.",
                    SceneName);
                Debug.LogWarning(warningMessage);
                DialogHelper.DisplayMessage(SaveErrorTitle, warningMessage);
            }
            else
            {
                if (EditorUtility.DisplayDialog("Change Scenes in Build",
                    "Would you like to replace any existing Scenes in Build with the loading screen scene?", "Yes",
                    "No"))
                {
                    SetMainSceneInBuild(SceneFilePath);
                }
            }
        }
public static void GenerateScene ( string assetBundleUrl , string loadingScreenImagePath ) { if ( string . IsNullOrEmpty ( assetBundleUrl ) ) { throw new ArgumentException ( " " ) ; } if ( ! File . Exists ( loadingScreenImagePath ) ) { throw new FileNotFoundException ( string . Format ( " " , loadingScreenImagePath ) ) ; } EditorSceneManager . CloseScene ( SceneManager . GetSceneByName ( Path . GetFileNameWithoutExtension ( SceneName ) ) , true ) ; var loadingScreenScene = EditorSceneManager . NewScene ( NewSceneSetup . EmptyScene , NewSceneMode . Additive ) ; var loadingScreenGameObject = new GameObject ( CanvasName ) ; AddImageToScene ( loadingScreenGameObject , loadingScreenImagePath ) ; AddScript ( loadingScreenGameObject ) ; LoadingBar . AddComponent ( loadingScreenGameObject ) ; bool saveOk = EditorSceneManager . SaveScene ( loadingScreenScene , SceneFilePath ) ; if ( ! saveOk ) { var warningMessage = string . Format ( " " , SceneName ) ; Debug . LogWarning ( warningMessage ) ; DialogHelper . DisplayMessage ( SaveErrorTitle , warningMessage ) ; } else { if ( EditorUtility . DisplayDialog ( " " , " " , " " , " " ) ) { SetMainSceneInBuild ( SceneFilePath ) ; } } }
Creates a scene in the current project that acts as a loading scene until assetbundles are
downloaded from the CDN.
Creates a scene in the current project that acts as a loading scene until assetbundles are downloaded from the CDN .
// Removes the loading scene if it is present, otherwise does nothing. // Not a fatal issue. User can attempt to resave this scene. //TODO: investigate GUI Layout errors that occur when moving this to DialogHelper
assetBundleUrl
string
loadingScreenImagePath
string