예제 #1
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            EditorGUILayout.HelpBox("Build Player: Build Player.", MessageType.Info);
            editor.UpdateNodeName(node);

            if (m_buildOptions == null)
            {
                return;
            }

            GUILayout.Space(10f);

            //Show target configuration tab
            editor.DrawPlatformSelector(node);
            using (new EditorGUILayout.VerticalScope(GUI.skin.box))
            {
                var disabledScope = editor.DrawOverrideTargetToggle(node, m_buildOptions.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) =>
                {
                    using (new RecordUndoScope("Remove Target Build Settings", node, true))
                    {
                        if (enabled)
                        {
                            m_buildOptions[editor.CurrentEditingGroup]   = m_buildOptions.DefaultValue;
                            m_buildLocations[editor.CurrentEditingGroup] = m_buildLocations.DefaultValue;
                            m_playerName[editor.CurrentEditingGroup]     = m_playerName.DefaultValue;
                            m_scenes[editor.CurrentEditingGroup]         = m_scenes.DefaultValue;
                        }
                        else
                        {
                            m_buildOptions.Remove(editor.CurrentEditingGroup);
                            m_buildLocations.Remove(editor.CurrentEditingGroup);
                            m_playerName.Remove(editor.CurrentEditingGroup);
                            m_scenes.Remove(editor.CurrentEditingGroup);
                        }
                        onValueChanged();
                    }
                });

                using (disabledScope)
                {
                    using (var scrollScope = new EditorGUILayout.ScrollViewScope(m_scroll))
                    {
                        m_scroll = scrollScope.scrollPosition;
                        GUILayout.Label("Player Build Location", "BoldLabel");
                        var newBuildLocation = editor.DrawFolderSelector("", "Select Build Location",
                                                                         m_buildLocations[editor.CurrentEditingGroup],
                                                                         Application.dataPath + "/../"
                                                                         );
                        if (newBuildLocation.StartsWith(Application.dataPath))
                        {
                            throw new NodeException("You can not build player inside Assets directory.", node.Data);
                        }

                        if (newBuildLocation != m_buildLocations[editor.CurrentEditingGroup])
                        {
                            using (new RecordUndoScope("Change Build Location", node, true))
                            {
                                m_buildLocations[editor.CurrentEditingGroup] = newBuildLocation;
                                onValueChanged();
                            }
                        }
                        GUILayout.Space(4f);
                        var newPlayerName = EditorGUILayout.TextField("Player Name", m_playerName[editor.CurrentEditingGroup]);
                        if (newPlayerName != m_playerName[editor.CurrentEditingGroup])
                        {
                            using (new RecordUndoScope("Change Player Name", node, true))
                            {
                                m_playerName[editor.CurrentEditingGroup] = newPlayerName;
                                onValueChanged();
                            }
                        }

                        GUILayout.Space(10f);
                        GUILayout.Label("Build Options", "BoldLabel");
                        int buildOptions = m_buildOptions[editor.CurrentEditingGroup];
                        foreach (var option in Model.Settings.BuildPlayerOptionsSettings)
                        {
                            // contains keyword == enabled. if not, disabled.
                            bool isEnabled = (buildOptions & (int)option.option) != 0;

                            var result = EditorGUILayout.ToggleLeft(option.description, isEnabled);
                            if (result != isEnabled)
                            {
                                using (new RecordUndoScope("Change Build Option", node, true))
                                {
                                    buildOptions = (result) ?
                                                   ((int)option.option | buildOptions) :
                                                   (((~(int)option.option)) & buildOptions);
                                    m_buildOptions[editor.CurrentEditingGroup] = buildOptions;
                                    onValueChanged();
                                }
                            }
                        }

                        var scenesInProject = AssetDatabase.FindAssets("t:Scene");
                        if (scenesInProject.Length > 0)
                        {
                            GUILayout.Space(10f);
                            GUILayout.Label("Scenes", "BoldLabel");

                            using (new EditorGUILayout.VerticalScope(GUI.skin.box))
                            {
                                var scenesSelected = m_scenes[editor.CurrentEditingGroup].Split(',');

                                foreach (var sceneGUID in scenesInProject)
                                {
                                    var path = AssetDatabase.GUIDToAssetPath(sceneGUID);
                                    if (string.IsNullOrEmpty(path))
                                    {
                                        ArrayUtility.Remove(ref scenesSelected, sceneGUID);
                                        m_scenes[editor.CurrentEditingGroup] = string.Join(",", scenesSelected);
                                        onValueChanged();
                                        continue;
                                    }
                                    var type = TypeUtility.GetMainAssetTypeAtPath(path);
                                    if (type != typeof(UnityEditor.SceneAsset))
                                    {
                                        continue;
                                    }

                                    var selected    = scenesSelected.Contains(sceneGUID);
                                    var newSelected = EditorGUILayout.ToggleLeft(path, selected);
                                    if (newSelected != selected)
                                    {
                                        using (new RecordUndoScope("Change Scene Selection", node, true))
                                        {
                                            if (newSelected)
                                            {
                                                ArrayUtility.Add(ref scenesSelected, sceneGUID);
                                            }
                                            else
                                            {
                                                ArrayUtility.Remove(ref scenesSelected, sceneGUID);
                                            }
                                            m_scenes[editor.CurrentEditingGroup] = string.Join(",", scenesSelected);
                                            onValueChanged();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
 public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
 {
     EditorGUILayout.HelpBox("Last Imported Items: Load assets just imported.", MessageType.Info);
     editor.UpdateNodeName(node);
 }
예제 #3
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            if (m_enabledBundleOptions == null)
            {
                return;
            }

            EditorGUILayout.HelpBox("Build Asset Bundles: Build asset bundles with given asset bundle settings.", MessageType.Info);
            editor.UpdateNodeName(node);

            bool newOverwrite = EditorGUILayout.ToggleLeft("Keep AssetImporter settings for variants", m_overwriteImporterSetting);

            if (newOverwrite != m_overwriteImporterSetting)
            {
                using (new RecordUndoScope("Remove Target Bundle Options", node, true)){
                    m_overwriteImporterSetting = newOverwrite;
                    onValueChanged();
                }
            }

            GUILayout.Space(10f);

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

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

                    using (new EditorGUI.DisabledScope(opt == OutputOption.BuildInCacheDirectory)) {
                        var newDirPath = editor.DrawFolderSelector("Output Directory", "Select Output Folder",
                                                                   m_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 != m_outputDir[editor.CurrentEditingGroup])
                        {
                            using (new RecordUndoScope("Change Output Directory", node, true)){
                                m_outputDir[editor.CurrentEditingGroup] = newDirPath;
                                onValueChanged();
                            }
                        }

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

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

                            string parentDir = Path.GetDirectoryName(m_outputDir[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 manifestName    = m_manifestName[editor.CurrentEditingGroup];
                    var newManifestName = EditorGUILayout.TextField("Manifest Name", manifestName);
                    if (newManifestName != manifestName)
                    {
                        using (new RecordUndoScope("Change Manifest Name", node, true)){
                            m_manifestName[editor.CurrentEditingGroup] = newManifestName;
                            onValueChanged();
                        }
                    }

                    GUILayout.Space(8f);

                    int bundleOptions = m_enabledBundleOptions[editor.CurrentEditingGroup];

                    bool isDisableWriteTypeTreeEnabled  = 0 < (bundleOptions & (int)BuildAssetBundleOptions.DisableWriteTypeTree);
                    bool isIgnoreTypeTreeChangesEnabled = 0 < (bundleOptions & (int)BuildAssetBundleOptions.IgnoreTypeTreeChanges);

                    // buildOptions are validated during loading. Two flags should not be true at the same time.
                    UnityEngine.Assertions.Assert.IsFalse(isDisableWriteTypeTreeEnabled && isIgnoreTypeTreeChangesEnabled);

                    bool isSomethingDisabled = isDisableWriteTypeTreeEnabled || isIgnoreTypeTreeChangesEnabled;

                    foreach (var option in Model.Settings.BundleOptionSettings)
                    {
                        // contains keyword == enabled. if not, disabled.
                        bool isEnabled = (bundleOptions & (int)option.option) != 0;

                        bool isToggleDisabled =
                            (option.option == BuildAssetBundleOptions.DisableWriteTypeTree && isIgnoreTypeTreeChangesEnabled) ||
                            (option.option == BuildAssetBundleOptions.IgnoreTypeTreeChanges && isDisableWriteTypeTreeEnabled);

                        using (new EditorGUI.DisabledScope(isToggleDisabled)) {
                            var result = EditorGUILayout.ToggleLeft(option.description, isEnabled);
                            if (result != isEnabled)
                            {
                                using (new RecordUndoScope("Change Bundle Options", node, true)){
                                    bundleOptions = (result) ?
                                                    ((int)option.option | bundleOptions) :
                                                    (((~(int)option.option)) & bundleOptions);
                                    m_enabledBundleOptions[editor.CurrentEditingGroup] = bundleOptions;
                                    onValueChanged();
                                }
                            }
                        }
                    }
                    if (isSomethingDisabled)
                    {
                        EditorGUILayout.HelpBox("'Disable Write Type Tree' and 'Ignore Type Tree Changes' can not be used together.", MessageType.Info);
                    }
                }
            }
        }
예제 #4
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            if (m_bundleNameTemplate == null)
            {
                return;
            }

            EditorGUILayout.HelpBox("Configure Bundle From Group: Create asset bundle settings from incoming group of assets.", MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(10f);

            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                var newUseGroupAsVariantValue = GUILayout.Toggle(m_useGroupAsVariants, "Use input group as variants");
                if (newUseGroupAsVariantValue != m_useGroupAsVariants)
                {
                    using (new RecordUndoScope("Change Bundle Config", node, true)){
                        m_useGroupAsVariants = newUseGroupAsVariantValue;

                        List <Variant> rv = new List <Variant>(m_variants);
                        foreach (var v in rv)
                        {
                            NodeGUIUtility.NodeEventHandler(
                                new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_DELETED, node, Vector2.zero, GetConnectionPoint(node.Data, v)));
                            RemoveVariant(node.Data, v);
                        }
                        onValueChanged();
                    }
                }

                using (new EditorGUI.DisabledScope(newUseGroupAsVariantValue)) {
                    GUILayout.Label("Variants:");
                    var     variantNames = m_variants.Select(v => v.Name).ToList();
                    Variant removing     = null;
                    foreach (var v in m_variants)
                    {
                        using (new GUILayout.HorizontalScope()) {
                            if (GUILayout.Button("-", GUILayout.Width(30)))
                            {
                                removing = v;
                            }
                            else
                            {
                                GUIStyle s             = new GUIStyle((GUIStyle)"TextFieldDropDownText");
                                Action   makeStyleBold = () => {
                                    s.fontStyle = FontStyle.Bold;
                                    s.fontSize  = 12;
                                };

                                ValidateVariantName(v.Name, variantNames,
                                                    makeStyleBold,
                                                    makeStyleBold,
                                                    makeStyleBold);

                                var variantName = EditorGUILayout.TextField(v.Name, s);

                                if (variantName != v.Name)
                                {
                                    using (new RecordUndoScope("Change Variant Name", node, true)){
                                        v.Name = variantName;
                                        UpdateVariant(node.Data, v);
                                        onValueChanged();
                                    }
                                }
                            }
                        }
                    }
                    if (GUILayout.Button("+"))
                    {
                        using (new RecordUndoScope("Add Variant", node, true)){
                            if (m_variants.Count == 0)
                            {
                                NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_DELETE_ALL_CONNECTIONS_TO_POINT, node, Vector2.zero, node.Data.InputPoints[0]));
                            }
                            AddVariant(node.Data, Model.Settings.BUNDLECONFIG_VARIANTNAME_DEFAULT);
                            onValueChanged();
                        }
                    }
                    if (removing != null)
                    {
                        using (new RecordUndoScope("Remove Variant", node, true)){
                            // event must raise to remove connection associated with point
                            NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_DELETED, node, Vector2.zero, GetConnectionPoint(node.Data, removing)));
                            RemoveVariant(node.Data, removing);
                            onValueChanged();
                        }
                    }
                }
            }

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

                using (disabledScope) {
                    var bundleNameTemplate = EditorGUILayout.TextField("Bundle Name Template", m_bundleNameTemplate[editor.CurrentEditingGroup]).ToLower();

                    if (bundleNameTemplate != m_bundleNameTemplate[editor.CurrentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Bundle Name Template", node, true)){
                            m_bundleNameTemplate[editor.CurrentEditingGroup] = bundleNameTemplate;
                            onValueChanged();
                        }
                    }
                }
            }
        }
예제 #5
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            if (m_srcPath == null)
            {
                return;
            }

            var currentEditingGroup = editor.CurrentEditingGroup;

            EditorGUILayout.HelpBox("Mirror Directory: Mirror source directory to destination. This node does not use assets passed by.", 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_srcPath.ContainsValueOf(currentEditingGroup), (bool enabled) => {
                    using (new RecordUndoScope("Remove Target Mirror Directory Settings", node, true)){
                        if (enabled)
                        {
                            m_srcPath[currentEditingGroup]      = m_srcPath.DefaultValue;
                            m_dstPath[currentEditingGroup]      = m_dstPath.DefaultValue;
                            m_mirrorOption[currentEditingGroup] = m_mirrorOption.DefaultValue;
                        }
                        else
                        {
                            m_srcPath.Remove(currentEditingGroup);
                            m_dstPath.Remove(currentEditingGroup);
                            m_mirrorOption[currentEditingGroup] = m_mirrorOption.DefaultValue;
                        }
                        onValueChanged();
                    }
                });

                using (disabledScope) {
                    MirrorOption opt       = (MirrorOption)m_mirrorOption[currentEditingGroup];
                    var          newOption = (MirrorOption)EditorGUILayout.EnumPopup("Mirror Option", opt);
                    if (newOption != opt)
                    {
                        using (new RecordUndoScope("Change Mirror Option", node, true)){
                            m_mirrorOption[currentEditingGroup] = (int)newOption;
                            onValueChanged();
                        }
                    }

                    EditorGUILayout.LabelField("Source Directory Path:");

                    string newSrcPath = null;
                    string newDstPath = null;

                    newSrcPath = editor.DrawFolderSelector("", "Select Source Folder",
                                                           m_srcPath[currentEditingGroup],
                                                           Directory.GetParent(Application.dataPath).ToString(),
                                                           (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 (newSrcPath != m_srcPath[currentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Source Folder", node, true)){
                            m_srcPath[currentEditingGroup] = newSrcPath;
                            onValueChanged();
                        }
                    }
                    DrawDirectorySuggestion(GetNormalizedPath(m_srcPath[currentEditingGroup]), currentEditingGroup, onValueChanged);

                    GUILayout.Space(10f);

                    EditorGUILayout.LabelField("Destination Directory Path:");
                    newDstPath = editor.DrawFolderSelector("", "Select Destination Folder",
                                                           m_dstPath[currentEditingGroup],
                                                           Directory.GetParent(Application.dataPath).ToString(),
                                                           (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 (newDstPath != m_dstPath[currentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Destination Folder", node, true)){
                            m_dstPath[currentEditingGroup] = newDstPath;
                            onValueChanged();
                        }
                    }

                    DrawDirectorySuggestion(GetNormalizedPath(m_dstPath[currentEditingGroup]), currentEditingGroup, onValueChanged);
                }
            }
        }
예제 #6
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            if (m_destinationPath == null)
            {
                return;
            }

            var currentEditingGroup = editor.CurrentEditingGroup;

            EditorGUILayout.HelpBox("File Operation: Copy or Move Files.", MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(10f);

            var newOp = (FileOperationType)EditorGUILayout.EnumPopup("Operation", m_operationType);

            if (newOp != m_operationType)
            {
                using (new RecordUndoScope("Change Copy/Move Operation", node, true))
                {
                    m_operationType = newOp;
                    onValueChanged();
                }
            }

            var newDepth = EditorGUILayout.IntField("Removing Directory Depth", m_removingDirectoryDepth);

            if (newDepth != m_removingDirectoryDepth)
            {
                using (new RecordUndoScope("Change Directory Depth", node, true))
                {
                    m_removingDirectoryDepth = newDepth;
                    onValueChanged();
                }
            }

            GUILayout.Space(8f);

            //Show target configuration tab
            editor.DrawPlatformSelector(node);
            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                var disabledScope = editor.DrawOverrideTargetToggle(node, m_destinationPath.ContainsValueOf(currentEditingGroup), (bool enabled) => {
                    using (new RecordUndoScope("Remove Target Directory Settings", node, true)){
                        if (enabled)
                        {
                            m_destinationPath[currentEditingGroup]   = m_destinationPath.DefaultValue;
                            m_destinationOption[currentEditingGroup] = m_destinationOption.DefaultValue;
                        }
                        else
                        {
                            m_destinationPath.Remove(currentEditingGroup);
                            m_destinationOption.Remove(currentEditingGroup);
                        }
                        onValueChanged();
                    }
                });

                using (disabledScope) {
                    DestinationDirectoryOption opt = (DestinationDirectoryOption)m_destinationOption[currentEditingGroup];
                    var newOption = (DestinationDirectoryOption)EditorGUILayout.EnumPopup("Directory Option", opt);
                    if (newOption != opt)
                    {
                        using (new RecordUndoScope("Change Directory Option", node, true)){
                            m_destinationOption[currentEditingGroup] = (int)newOption;
                            onValueChanged();
                        }
                    }

                    EditorGUILayout.LabelField("Destination Path:");

                    string newDstPath = null;

                    newDstPath = editor.DrawFolderSelector("", "Select Destination Folder",
                                                           m_destinationPath[currentEditingGroup],
                                                           GetDestinationPath(m_destinationPath[currentEditingGroup]),
                                                           (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 (newDstPath != m_destinationPath[currentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Destination Path", node, true)){
                            m_destinationPath[currentEditingGroup] = newDstPath;
                            onValueChanged();
                        }
                    }

                    var exporterNodePath = GetDestinationPath(newDstPath);
                    if (ValidateExportPath(
                            newDstPath,
                            exporterNodePath,
                            () => {
                    },
                            () => {
                        using (new EditorGUILayout.HorizontalScope()) {
                            EditorGUILayout.LabelField(exporterNodePath + " does not exist.");
                            if (GUILayout.Button("Create directory"))
                            {
                                Directory.CreateDirectory(exporterNodePath);
                            }
                            onValueChanged();
                        }
                        EditorGUILayout.Space();

                        string parentDir = Path.GetDirectoryName(exporterNodePath);
                        if (Directory.Exists(parentDir))
                        {
                            EditorGUILayout.LabelField("Available Directories:");
                            string[] dirs = Directory.GetDirectories(parentDir);
                            foreach (string s in dirs)
                            {
                                EditorGUILayout.LabelField(s);
                            }
                        }
                    }
                            ))
                    {
                        GUILayout.Space(10f);

                        using (new EditorGUILayout.HorizontalScope()) {
                            GUILayout.FlexibleSpace();
                            if (GUILayout.Button(GUIHelper.RevealInFinderLabel))
                            {
                                EditorUtility.RevealInFinder(exporterNodePath);
                            }
                        }
                    }
                }
            }
        }
예제 #7
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            EditorGUILayout.HelpBox("Modify Assets Directly: Modify assets.", MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(10f);

            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                if (string.IsNullOrEmpty(m_modifierType))
                {
                    EditorGUILayout.HelpBox("Select asset type to modify with this node.", MessageType.Info);
                    using (new EditorGUILayout.HorizontalScope()) {
                        EditorGUILayout.LabelField("Asset Type");
                        if (GUILayout.Button("", "Popup", GUILayout.MinWidth(150f)))
                        {
                            var menu = new GenericMenu();

                            var types = ModifierUtility.GetModifyableTypes().ToArray();

                            for (var i = 0; i < types.Length; i++)
                            {
                                var index = i;
                                menu.AddItem(
                                    new GUIContent(types [i].Name),
                                    false,
                                    () => {
                                    ResetConfig();
                                    m_modifierType = types[index].AssemblyQualifiedName;
                                }
                                    );
                            }
                            menu.ShowAsContext();
                        }
                    }
                    return;
                }

                var targetType = Type.GetType(m_modifierType);
                var modifier   = m_instance.Get <IModifier>(editor.CurrentEditingGroup);

                Dictionary <string, string> map = null;

                if (targetType != null)
                {
                    EditorGUILayout.LabelField("Asset Type", targetType.Name);

                    map = ModifierUtility.GetAttributeAssemblyQualifiedNameMap(targetType);
                }

                if (map != null && map.Count > 0)
                {
                    using (new GUILayout.HorizontalScope()) {
                        GUILayout.Label("Modifier");
                        var guiName = ModifierUtility.GetModifierGUIName(m_instance.ClassName);
                        if (GUILayout.Button(guiName, "Popup", GUILayout.MinWidth(150f)))
                        {
                            var builders = map.Keys.ToList();

                            if (builders.Count > 0)
                            {
                                NodeGUI.ShowTypeNamesMenu(guiName, builders, (string selectedGUIName) =>
                                {
                                    using (new RecordUndoScope("Change Modifier class", node, true)) {
                                        modifier = ModifierUtility.CreateModifier(selectedGUIName, targetType);
                                        m_instance.Set(editor.CurrentEditingGroup, modifier);
                                        onValueChanged();
                                    }
                                }
                                                          );
                            }
                        }

                        MonoScript s = TypeUtility.LoadMonoScript(m_instance.ClassName);

                        using (new EditorGUI.DisabledScope(s == null)) {
                            if (GUILayout.Button("Edit", GUILayout.Width(50)))
                            {
                                AssetDatabase.OpenAsset(s, 0);
                            }
                        }
                    }
                }
                else
                {
                    string[] menuNames = Model.Settings.GUI_TEXT_MENU_GENERATE_MODIFIER.Split('/');

                    if (targetType == null)
                    {
                        EditorGUILayout.HelpBox(
                            string.Format(
                                "You need to create at least one Modifier script to select script for Modifier. " +
                                "To start, select {0}>{1}>{2} menu and create a new script.",
                                menuNames[1], menuNames[2], menuNames[3]
                                ), MessageType.Info);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox(
                            string.Format(
                                "No CustomModifier found for {3} type. \n" +
                                "You need to create at least one Modifier script to select script for Modifier. " +
                                "To start, select {0}>{1}>{2} menu and create a new script.",
                                menuNames[1], menuNames[2], menuNames[3], targetType.FullName
                                ), MessageType.Info);
                    }
                }

                GUILayout.Space(10f);

                editor.DrawPlatformSelector(node);
                using (new EditorGUILayout.VerticalScope()) {
                    var disabledScope = editor.DrawOverrideTargetToggle(node, m_instance.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => {
                        if (enabled)
                        {
                            m_instance.CopyDefaultValueTo(editor.CurrentEditingGroup);
                        }
                        else
                        {
                            m_instance.Remove(editor.CurrentEditingGroup);
                        }
                        onValueChanged();
                    });

                    using (disabledScope) {
                        if (modifier != null)
                        {
                            Action onChangedAction = () => {
                                using (new RecordUndoScope("Change Modifier Setting", node)) {
                                    m_instance.Set(editor.CurrentEditingGroup, modifier);
                                    onValueChanged();
                                }
                            };

                            modifier.OnInspectorGUI(onChangedAction);
                        }
                    }
                }

                GUILayout.Space(40f);
                using (new EditorGUILayout.HorizontalScope(GUI.skin.box)) {
                    GUILayout.Space(4f);
                    EditorGUILayout.LabelField("Reset Modifier Setting");

                    if (GUILayout.Button("Clear"))
                    {
                        if (EditorUtility.DisplayDialog("Clear Modifier Setting",
                                                        string.Format("Do you want to reset modifier for \"{0}\"?", node.Name), "OK", "Cancel"))
                        {
                            using (new RecordUndoScope("Clear Modifier Setting", node)) {
                                ResetConfig();
                            }
                        }
                    }
                }
            }
        }
예제 #8
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            EditorGUILayout.HelpBox("Overwrite Import Setting: Overwrite import settings of incoming assets.", MessageType.Info);
            editor.UpdateNodeName(node);

            // prevent inspector flicking by new Editor changing active selction
            node.SetActive(true);

            using (new EditorGUILayout.VerticalScope()) {
                Type importerType = null;
                Type assetType    = null;

                var referenceImporter = GetReferenceAssetImporter(node.Data, false);
                if (referenceImporter != null)
                {
                    importerType = referenceImporter.GetType();
                    assetType    = TypeUtility.GetMainAssetTypeAtPath(AssetDatabase.GUIDToAssetPath(m_referenceAssetGuid));
                }
                else
                {
                    GUILayout.Space(10f);
                    using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                        EditorGUILayout.HelpBox("Import setting type can be set by incoming asset, or you can specify by selecting.", MessageType.Info);
                        using (new EditorGUILayout.HorizontalScope()) {
                            EditorGUILayout.LabelField("Importer Type");
                            if (GUILayout.Button("", "Popup", GUILayout.MinWidth(150f)))
                            {
                                var menu = new GenericMenu();

                                var guiMap   = ImporterConfiguratorUtility.GetImporterConfiguratorGuiNameTypeMap();
                                var guiNames = guiMap.Keys.ToArray();

                                for (var i = 0; i < guiNames.Length; i++)
                                {
                                    var index = i;
                                    menu.AddItem(
                                        new GUIContent(guiNames [i]),
                                        false,
                                        () => {
                                        ResetConfig(node.Data);
                                        CreateConfigurator(node.Data, guiMap [guiNames [index]]);
                                        onValueChanged();
                                        // call Validate
                                        NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_UPDATED, node));
                                    }
                                        );
                                }
                                menu.ShowAsContext();
                            }
                        }
                    }
                    return;
                }

                if (importerType != null && assetType != null)
                {
                    GUILayout.Space(10f);
                    DoCustomAssetGUI(assetType, importerType, node, editor, onValueChanged);
                }

                // get reference importer again (enabling custom asset this time)
                referenceImporter = GetReferenceAssetImporter(node.Data, true);

                if (referenceImporter != null)
                {
                    var configurator = m_configuratorInstance.Get <IAssetImporterConfigurator> (editor.CurrentEditingGroup);
                    if (configurator != null)
                    {
                        GUILayout.Space(10f);

                        Action onChangedAction = () => {
                            using (new RecordUndoScope(string.Format("Change {0} Setting", node.Name), node)) {
                                m_configuratorInstance.Set(editor.CurrentEditingGroup, configurator);
                                onValueChanged();
                            }
                        };

                        configurator.OnInspectorGUI(referenceImporter, editor.CurrentEditingGroup, onChangedAction);
                    }

                    if (m_importerEditor == null)
                    {
                        m_importerEditor = Editor.CreateEditor(referenceImporter);
                    }
                }

                if (m_importerEditor != null)
                {
                    GUILayout.Space(10f);
                    GUILayout.Label(string.Format("Import Setting ({0})", importerType.Name));
                    m_importerEditor.OnInspectorGUI();
                }

                GUILayout.Space(40f);
                using (new EditorGUILayout.HorizontalScope(GUI.skin.box)) {
                    GUILayout.Space(4f);
                    EditorGUILayout.LabelField("Clear Saved Import Setting");

                    if (GUILayout.Button("Clear"))
                    {
                        if (EditorUtility.DisplayDialog("Clear Saved Import Setting",
                                                        string.Format("Do you want to reset saved import setting for \"{0}\"? This operation is not undoable.", node.Name), "OK", "Cancel"))
                        {
                            ResetConfig(node.Data);
                            onValueChanged();
                        }
                    }
                }
            }
        }
예제 #9
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;
                            m_groupNameFormat[editor.CurrentEditingGroup] = m_groupNameFormat.DefaultValue;
                        }
                        else
                        {
                            m_groupSizeByte.Remove(editor.CurrentEditingGroup);
                            m_groupingType.Remove(editor.CurrentEditingGroup);
                            m_groupNameFormat.Remove(editor.CurrentEditingGroup);
                        }
                        onValueChanged();
                    }
                });

                using (disabledScope) {
                    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();
                        }
                    }

                    var newGroupNameFormat = EditorGUILayout.TextField("Group Name Format", m_groupNameFormat [editor.CurrentEditingGroup]);
                    EditorGUILayout.HelpBox(
                        "You can customize group name. You can use variable {OldGroup} for old group name and {NewGroup} for current matching name.",
                        MessageType.Info);

                    if (newGroupNameFormat != m_groupNameFormat [editor.CurrentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Group Name", node, true)) {
                            m_groupNameFormat [editor.CurrentEditingGroup] = newGroupNameFormat;
                            onValueChanged();
                        }
                    }
                }
            }

            var newFreezeGroups = EditorGUILayout.ToggleLeft("Freeze group on build", m_freezeGroups);

            if (newFreezeGroups != m_freezeGroups)
            {
                using (new RecordUndoScope("Change Freeze Groups", node, true)){
                    m_freezeGroups = newFreezeGroups;
                    onValueChanged();
                }
            }
            EditorGUILayout.HelpBox("Freezing group will save group when build is performed, and any new asset from there will be put into new group.",
                                    MessageType.Info);
            using (new GUILayout.HorizontalScope()) {
                GUILayout.Label("Group setting");
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Import"))
                {
                    if (ImportGroupsWithGUI(node))
                    {
                        onValueChanged();
                    }
                }
                if (GUILayout.Button("Export"))
                {
                    ExportGroupsWithGUI(node);
                }
                if (GUILayout.Button("Reset"))
                {
                    if (EditorUtility.DisplayDialog("Do you want to reset group setting?", "This will erase current saved group setting.", "OK", "Cancel"))
                    {
                        m_savedGroups = null;
                        onValueChanged();
                    }
                }
            }
            GUILayout.Space(8f);

            if (m_groupViewController != null)
            {
                m_groupViewController.OnGroupViewGUI();
            }
        }
예제 #10
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            EditorGUILayout.HelpBox("Create Prefab From Group: Create prefab from incoming group of assets, using assigned script.", MessageType.Info);
            editor.UpdateNodeName(node);

            var builder = m_instance.Get <IPrefabBuilder>(editor.CurrentEditingGroup);

            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                var map = PrefabBuilderUtility.GetAttributeAssemblyQualifiedNameMap();
                if (map.Count > 0)
                {
                    using (new GUILayout.HorizontalScope()) {
                        GUILayout.Label("PrefabBuilder");
                        var guiName = PrefabBuilderUtility.GetPrefabBuilderGUIName(m_instance.ClassName);

                        if (GUILayout.Button(guiName, "Popup", GUILayout.MinWidth(150f)))
                        {
                            var builders = map.Keys.ToList();

                            if (builders.Count > 0)
                            {
                                NodeGUI.ShowTypeNamesMenu(guiName, builders, (string selectedGUIName) =>
                                {
                                    using (new RecordUndoScope("Change PrefabBuilder class", node, true)) {
                                        builder = PrefabBuilderUtility.CreatePrefabBuilder(selectedGUIName);
                                        m_instance.Set(editor.CurrentEditingGroup, builder);
                                        onValueChanged();
                                    }
                                }
                                                          );
                            }
                        }

                        MonoScript s = TypeUtility.LoadMonoScript(m_instance.ClassName);

                        using (new EditorGUI.DisabledScope(s == null)) {
                            if (GUILayout.Button("Edit", GUILayout.Width(50)))
                            {
                                AssetDatabase.OpenAsset(s, 0);
                            }
                        }
                    }
                    ReplacePrefabOptions opt = (ReplacePrefabOptions)EditorGUILayout.EnumPopup("Prefab Replace Option", m_replacePrefabOptions, GUILayout.MinWidth(150f));
                    if (m_replacePrefabOptions != opt)
                    {
                        using (new RecordUndoScope("Change Prefab Replace Option", node, true)) {
                            m_replacePrefabOptions = opt;
                            onValueChanged();
                        }
                        opt = m_replacePrefabOptions;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(m_instance.ClassName))
                    {
                        EditorGUILayout.HelpBox(
                            string.Format(
                                "Your PrefabBuilder script {0} is missing from assembly. Did you delete script?", m_instance.ClassName), MessageType.Info);
                    }
                    else
                    {
                        string[] menuNames = Model.Settings.GUI_TEXT_MENU_GENERATE_PREFABBUILDER.Split('/');
                        EditorGUILayout.HelpBox(
                            string.Format(
                                "You need to create at least one PrefabBuilder script to use this node. To start, select {0}>{1}>{2} menu and create new script from template.",
                                menuNames[1], menuNames[2], menuNames[3]
                                ), MessageType.Info);
                    }
                }

                GUILayout.Space(10f);

                editor.DrawPlatformSelector(node);
                using (new EditorGUILayout.VerticalScope()) {
                    var disabledScope = editor.DrawOverrideTargetToggle(node, m_instance.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => {
                        if (enabled)
                        {
                            m_instance.CopyDefaultValueTo(editor.CurrentEditingGroup);
                            m_outputDir[editor.CurrentEditingGroup]    = m_outputDir.DefaultValue;
                            m_outputOption[editor.CurrentEditingGroup] = m_outputOption.DefaultValue;
                        }
                        else
                        {
                            m_instance.Remove(editor.CurrentEditingGroup);
                            m_outputDir.Remove(editor.CurrentEditingGroup);
                            m_outputOption.Remove(editor.CurrentEditingGroup);
                        }
                        onValueChanged();
                    });

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

                        using (new EditorGUI.DisabledScope(opt == OutputOption.CreateInCacheDirectory)) {
                            var newDirPath = editor.DrawFolderSelector("Output Directory", "Select Output Folder",
                                                                       m_outputDir[editor.CurrentEditingGroup],
                                                                       Application.dataPath,
                                                                       (string folderSelected) => {
                                string basePath = Application.dataPath;

                                if (basePath == folderSelected)
                                {
                                    folderSelected = string.Empty;
                                }
                                else
                                {
                                    var index = folderSelected.IndexOf(basePath);
                                    if (index >= 0)
                                    {
                                        folderSelected = folderSelected.Substring(basePath.Length + index);
                                        if (folderSelected.IndexOf('/') == 0)
                                        {
                                            folderSelected = folderSelected.Substring(1);
                                        }
                                    }
                                }
                                return(folderSelected);
                            }
                                                                       );
                            if (newDirPath != m_outputDir[editor.CurrentEditingGroup])
                            {
                                using (new RecordUndoScope("Change Output Directory", node, true)){
                                    m_outputDir[editor.CurrentEditingGroup] = newDirPath;
                                    onValueChanged();
                                }
                            }

                            var dirPath = Path.Combine(Application.dataPath, m_outputDir [editor.CurrentEditingGroup]);

                            if (opt == OutputOption.CreateInSelectedDirectory &&
                                !string.IsNullOrEmpty(m_outputDir [editor.CurrentEditingGroup]) &&
                                !Directory.Exists(dirPath))
                            {
                                using (new EditorGUILayout.HorizontalScope()) {
                                    EditorGUILayout.LabelField(m_outputDir[editor.CurrentEditingGroup] + " does not exist.");
                                    if (GUILayout.Button("Create directory"))
                                    {
                                        Directory.CreateDirectory(dirPath);
                                        AssetDatabase.Refresh();
                                    }
                                }
                                EditorGUILayout.Space();

                                string parentDir = Path.GetDirectoryName(m_outputDir[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();
                            }

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

                            using (new EditorGUI.DisabledScope(!Directory.Exists(outputDir)))
                            {
                                using (new EditorGUILayout.HorizontalScope()) {
                                    GUILayout.FlexibleSpace();
                                    if (GUILayout.Button("Highlight in Project Window", GUILayout.Width(180f)))
                                    {
                                        var folder = AssetDatabase.LoadMainAssetAtPath(outputDir);
                                        EditorGUIUtility.PingObject(folder);
                                    }
                                }
                            }
                        }

                        GUILayout.Space(8f);

                        if (builder != null)
                        {
                            Action onChangedAction = () => {
                                using (new RecordUndoScope("Change PrefabBuilder Setting", node)) {
                                    m_instance.Set(editor.CurrentEditingGroup, builder);
                                    onValueChanged();
                                }
                            };

                            builder.OnInspectorGUI(onChangedAction);
                        }
                    }
                }
            }
        }
예제 #11
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            EditorGUILayout.HelpBox("Assert Unwanted Assets In Bundle: Checks if unwanted assets are included in bundle configurations.", MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(10f);

            var newValue = (AssertionStyle)EditorGUILayout.EnumPopup("Assertion Style", m_style);

            if (newValue != m_style)
            {
                using (new RecordUndoScope("Change Assertion Style", node, true)) {
                    m_style = newValue;
                    onValueChanged();
                }
            }

            GUILayout.Space(4f);

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

                using (disabledScope) {
                    var path = m_path[editor.CurrentEditingGroup];
                    EditorGUILayout.LabelField("Assertion Path:");

                    string newLoadPath = null;

                    newLoadPath = editor.DrawFolderSelector(Model.Settings.Path.ASSETS_PATH, "Select Asset Folder",
                                                            path,
                                                            FileUtility.PathCombine(Model.Settings.Path.ASSETS_PATH, path),
                                                            (string folderSelected) => {
                        var dataPath = Application.dataPath;
                        if (dataPath == folderSelected)
                        {
                            folderSelected = string.Empty;
                        }
                        else
                        {
                            var index = folderSelected.IndexOf(dataPath);
                            if (index >= 0)
                            {
                                folderSelected = folderSelected.Substring(dataPath.Length + index);
                                if (folderSelected.IndexOf('/') == 0)
                                {
                                    folderSelected = folderSelected.Substring(1);
                                }
                            }
                        }
                        return(folderSelected);
                    }
                                                            );

                    if (newLoadPath != path)
                    {
                        using (new RecordUndoScope("Path Change", node, true)){
                            m_path[editor.CurrentEditingGroup] = newLoadPath;
                            onValueChanged();
                        }
                    }

                    var  dirPath   = Path.Combine(Model.Settings.Path.ASSETS_PATH, newLoadPath);
                    bool dirExists = Directory.Exists(dirPath);

                    GUILayout.Space(10f);

                    using (new EditorGUILayout.HorizontalScope()) {
                        using (new EditorGUI.DisabledScope(string.IsNullOrEmpty(newLoadPath) || !dirExists))
                        {
                            GUILayout.FlexibleSpace();
                            if (GUILayout.Button("Highlight in Project Window", GUILayout.Width(180f)))
                            {
                                // trailing is "/" not good for LoadMainAssetAtPath
                                if (dirPath[dirPath.Length - 1] == '/')
                                {
                                    dirPath = dirPath.Substring(0, dirPath.Length - 1);
                                }
                                var obj = AssetDatabase.LoadMainAssetAtPath(dirPath);
                                EditorGUIUtility.PingObject(obj);
                            }
                        }
                    }
                }
            }
        }
예제 #12
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            if (m_importDirectoryPath == null)
            {
                return;
            }

            var currentEditingGroup = editor.CurrentEditingGroup;

            EditorGUILayout.HelpBox("Import Unity Packages: Import Unity Packages.", 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_importDirectoryPath.ContainsValueOf(currentEditingGroup), (bool enabled) => {
                    using (new RecordUndoScope("Remove Target Export Settings", node, true)){
                        if (enabled)
                        {
                            m_importDirectoryPath[currentEditingGroup] = m_importDirectoryPath.DefaultValue;
                            m_isInteractive[currentEditingGroup]       = m_isInteractive.DefaultValue;
                            m_isRecursive[currentEditingGroup]         = m_isRecursive.DefaultValue;
                        }
                        else
                        {
                            m_importDirectoryPath.Remove(currentEditingGroup);
                            m_isInteractive.Remove(currentEditingGroup);
                            m_isRecursive.Remove(currentEditingGroup);
                        }
                        onValueChanged();
                    }
                });

                using (disabledScope) {
                    EditorGUILayout.LabelField("Import Path:");

                    string newImportDir = null;

                    newImportDir = editor.DrawFolderSelector("", "Select Import Folder",
                                                             m_importDirectoryPath[currentEditingGroup],
                                                             GetImportDirectoryPath(m_importDirectoryPath[currentEditingGroup]),
                                                             (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 (newImportDir != m_importDirectoryPath[currentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Import Path", node, true)){
                            m_importDirectoryPath[currentEditingGroup] = newImportDir;
                            onValueChanged();
                        }
                    }

                    int isInteractive    = m_isInteractive[currentEditingGroup];
                    var newIsInteractive = EditorGUILayout.ToggleLeft("Interactive", isInteractive == 1) ? 1:0;
                    if (newIsInteractive != isInteractive)
                    {
                        using (new RecordUndoScope("Change Interactive", node, true)){
                            m_isInteractive[currentEditingGroup] = newIsInteractive;
                            onValueChanged();
                        }
                    }

                    int isRecursive    = m_isRecursive[currentEditingGroup];
                    var newIsRecursive = EditorGUILayout.ToggleLeft("Import packages in subfolders", isRecursive == 1) ? 1:0;
                    if (newIsRecursive != isRecursive)
                    {
                        using (new RecordUndoScope("Change Recursive", node, true)){
                            m_isRecursive[currentEditingGroup] = newIsRecursive;
                            onValueChanged();
                        }
                    }


                    var importDirectoryPath = GetImportDirectoryPath(newImportDir);
                    if (!Directory.Exists(importDirectoryPath))
                    {
                        using (new EditorGUILayout.HorizontalScope()) {
                            EditorGUILayout.LabelField(importDirectoryPath + " does not exist.");
                            if (GUILayout.Button("Create directory"))
                            {
                                Directory.CreateDirectory(importDirectoryPath);
                            }
                            onValueChanged();
                        }
                        EditorGUILayout.Space();

                        var parentDir = Path.GetDirectoryName(importDirectoryPath);
                        if (Directory.Exists(parentDir))
                        {
                            EditorGUILayout.LabelField("Available Directories:");
                            var dirs = Directory.GetDirectories(parentDir);
                            foreach (var s in dirs)
                            {
                                EditorGUILayout.LabelField(s);
                            }
                        }
                    }
                    else
                    {
                        GUILayout.Space(10f);

                        using (new EditorGUILayout.HorizontalScope()) {
                            GUILayout.FlexibleSpace();
                            if (GUILayout.Button(GUIHelper.RevealInFinderLabel))
                            {
                                EditorUtility.RevealInFinder(importDirectoryPath);
                            }
                        }
                    }
                }
            }
        }
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            var currentEditingGroup = editor.CurrentEditingGroup;

            EditorGUILayout.HelpBox("Export As UnityPackage: Export given files as UnityPackage.", 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_packageName.ContainsValueOf(currentEditingGroup), (bool enabled) => {
                    using (new RecordUndoScope("Remove Target Export Settings", node, true)){
                        if (enabled)
                        {
                            m_packageName[currentEditingGroup]          = m_packageName.DefaultValue;
                            m_exportPackageOptions[currentEditingGroup] = m_exportPackageOptions.DefaultValue;
                        }
                        else
                        {
                            m_packageName.Remove(currentEditingGroup);
                            m_exportPackageOptions.Remove(currentEditingGroup);
                        }
                        onValueChanged();
                    }
                });

                using (disabledScope) {
                    var name    = m_packageName[currentEditingGroup];
                    var newName = EditorGUILayout.TextField("Package Name", name);
                    if (newName != name)
                    {
                        using (new RecordUndoScope("Change Package Name", node, true)){
                            m_packageName[currentEditingGroup] = newName;
                            onValueChanged();
                        }
                    }
                    EditorGUILayout.HelpBox("You can use {Platform} and {GroupName} for package name variable.", MessageType.Info);

                    GUILayout.Space(8f);

                    var exportOptions = m_exportPackageOptions[currentEditingGroup];

                    foreach (var option in Model.Settings.ExportPackageOptions)
                    {
                        // contains keyword == enabled. if not, disabled.
                        var isEnabled = (exportOptions & (int)option.option) != 0;
                        var result    = EditorGUILayout.ToggleLeft(option.description, isEnabled);
                        if (result != isEnabled)
                        {
                            using (new RecordUndoScope("Change Bundle Options", node, true)){
                                exportOptions = (result) ?
                                                ((int)option.option | exportOptions) :
                                                (((~(int)option.option)) & exportOptions);
                                m_exportPackageOptions[editor.CurrentEditingGroup] = exportOptions;
                                onValueChanged();
                            }
                        }
                    }
                }
            }
        }
예제 #14
0
파일: Loader.cs 프로젝트: kookllcat3/MyKit
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            if (m_loadPath == null)
            {
                return;
            }

            EditorGUILayout.HelpBox("Load From Directory: Load assets from given directory path.", MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(10f);

            bool bRespondAP = EditorGUILayout.ToggleLeft("Respond To Asset Change", m_respondToAssetChange);

            if (bRespondAP != m_respondToAssetChange)
            {
                using (new RecordUndoScope("Remove Target Load Path Settings", node, true)) {
                    m_respondToAssetChange = bRespondAP;
                }
            }

            GUILayout.Space(4f);

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

                using (disabledScope) {
                    var path = m_loadPath[editor.CurrentEditingGroup];
                    EditorGUILayout.LabelField("Load Path:");

                    string newLoadPath = null;

                    newLoadPath = editor.DrawFolderSelector(Model.Settings.Path.ASSETS_PATH, "Select Asset Folder",
                                                            path,
                                                            FileUtility.PathCombine(Model.Settings.Path.ASSETS_PATH, path),
                                                            (string folderSelected) => { return(NormalizeLoadPath(folderSelected)); }
                                                            );

                    var dirPath = Path.Combine(Model.Settings.Path.ASSETS_PATH, newLoadPath);

                    if (newLoadPath != path)
                    {
                        using (new RecordUndoScope("Load Path Changed", node, true)){
                            m_loadPath[editor.CurrentEditingGroup]      = newLoadPath;
                            m_loadPathGuid [editor.CurrentEditingGroup] = AssetDatabase.AssetPathToGUID(dirPath);
                            onValueChanged();
                        }
                    }

                    bool dirExists = Directory.Exists(dirPath);

                    GUILayout.Space(10f);

                    using (new EditorGUILayout.HorizontalScope()) {
                        using (new EditorGUI.DisabledScope(string.IsNullOrEmpty(newLoadPath) || !dirExists))
                        {
                            GUILayout.FlexibleSpace();
                            if (GUILayout.Button("Highlight in Project Window", GUILayout.Width(180f)))
                            {
                                // trailing is "/" not good for LoadMainAssetAtPath
                                if (dirPath[dirPath.Length - 1] == '/')
                                {
                                    dirPath = dirPath.Substring(0, dirPath.Length - 1);
                                }
                                var obj = AssetDatabase.LoadMainAssetAtPath(dirPath);
                                EditorGUIUtility.PingObject(obj);
                            }
                        }
                    }

                    if (!dirExists)
                    {
                        var  parentDirPath   = Path.GetDirectoryName(dirPath);
                        bool parentDirExists = Directory.Exists(parentDirPath);
                        if (parentDirExists)
                        {
                            EditorGUILayout.LabelField("Available Directories:");
                            string[] dirs = Directory.GetDirectories(parentDirPath);
                            foreach (string s in dirs)
                            {
                                EditorGUILayout.LabelField(s);
                            }
                        }
                    }
                }
            }
        }
예제 #15
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager,
                                            NodeGUIEditor editor, Action onValueChanged)
        {
            if (m_groupingKeyword == null)
            {
                return;
            }

            EditorGUILayout.HelpBox("Group By File Path: Create group of assets from asset's file path.",
                                    MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(10f);
            var newSlash = EditorGUILayout.ToggleLeft("Allow directory separator ('/') in group name", m_allowSlash);

            if (newSlash != m_allowSlash)
            {
                using (new RecordUndoScope("Change Allow Slash Setting", node, true))
                {
                    m_allowSlash = newSlash;
                    onValueChanged();
                }
            }

            if (m_allowSlash)
            {
                EditorGUILayout.HelpBox(
                    "Allowing directory separator for group name may create incompatible group name with other nodes. Please use this option carefully.",
                    MessageType.Info);
            }

            GUILayout.Space(4f);

            //Show target configuration tab
            editor.DrawPlatformSelector(node);
            using (new EditorGUILayout.VerticalScope(GUI.skin.box))
            {
                var disabledScope = editor.DrawOverrideTargetToggle(node,
                                                                    m_groupingKeyword.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) =>
                {
                    using (new RecordUndoScope("Remove Target Grouping Keyword Settings", node, true))
                    {
                        if (enabled)
                        {
                            m_groupingKeyword[editor.CurrentEditingGroup] = m_groupingKeyword.DefaultValue;
                            m_patternType[editor.CurrentEditingGroup]     = m_patternType.DefaultValue;
                            m_groupNameFormat[editor.CurrentEditingGroup] = m_groupNameFormat.DefaultValue;
                        }
                        else
                        {
                            m_groupingKeyword.Remove(editor.CurrentEditingGroup);
                            m_patternType.Remove(editor.CurrentEditingGroup);
                            m_groupNameFormat.Remove(editor.CurrentEditingGroup);
                        }

                        onValueChanged();
                    }
                });

                using (disabledScope)
                {
                    var newType = (GroupingPatternType)EditorGUILayout.EnumPopup("Pattern Type",
                                                                                 (GroupingPatternType)m_patternType[editor.CurrentEditingGroup]);
                    if (newType != (GroupingPatternType)m_patternType[editor.CurrentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Grouping Pattern Type", node, true))
                        {
                            m_patternType[editor.CurrentEditingGroup] = (int)newType;
                            onValueChanged();
                        }
                    }

                    var newGroupingKeyword = EditorGUILayout.TextField("Grouping Keyword",
                                                                       m_groupingKeyword[editor.CurrentEditingGroup]);
                    string helpText = null;
                    switch ((GroupingPatternType)m_patternType[editor.CurrentEditingGroup])
                    {
                    case GroupingPatternType.WildCard:
                        helpText =
                            "Grouping Keyword requires \"*\" in itself. It assumes there is a pattern such as \"ID_0\" in incoming paths when configured as \"ID_*\" ";
                        break;

                    case GroupingPatternType.RegularExpression:
                        helpText =
                            "Grouping Keyword requires pattern definition with \"()\" in Regular Expression manner.";
                        break;
                    }

                    EditorGUILayout.HelpBox(helpText, MessageType.Info);

                    if (newGroupingKeyword != m_groupingKeyword[editor.CurrentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Grouping Keywords", node, true))
                        {
                            m_groupingKeyword[editor.CurrentEditingGroup] = newGroupingKeyword;
                            onValueChanged();
                        }
                    }

                    var newGroupNameFormat = EditorGUILayout.TextField("Group Name Format",
                                                                       m_groupNameFormat[editor.CurrentEditingGroup]);
                    EditorGUILayout.HelpBox(
                        "You can customize group name. You can use variable {OldGroup} for old group name and {NewGroup} for current matching name.",
                        MessageType.Info);

                    if (newGroupNameFormat != m_groupNameFormat[editor.CurrentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Group Name", node, true))
                        {
                            m_groupNameFormat[editor.CurrentEditingGroup] = newGroupNameFormat;
                            onValueChanged();
                        }
                    }
                }
            }
        }
예제 #16
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            EditorGUILayout.HelpBox("Extract Shared Assets: Extract shared assets between asset bundles and add bundle configurations.", MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(10f);

            var newValue = EditorGUILayout.TextField("Bundle Name Template", m_bundleNameTemplate);

            if (newValue != m_bundleNameTemplate)
            {
                using (new RecordUndoScope("Bundle Name Template Change", node, true)) {
                    m_bundleNameTemplate = newValue;
                    onValueChanged();
                }
            }

            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_groupExtractedAssets[editor.CurrentEditingGroup] = m_groupExtractedAssets.DefaultValue;
                            m_groupSizeByte[editor.CurrentEditingGroup]        = m_groupSizeByte.DefaultValue;
                            m_groupingType[editor.CurrentEditingGroup]         = m_groupingType.DefaultValue;
                        }
                        else
                        {
                            m_groupExtractedAssets.Remove(editor.CurrentEditingGroup);
                            m_groupSizeByte.Remove(editor.CurrentEditingGroup);
                            m_groupingType.Remove(editor.CurrentEditingGroup);
                        }
                        onValueChanged();
                    }
                });

                using (disabledScope) {
                    var useGroup = EditorGUILayout.ToggleLeft("Subgroup shared assets by size", m_groupExtractedAssets [editor.CurrentEditingGroup] != 0);
                    if (useGroup != (m_groupExtractedAssets [editor.CurrentEditingGroup] != 0))
                    {
                        using (new RecordUndoScope("Change Grouping Type", node, true)){
                            m_groupExtractedAssets[editor.CurrentEditingGroup] = (useGroup)? 1:0;
                            onValueChanged();
                        }
                    }

                    using (new EditorGUI.DisabledScope(!useGroup)) {
                        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();
                            }
                        }
                    }
                }
            }

            EditorGUILayout.HelpBox("Bundle Name Template replaces \'*\' with number.", MessageType.Info);
        }
예제 #17
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            if (m_exportPath == null)
            {
                return;
            }

            var currentEditingGroup = editor.CurrentEditingGroup;

            EditorGUILayout.HelpBox("Export To Directory: Export given files to output directory.", 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_exportPath.ContainsValueOf(currentEditingGroup), (bool enabled) => {
                    using (new RecordUndoScope("Remove Target Export Settings", node, true)){
                        if (enabled)
                        {
                            m_exportPath[currentEditingGroup]   = m_exportPath.DefaultValue;
                            m_exportOption[currentEditingGroup] = m_exportOption.DefaultValue;
                            m_flattenDir[currentEditingGroup]   = m_flattenDir.DefaultValue;
                        }
                        else
                        {
                            m_exportPath.Remove(currentEditingGroup);
                            m_exportOption.Remove(currentEditingGroup);
                            m_flattenDir.Remove(currentEditingGroup);
                        }
                        onValueChanged();
                    }
                });

                using (disabledScope) {
                    ExportOption opt       = (ExportOption)m_exportOption[currentEditingGroup];
                    var          newOption = (ExportOption)EditorGUILayout.EnumPopup("Export Option", opt);
                    if (newOption != opt)
                    {
                        using (new RecordUndoScope("Change Export Option", node, true)){
                            m_exportOption[currentEditingGroup] = (int)newOption;
                            onValueChanged();
                        }
                    }

                    EditorGUILayout.LabelField("Export Path:");

                    string newExportPath = null;

                    newExportPath = editor.DrawFolderSelector("", "Select Export Folder",
                                                              m_exportPath[currentEditingGroup],
                                                              GetExportPath(m_exportPath[currentEditingGroup]),
                                                              (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 (newExportPath != m_exportPath[currentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Export Path", node, true)){
                            m_exportPath[currentEditingGroup] = newExportPath;
                            onValueChanged();
                        }
                    }

                    int flat    = m_flattenDir[currentEditingGroup];
                    var newFlat = EditorGUILayout.ToggleLeft("Flatten Directory", flat == 1) ? 1:0;
                    if (newFlat != flat)
                    {
                        using (new RecordUndoScope("Change Flatten Directory", node, true)){
                            m_flattenDir[currentEditingGroup] = newFlat;
                            onValueChanged();
                        }
                    }

                    var exporterNodePath = GetExportPath(newExportPath);
                    if (ValidateExportPath(
                            newExportPath,
                            exporterNodePath,
                            () => {
                    },
                            () => {
                        using (new EditorGUILayout.HorizontalScope()) {
                            EditorGUILayout.LabelField(exporterNodePath + " does not exist.");
                            if (GUILayout.Button("Create directory"))
                            {
                                Directory.CreateDirectory(exporterNodePath);
                            }
                            onValueChanged();
                        }
                        EditorGUILayout.Space();

                        string parentDir = Path.GetDirectoryName(exporterNodePath);
                        if (Directory.Exists(parentDir))
                        {
                            EditorGUILayout.LabelField("Available Directories:");
                            string[] dirs = Directory.GetDirectories(parentDir);
                            foreach (string s in dirs)
                            {
                                EditorGUILayout.LabelField(s);
                            }
                        }
                    }
                            ))
                    {
                        GUILayout.Space(10f);

                        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(exporterNodePath);
                            }
                        }
                    }
                }
            }
        }
예제 #18
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            EditorGUILayout.HelpBox("Generate Asset: Generate new asset from incoming asset.", MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(8f);

            editor.DrawPlatformSelector(node);
            using (new EditorGUILayout.VerticalScope()) {
                var disabledScope = editor.DrawOverrideTargetToggle(node, m_outputOption.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => {
                    if (enabled)
                    {
                        m_outputOption[editor.CurrentEditingGroup] = m_outputOption.DefaultValue;
                        m_outputDir[editor.CurrentEditingGroup]    = m_outputDir.DefaultValue;
                    }
                    else
                    {
                        m_outputOption.Remove(editor.CurrentEditingGroup);
                        m_outputDir.Remove(editor.CurrentEditingGroup);
                    }
                    onValueChanged();
                });

                using (disabledScope) {
                    OutputOption opt       = (OutputOption)m_outputOption[editor.CurrentEditingGroup];
                    var          newOption = (OutputOption)EditorGUILayout.EnumPopup("Output Option", opt);
                    if (newOption != opt)
                    {
                        using (new RecordUndoScope("Change Output Option", node, true)){
                            m_outputOption[editor.CurrentEditingGroup] = (int)newOption;
                            onValueChanged();
                        }
                        opt = newOption;
                    }
                    if (opt != OutputOption.CreateInCacheDirectory)
                    {
                        EditorGUILayout.HelpBox("When you are not creating assets under cache directory, make sure your generators are not overwriting assets each other.", MessageType.Info);
                    }

                    using (new EditorGUI.DisabledScope(opt == OutputOption.CreateInCacheDirectory)) {
                        var newDirPath = m_outputDir[editor.CurrentEditingGroup];

                        if (opt == OutputOption.CreateInSelectedDirectory)
                        {
                            newDirPath = editor.DrawFolderSelector("Output Directory", "Select Output Folder",
                                                                   m_outputDir [editor.CurrentEditingGroup],
                                                                   Application.dataPath,
                                                                   (string folderSelected) => {
                                string basePath = Application.dataPath;

                                if (basePath == folderSelected)
                                {
                                    folderSelected = string.Empty;
                                }
                                else
                                {
                                    var index = folderSelected.IndexOf(basePath);
                                    if (index >= 0)
                                    {
                                        folderSelected = folderSelected.Substring(basePath.Length + index);
                                        if (folderSelected.IndexOf('/') == 0)
                                        {
                                            folderSelected = folderSelected.Substring(1);
                                        }
                                    }
                                }
                                return(folderSelected);
                            }
                                                                   );
                        }
                        else if (opt == OutputOption.RelativeToSourceAsset)
                        {
                            newDirPath = EditorGUILayout.TextField("Relative Path", m_outputDir[editor.CurrentEditingGroup]);
                        }

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

                        var dirPath = Path.Combine(Application.dataPath, m_outputDir [editor.CurrentEditingGroup]);

                        if (opt == OutputOption.CreateInSelectedDirectory &&
                            !string.IsNullOrEmpty(m_outputDir [editor.CurrentEditingGroup]) &&
                            !Directory.Exists(dirPath))
                        {
                            using (new EditorGUILayout.HorizontalScope()) {
                                EditorGUILayout.LabelField(m_outputDir[editor.CurrentEditingGroup] + " does not exist.");
                                if (GUILayout.Button("Create directory"))
                                {
                                    Directory.CreateDirectory(dirPath);
                                    AssetDatabase.Refresh();
                                }
                            }
                            EditorGUILayout.Space();

                            string parentDir = Path.GetDirectoryName(m_outputDir[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();
                        }

                        if (opt == OutputOption.CreateInSelectedDirectory || opt == OutputOption.CreateInCacheDirectory)
                        {
                            var outputDir = PrepareOutputDirectory(BuildTargetUtility.GroupToTarget(editor.CurrentEditingGroup), node.Data, null);

                            using (new EditorGUI.DisabledScope(!Directory.Exists(outputDir)))
                            {
                                using (new EditorGUILayout.HorizontalScope()) {
                                    GUILayout.FlexibleSpace();
                                    if (GUILayout.Button("Highlight in Project Window", GUILayout.Width(180f)))
                                    {
                                        var folder = AssetDatabase.LoadMainAssetAtPath(outputDir);
                                        EditorGUIUtility.PingObject(folder);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            GUILayout.Space(8f);

            foreach (var s in m_entries)
            {
                DrawGeneratorSetting(s, node, streamManager, editor, onValueChanged);
                GUILayout.Space(10f);
            }

            if (m_removingEntry != null)
            {
                using (new RecordUndoScope("Remove Generator", node)) {
                    RemoveGeneratorEntry(node, m_removingEntry);
                    m_removingEntry = null;
                    onValueChanged();
                }
            }

            GUILayout.Space(8);

            if (GUILayout.Button("Add Generator"))
            {
                using (new RecordUndoScope("Add Generator", node)) {
                    AddEntry(node);
                    onValueChanged();
                }
            }
        }
예제 #19
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager,
                                            NodeGUIEditor editor, Action onValueChanged)
        {
            EditorGUILayout.HelpBox("Build Addressable Assets: Build Addressable Assets.",
                                    MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(4f);

            EditorGUILayout.HelpBox("Build Addressable Assets does not respect Platform selection in Graph Editor." +
                                    "Instead, Addressable Profile will be used for platform targeting.",
                                    MessageType.Info);

            if (!AddressableAssetSettingsDefaultObject.SettingsExists)
            {
                return;
            }

            var profileNames = Settings.profileSettings.GetAllProfileNames();

            profileNames.Insert(0, kCurrentProfile);
            var profileIndex    = string.IsNullOrEmpty(m_profileName) ? 0 : profileNames.IndexOf(m_profileName);
            var newProfileIndex = EditorGUILayout.Popup("Profile", profileIndex, profileNames.ToArray());

            if (newProfileIndex != profileIndex)
            {
                using (new RecordUndoScope("Change Profile", node, true))
                {
                    m_profileName = profileNames[newProfileIndex];
                    onValueChanged();
                }
            }

            if (m_currentDataBuilder == null && !string.IsNullOrEmpty(m_builderGuid))
            {
                m_currentDataBuilder = Settings.DataBuilders.FirstOrDefault(obj =>
                                                                            AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(obj)) == m_builderGuid);
            }

            var dataBuilders = Settings.DataBuilders.Where(builder => (builder as IDataBuilder).CanBuildData <AddressablesPlayerBuildResult>()).ToList();

            var builderIndex = m_currentDataBuilder == null ? -1 : dataBuilders.IndexOf(m_currentDataBuilder);
            var builderNames = dataBuilders
                               .Select(builder => ((IDataBuilder)builder).Name).ToArray();

            var newIndex = EditorGUILayout.Popup("Builder Script", builderIndex, builderNames);

            if (newIndex != builderIndex)
            {
                using (new RecordUndoScope("Change Builder", node, true))
                {
                    m_currentDataBuilder = dataBuilders[newIndex];
                    m_builderGuid        =
                        AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_currentDataBuilder));
                    onValueChanged();
                }
            }

            var newPreferUpdate = EditorGUILayout.ToggleLeft("Update", m_preferUpdate);

            if (newPreferUpdate != m_preferUpdate)
            {
                using (new RecordUndoScope("Update Toggle", node, true))
                {
                    m_preferUpdate = newPreferUpdate;
                    onValueChanged();
                }
            }

            using (new EditorGUI.DisabledScope(!m_preferUpdate))
            {
                GUILayout.Label("Content State File", "BoldLabel");
                using (new EditorGUILayout.HorizontalScope()) {
                    EditorGUILayout.SelectableLabel(m_contentStateFilePath, EditorStyles.textField,
                                                    GUILayout.Height(EditorGUIUtility.singleLineHeight));
                    if (GUILayout.Button("Select", GUILayout.Width(50f)))
                    {
                        var newStateData = ContentUpdateScript.GetContentStateDataPath(true);
                        if (newStateData != null && newStateData != m_contentStateFilePath)
                        {
                            using (new RecordUndoScope("Content State Data Path", node, true))
                            {
                                m_contentStateFilePath = newStateData;
                                onValueChanged();
                            }
                        }
                    }
                }
            }

            GUILayout.Space(10f);

            if (GUILayout.Button("Clean Build Cache", GUILayout.Width(250f)))
            {
                if (EditorUtility.DisplayDialog("Clean Build Cache",
                                                "Do you really want to clean build cache?",
                                                "OK", "Cancel"))
                {
                    AddressableAssetSettings.CleanPlayerContent(null);
                    BuildCache.PurgeCache(false);
                }
            }
        }