Esempio n. 1
0
        /// <summary>
        /// Displays a save dialog, saves the specified path to config, and then creates an AssetBundle at that path.
        /// </summary>
        private void HandleBuildAssetBundleButton()
        {
            string saveFilePath = DialogHelper.SaveFilePanel("Save AssetBundle", Config.AssetBundleFileName, "");

            if (String.IsNullOrEmpty(saveFilePath))
            {
                // Assume cancelled.
                return;
            }

            Config.AssetBundleFileName = saveFilePath;

            try
            {
                Config.SaveConfiguration(true);
                AssetBundleBuilder.BuildQuickDeployAssetBundle(GetEnabledSceneItemPaths());
            }
            catch (Exception ex)
            {
                DialogHelper.DisplayMessage(AssetBundleBuildErrorTitle, ex.Message);
                throw;
            }
        }
        private void OnGuiCreateBundleSelect()
        {
            var descriptionTextStyle = CreateDescriptionTextStyle();

            EditorGUILayout.LabelField("Create AssetBundle", EditorStyles.boldLabel);

            EditorGUILayout.BeginVertical(UserInputGuiStyle);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Select scenes to be put into an AssetBundle and then build it.",
                                       descriptionTextStyle);

            EditorGUILayout.Space();

            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(UserInputGuiStyle);
            EditorGUILayout.Space();

            _playInstantSceneTreeTreeView.OnGUI(GUILayoutUtility.GetRect(position.width,
                                                                         position.height - SceneViewDeltaFromTop));
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Add Open Scenes"))
            {
                _playInstantSceneTreeTreeView.AddOpenScenes();
            }

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

            EditorGUILayout.Space();


            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("AssetBundle File Path", GUILayout.MinWidth(FieldMinWidth));
            Config.AssetBundleFileName = EditorGUILayout.TextField(Config.AssetBundleFileName,
                                                                   GUILayout.MinWidth(FieldMinWidth));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Browse", GUILayout.Width(ShortButtonWidth)))
            {
                Config.AssetBundleFileName = EditorUtility.SaveFilePanel("Save AssetBundle", "", "", "");
                HandleDialogExit();
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Build AssetBundle"))
            {
                try
                {
                    Config.SaveConfiguration(ToolBarSelectedButton.CreateBundle);
                    AssetBundleBuilder.BuildQuickDeployAssetBundle(GetEnabledSceneItemPaths());
                }
                catch (Exception ex)
                {
                    DialogHelper.DisplayMessage(AssetBundleBuildErrorTitle,
                                                ex.Message);
                    throw;
                }

                HandleDialogExit();
            }

            EditorGUILayout.EndHorizontal();
        }