Пример #1
0
    public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
    {
        if (_enabledOptions == null)
        {
            return;
        }

        EditorGUILayout.HelpBox("Удаляет папку и все файлы в ней", MessageType.Info);
        editor.UpdateNodeName(node);

        GUILayout.Space(10f);

        //Show target configuration tab
        editor.DrawPlatformSelector(node);
        using (new EditorGUILayout.VerticalScope(GUI.skin.box))
        {
            var disabledScope = editor.DrawOverrideTargetToggle(node, _enabledOptions.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) =>
            {
                using (new RecordUndoScope("Remove Target Bundle Options", node, true))
                {
                    if (enabled)
                    {
                        _enabledOptions[editor.CurrentEditingGroup] = _enabledOptions.DefaultValue;
                        _outputDir[editor.CurrentEditingGroup]      = _outputDir.DefaultValue;
                        _outputOption[editor.CurrentEditingGroup]   = _outputOption.DefaultValue;
                    }
                    else
                    {
                        _enabledOptions.Remove(editor.CurrentEditingGroup);
                        _outputDir.Remove(editor.CurrentEditingGroup);
                        _outputOption.Remove(editor.CurrentEditingGroup);
                    }

                    onValueChanged();
                }
            });

            using (disabledScope)
            {
                OutputOption opt       = (OutputOption)_outputOption[editor.CurrentEditingGroup];
                var          newOption = (OutputOption)EditorGUILayout.EnumPopup("Output Option", opt);
                if (newOption != opt)
                {
                    using (new RecordUndoScope("Change Output Option", node, true))
                    {
                        _outputOption[editor.CurrentEditingGroup] = (int)newOption;
                        onValueChanged();
                    }
                }

                using (new EditorGUI.DisabledScope(opt == OutputOption.BuildInCacheDirectory || opt == OutputOption.BuildInBundlesCacheDirectory))
                {
                    var newDirPath = editor.DrawFolderSelector("Output Directory", "Select Output Folder",
                                                               _outputDir[editor.CurrentEditingGroup],
                                                               Application.dataPath + "/../",
                                                               (string folderSelected) =>
                    {
                        var projectPath = Directory.GetParent(Application.dataPath).ToString();

                        if (projectPath == folderSelected)
                        {
                            folderSelected = string.Empty;
                        }
                        else
                        {
                            var index = folderSelected.IndexOf(projectPath);
                            if (index >= 0)
                            {
                                folderSelected = folderSelected.Substring(projectPath.Length + index);
                                if (folderSelected.IndexOf('/') == 0)
                                {
                                    folderSelected = folderSelected.Substring(1);
                                }
                            }
                        }

                        return(folderSelected);
                    }
                                                               );

                    if (newDirPath != _outputDir[editor.CurrentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Output Directory", node, true))
                        {
                            _outputDir[editor.CurrentEditingGroup] = newDirPath;



                            onValueChanged();
                        }
                    }

                    var outputDir = PrepareOutputDirectory(BuildTargetUtility.GroupToTarget(editor.CurrentEditingGroup), node.Data);

                    using (new EditorGUI.DisabledScope(!Directory.Exists(outputDir)))
                    {
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            GUILayout.FlexibleSpace();
#if UNITY_EDITOR_OSX
                            string buttonName = "Reveal in Finder";
#else
                            string buttonName = "Show in Explorer";
#endif
                            if (GUILayout.Button(buttonName))
                            {
                                EditorUtility.RevealInFinder(outputDir);
                            }
                        }
                    }

                    EditorGUILayout.HelpBox("You can use '{Platform}' variable for Output Directory path to include platform name.", MessageType.Info);
                }
            }
        }
    }
Пример #2
0
    public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
    {
        if (_enabledOptions == null)
        {
            return;
        }

        EditorGUILayout.HelpBox("Сохраняет конфигурацию бандлей в json", MessageType.Info);
        editor.UpdateNodeName(node);

        GUILayout.Space(10f);

        //Show target configuration tab
        editor.DrawPlatformSelector(node);
        using (new EditorGUILayout.VerticalScope(GUI.skin.box))
        {
            var disabledScope = editor.DrawOverrideTargetToggle(node, _enabledOptions.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) =>
            {
                using (new RecordUndoScope("Remove Target Bundle Options", node, true))
                {
                    if (enabled)
                    {
                        _enabledOptions[editor.CurrentEditingGroup] = _enabledOptions.DefaultValue;
                        _inputDir[editor.CurrentEditingGroup]       = _inputDir.DefaultValue;
                        _inputOption[editor.CurrentEditingGroup]    = _inputOption.DefaultValue;
                        _fileName[editor.CurrentEditingGroup]       = _fileName.DefaultValue;
                    }
                    else
                    {
                        _enabledOptions.Remove(editor.CurrentEditingGroup);
                        _inputDir.Remove(editor.CurrentEditingGroup);
                        _inputOption.Remove(editor.CurrentEditingGroup);
                        _fileName.Remove(editor.CurrentEditingGroup);
                    }

                    onValueChanged();
                }
            });

            using (disabledScope)
            {
                SaveBundlesConfigurationNode.OutputOption opt = (SaveBundlesConfigurationNode.OutputOption)_inputOption[editor.CurrentEditingGroup];
                var newOption = (SaveBundlesConfigurationNode.OutputOption)EditorGUILayout.EnumPopup("Output Option", opt);
                if (newOption != opt)
                {
                    using (new RecordUndoScope("Change Output Option", node, true))
                    {
                        _inputOption[editor.CurrentEditingGroup] = (int)newOption;
                        onValueChanged();
                    }
                }

                using (new EditorGUI.DisabledScope(opt == SaveBundlesConfigurationNode.OutputOption.BuildInCacheDirectory))
                {
                    var newDirPath = editor.DrawFolderSelector("Output Directory", "Select Output Folder",
                                                               _inputDir[editor.CurrentEditingGroup],
                                                               Application.dataPath + "/../",
                                                               (string folderSelected) =>
                    {
                        var projectPath = Directory.GetParent(Application.dataPath).ToString();

                        if (projectPath == folderSelected)
                        {
                            folderSelected = string.Empty;
                        }
                        else
                        {
                            var index = folderSelected.IndexOf(projectPath);
                            if (index >= 0)
                            {
                                folderSelected = folderSelected.Substring(projectPath.Length + index);
                                if (folderSelected.IndexOf('/') == 0)
                                {
                                    folderSelected = folderSelected.Substring(1);
                                }
                            }
                        }

                        return(folderSelected);
                    }
                                                               );
                    if (newDirPath != _inputDir[editor.CurrentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Output Directory", node, true))
                        {
                            _inputDir[editor.CurrentEditingGroup] = newDirPath;
                            onValueChanged();
                        }
                    }

                    var outputDir = PrepareOutputDirectory(BuildTargetUtility.GroupToTarget(editor.CurrentEditingGroup), node.Data, false);

                    if (opt == SaveBundlesConfigurationNode.OutputOption.ErrorIfNoOutputDirectoryFound &&
                        editor.CurrentEditingGroup != BuildTargetGroup.Unknown &&
                        !string.IsNullOrEmpty(_inputDir[editor.CurrentEditingGroup]) &&
                        !Directory.Exists(outputDir))
                    {
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            EditorGUILayout.LabelField(outputDir + " does not exist.");
                            if (GUILayout.Button("Create directory"))
                            {
                                Directory.CreateDirectory(outputDir);
                            }
                        }

                        EditorGUILayout.Space();

                        string parentDir = Path.GetDirectoryName(_inputDir[editor.CurrentEditingGroup]);
                        if (Directory.Exists(parentDir))
                        {
                            EditorGUILayout.LabelField("Available Directories:");
                            string[] dirs = Directory.GetDirectories(parentDir);
                            foreach (string s in dirs)
                            {
                                EditorGUILayout.LabelField(s);
                            }
                        }

                        EditorGUILayout.Space();
                    }

                    using (new EditorGUI.DisabledScope(!Directory.Exists(outputDir)))
                    {
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            GUILayout.FlexibleSpace();
#if UNITY_EDITOR_OSX
                            string buttonName = "Reveal in Finder";
#else
                            string buttonName = "Show in Explorer";
#endif
                            if (GUILayout.Button(buttonName))
                            {
                                EditorUtility.RevealInFinder(outputDir);
                            }
                        }
                    }

                    EditorGUILayout.HelpBox("You can use '{Platform}' variable for Output Directory path to include platform name.", MessageType.Info);
                }

                GUILayout.Space(8f);

                var fileName    = _fileName[editor.CurrentEditingGroup];
                var newFileName = EditorGUILayout.TextField("File Name", fileName);
                if (newFileName != fileName)
                {
                    using (new RecordUndoScope("Change File Name", node, true))
                    {
                        _fileName[editor.CurrentEditingGroup] = newFileName;
                        onValueChanged();
                    }
                }
            }
        }
    }
    public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
    {
        EditorGUILayout.HelpBox("Will delete all files, specified by bundles manifest and passed node condition." + Environment.NewLine +
                                " \"OnlyInBatchMode\" means node work only if unity run in batch mode", MessageType.Info);

        editor.UpdateNodeName(node);

        GUILayout.Space(10f);

        //Show target configuration tab
        editor.DrawPlatformSelector(node);
        using (new EditorGUILayout.VerticalScope(GUI.skin.box))
        {
            var disabledScope = editor.DrawOverrideTargetToggle(node, _enabledPerPlatformOptions.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) =>
            {
                using (new RecordUndoScope("Remove Target Bundle Options", node, true))
                {
                    if (enabled)
                    {
                        _enabledPerPlatformOptions[editor.CurrentEditingGroup] = _enabledPerPlatformOptions.DefaultValue;
                        _workingOption[editor.CurrentEditingGroup]             = _workingOption.DefaultValue;
                        _filterString[editor.CurrentEditingGroup] = _filterString.DefaultValue;
                    }
                    else
                    {
                        _enabledPerPlatformOptions.Remove(editor.CurrentEditingGroup);
                        _workingOption.Remove(editor.CurrentEditingGroup);
                        _filterString.Remove(editor.CurrentEditingGroup);
                    }

                    onValueChanged();
                }
            });

            using (disabledScope)
            {
                WorkOption opt       = (WorkOption)_workingOption[editor.CurrentEditingGroup];
                var        newOption = (WorkOption)EditorGUILayout.EnumPopup("Mode:", opt);
                if (newOption != opt)
                {
                    using (new RecordUndoScope("Change node mode", node, true))
                    {
                        _workingOption[editor.CurrentEditingGroup] = (int)newOption;
                        onValueChanged();
                    }
                }

                if (opt == WorkOption.RemoveByAssetPathContains ||
                    opt == WorkOption.RemoveByAssetPathStarts ||
                    opt == WorkOption.RemoveByAssetNameContains ||
                    opt == WorkOption.RemoveByAssetNameStarts)
                {
                    GUILayout.Space(8f);

                    var curRegexValue = _filterString[editor.CurrentEditingGroup];
                    EditorGUILayout.LabelField("Conditions, separated by new line:");

                    var newRegexValue = EditorGUILayout.TextArea(curRegexValue);

                    if (newRegexValue != curRegexValue)
                    {
                        using (new RecordUndoScope("Change Regex", node, true))
                        {
                            _filterString[editor.CurrentEditingGroup] = newRegexValue;
                            onValueChanged();
                        }
                    }
                }
            }
        }
    }
Пример #4
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            if (m_groupSizeByte == null)
            {
                return;
            }

            EditorGUILayout.HelpBox("Grouping by size: Create group of assets by size.", MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(10f);

            //Show target configuration tab
            editor.DrawPlatformSelector(node);
            using (new EditorGUILayout.VerticalScope(GUI.skin.box))
            {
                var disabledScope = editor.DrawOverrideTargetToggle(node, m_groupSizeByte.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) =>
                {
                    using (new RecordUndoScope("Remove Target Grouping Size Settings", node, true))
                    {
                        if (enabled)
                        {
                            m_groupSizeByte[editor.CurrentEditingGroup] = m_groupSizeByte.DefaultValue;
                            m_groupingType[editor.CurrentEditingGroup]  = m_groupingType.DefaultValue;
                        }
                        else
                        {
                            m_groupSizeByte.Remove(editor.CurrentEditingGroup);
                            m_groupingType.Remove(editor.CurrentEditingGroup);
                        }
                        onValueChanged();
                    }
                });
                EditorGUI.BeginDisabledGroup(disabledScope);
                #region DisableGroup
                var newType = (GroupingType)EditorGUILayout.EnumPopup("Grouping Type", (GroupingType)m_groupingType[editor.CurrentEditingGroup]);
                if (newType != (GroupingType)m_groupingType[editor.CurrentEditingGroup])
                {
                    using (new RecordUndoScope("Change Grouping Type", node, true))
                    {
                        m_groupingType[editor.CurrentEditingGroup] = (int)newType;
                        onValueChanged();
                    }
                }

                var newSizeText = EditorGUILayout.TextField("Size(KB)", m_groupSizeByte[editor.CurrentEditingGroup].ToString());
                int newSize     = 0;
                Int32.TryParse(newSizeText, out newSize);

                if (newSize != m_groupSizeByte[editor.CurrentEditingGroup])
                {
                    using (new RecordUndoScope("Change Grouping Size", node, true))
                    {
                        m_groupSizeByte[editor.CurrentEditingGroup] = newSize;
                        onValueChanged();
                    }
                }
                #endregion
                EditorGUI.EndDisabledGroup();
            }
        }