コード例 #1
0
        private void OnGuiLoadingScreenSelect()
        {
            var descriptionTextStyle = CreateDescriptionTextStyle();

            EditorGUILayout.LabelField("Set AssetBundle URL", EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical(UserInputGuiStyle);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(
                "Specify the URL that points to the deployed AssetBundle. The AssetBundle will be downloaded at game startup. ",
                descriptionTextStyle);
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("AssetBundle URL", GUILayout.MinWidth(FieldMinWidth));
            Config.AssetBundleUrl =
                EditorGUILayout.TextField(Config.AssetBundleUrl, GUILayout.MinWidth(FieldMinWidth));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            var setAssetBundleText = QuickDeployConfig.EngineConfigExists()
                ? "Update AssetBundle URL"
                : "Set AssetBundle URL";

            if (GUILayout.Button(setAssetBundleText))
            {
                try
                {
                    Config.SaveConfiguration(ToolBarSelectedButton.LoadingScreen);
                }
                catch (Exception ex)
                {
                    DialogHelper.DisplayMessage(AssetBundleCheckerErrorTitle, ex.Message);

                    throw;
                }
            }

            EditorGUILayout.Space();
            if (GUILayout.Button("Check AssetBundle"))
            {
                var window = AssetBundleVerifierWindow.ShowWindow();

                try
                {
                    Config.SaveConfiguration(ToolBarSelectedButton.LoadingScreen);
                    window.StartAssetBundleDownload(Config.AssetBundleUrl);
                }
                catch (Exception ex)
                {
                    DialogHelper.DisplayMessage(AssetBundleCheckerErrorTitle, ex.Message);

                    window.Close();

                    throw;
                }
            }

            EditorGUILayout.Space();

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Select Loading Screen Image", EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical(UserInputGuiStyle);
            EditorGUILayout.Space();

            EditorGUILayout.LabelField(
                "Choose image to use as background for the loading scene.", descriptionTextStyle);
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Image File Path", GUILayout.MinWidth(FieldMinWidth));

            _loadingScreenImagePath =
                EditorGUILayout.TextField(_loadingScreenImagePath, GUILayout.MinWidth(FieldMinWidth));

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Browse", GUILayout.Width(ShortButtonWidth)))
            {
                _loadingScreenImagePath =
                    EditorUtility.OpenFilePanel("Select Image", "", "png,jpg,jpeg,tif,tiff,gif,bmp");
                HandleDialogExit();
            }

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            if (LoadingScreenGenerator.LoadingScreenExists())
            {
                if (GUILayout.Button("Update Loading Scene"))
                {
                    try
                    {
                        Config.SaveConfiguration(ToolBarSelectedButton.LoadingScreen);
                        LoadingScreenGenerator.AddImageToScene(LoadingScreenGenerator.GetLoadingScreenCanvasObject(),
                                                               _loadingScreenImagePath);
                    }
                    catch (Exception ex)
                    {
                        DialogHelper.DisplayMessage(LoadingScreenUpdateErrorTitle, ex.Message);
                        throw;
                    }
                }
            }
            else
            {
                if (GUILayout.Button("Create Loading Scene"))
                {
                    try
                    {
                        Config.SaveConfiguration(ToolBarSelectedButton.LoadingScreen);
                        LoadingScreenGenerator.GenerateScene(Config.AssetBundleUrl,
                                                             _loadingScreenImagePath);
                    }
                    catch (Exception ex)
                    {
                        DialogHelper.DisplayMessage(LoadingScreenCreationErrorTitle, ex.Message);
                        throw;
                    }
                }
            }

            EditorGUILayout.Space();

            EditorGUILayout.EndVertical();
        }