Esempio n. 1
0
    public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
    {
        EditorGUILayout.HelpBox("My Custom Node: Implement your own Inspector.", MessageType.Info);
        editor.UpdateNodeName(node);

        GUILayout.Space(10f);

        //Show target configuration tab
        editor.DrawPlatformSelector(node);
        using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
            // Draw Platform selector tab.
            var disabledScope = editor.DrawOverrideTargetToggle(node, m_result.ContainsValueOf(editor.CurrentEditingGroup), (bool b) => {
                using (new RecordUndoScope("Remove Target Platform Settings", node, true)) {
                    if (b)
                    {
                        m_result[editor.CurrentEditingGroup] = m_result.DefaultValue;
                    }
                    else
                    {
                        m_result.Remove(editor.CurrentEditingGroup);
                    }
                    onValueChanged();
                }
            });

            // Draw tab contents
            using (disabledScope) {
                var val = m_result[editor.CurrentEditingGroup];

                using (new GUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("Capture reference data"))
                    {
                        using (new RecordUndoScope("My Value Changed", node, true)){
                            val = JsonUtility.ToJson(m_current);
                            m_result[editor.CurrentEditingGroup] = val;
                            onValueChanged();
                        }
                    }
                    if (GUILayout.Button("Clear", GUILayout.Width(50f)))
                    {
                        m_result.Remove(editor.CurrentEditingGroup);
                        val = string.Empty;
                        onValueChanged();
                    }
                }


                GUILayout.Space(10f);
                if (!string.IsNullOrEmpty(val))
                {
                    GUILayout.Label("Reference Data", "BoldLabel");
//					var width = GUILayoutUtility.GetLastRect().width;
//					GUI.skin.label.CalcHeight(new GUIContent(val), 500f);
                    GUILayout.Label(val, GUI.skin.box, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));

                    GUILayout.Space(4f);
                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Copy to Clipboard", GUILayout.Width(150f)))
                        {
                            EditorGUIUtility.systemCopyBuffer = val;
                        }
                    }
                }
            }
        }
    }
Esempio n. 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();
                        }
                    }
                }
            }
        }
    }
Esempio n. 4
0
    public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor,
                                        Action onValueChanged)
    {
        editor.UpdateNodeName(node);

        GUILayout.Space(10f);

        editor.DrawPlatformSelector(node);
        using (new EditorGUILayout.VerticalScope(GUI.skin.box))
        {
            var disabledScope = editor.DrawOverrideTargetToggle(node, _enabledOptions.ContainsValueOf(editor.CurrentEditingGroup),
                                                                b =>
            {
                using (new RecordUndoScope("Remove Target Platform Settings", node, true))
                {
                    if (b)
                    {
                        _enabledOptions[editor.CurrentEditingGroup]   = _enabledOptions.DefaultValue;
                        _manifestFileName[editor.CurrentEditingGroup] = _manifestFileName.DefaultValue;
                        _resourcesPathes[editor.CurrentEditingGroup]  = _resourcesPathes.DefaultValue;
                    }
                    else
                    {
                        _enabledOptions.Remove(editor.CurrentEditingGroup);
                        _manifestFileName.Remove(editor.CurrentEditingGroup);
                        _resourcesPathes.Remove(editor.CurrentEditingGroup);
                    }

                    onValueChanged();
                }
            });

            using (disabledScope)
            {
                var newValue = EditorGUILayout.TextField("Output file name", _manifestFileName[editor.CurrentEditingGroup]);

                if (_manifestFileName[editor.CurrentEditingGroup] != newValue)
                {
                    using (new RecordUndoScope("Change Output file name", node, true))
                    {
                        _manifestFileName[editor.CurrentEditingGroup] = newValue;
                        onValueChanged();
                    }
                }

                EditorGUILayout.LabelField(
                    "Specify the folders, you want to cut from\nassets name. Use this if you have\none folder for all resources and want to\nmake assets name alb shorter.\nEach folder from a new line\nExample:\nMyStaffs/Dogs\nMyStaffs2/Cats",
                    GUILayout.Height(120));

                newValue = EditorGUILayout.TextArea(_resourcesPathes[editor.CurrentEditingGroup]);

                if (_resourcesPathes[editor.CurrentEditingGroup] != newValue)
                {
                    using (new RecordUndoScope("Change Resources pathes", node, true))
                    {
                        _resourcesPathes[editor.CurrentEditingGroup] = newValue;
                        onValueChanged();
                    }
                }
            }
        }
    }