Exemplo n.º 1
0
        void OnGUI()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));

            _bundleTreeView.searchString = _searchField.OnToolbarGUI(_bundleTreeView.searchString);

            GUILayout.Space(5);

            if (GUILayout.Button("Settings", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                SettingsWindow.Display();
            }

            EditorGUI.BeginChangeCheck();

            IEnumerable <AbstractBuildProcessor> processors = AssetBundleBuilder.GetProcessors();

            if (processors.Any())
            {
                DropdownMenuButton(new GUIContent($"Processors({processors.Count()})"), menu =>
                {
                    foreach (var processor in processors)
                    {
                        menu.AddItem(new GUIContent(processor.name), false,
                                     item => EditorGUIUtility.PingObject(item as Object), processor);
                    }
                });
            }

            var setting = Settings.instance;

            EnumDropDownButton(new GUIContent($"Mode: {setting.mode}"), setting.mode, mode =>
            {
                if (mode == Settings.Mode.Real && !AssetBundleBuilder.hasBuilded)
                {
                    ShowNotification(new GUIContent("Please build assetbundle first!"));
                }
                else
                {
                    Settings.GetModeSp(_settingsSo).enumValueIndex = (int)mode;
                    _settingsSo.ApplyModifiedProperties();
                }
            });

            DropdownMenuButton(_contentBuild, menu =>
            {
                menu.AddItem(new GUIContent("Build Content"), false, () => BuildContent(processors));

                menu.AddItem(new GUIContent("Rebuild"), false, () =>
                {
                    AssetBundleBuilder.ClearCache();
                    Caching.ClearCache();
                    BuildContent(processors);
                });

                menu.AddItem(new GUIContent("Try Build"), false,
                             () => AssetBundleBuilder.Build(
                                 Settings.instance.buildOptions | BuildAssetBundleOptions.DryRunBuild,
                                 processors));

                var settings          = Settings.instance.runtimeSettings;
                bool isCdnFieldFilled = Uri.IsWellFormedUriString(settings.cdnUrl, UriKind.Absolute);
                if (isCdnFieldFilled)
                {
                    menu.AddItem(_checkForUpdates, false, () => CheckForUpdatesAsync());
                }
                else
                {
                    menu.AddDisabledItem(_checkForUpdates);
                }

                menu.AddItem(new GUIContent("Clear Build Cache"), false, AssetBundleBuilder.ClearCache);
                menu.AddItem(new GUIContent("Clear Runtime Cache"), false, () => Caching.ClearCache());
            });

            EditorGUILayout.EndHorizontal();

            float offset = EditorStyles.toolbar.fixedHeight;

            _bundleTreeView.OnGUI(new Rect(0, offset, position.width, position.height - offset));

            if (EditorGUI.EndChangeCheck())
            {
                _settingsSo.ApplyModifiedProperties();
            }
        }