示例#1
0
 internal FileNameCkeckerSetting(FileNameCkeckerSetting copy)
 {
     DirectoryName = copy.DirectoryName;
     DirectoryType = copy.DirectoryType;
     RegexPattern  = copy.RegexPattern;
     FileType      = copy.FileType;
     IsActive      = copy.IsActive;
 }
        private void FileNameCheckerDrawer(FileNameCkeckerSetting setting)
        {
            var rect = EditorGUILayout.BeginVertical(GUIHelper.Styles.NoSpaceBox);

            {
                GUI.backgroundColor = setting.IsActive ? Color.green : Color.grey;
                if (GUILayout.Button("", EditorStyles.toolbarButton, GUILayout.ExpandWidth(true)))
                {
                    UndoHelper.BuilderDataUndo("Change FileNameChecker activation");
                    setting.IsActive = !setting.IsActive;
                    EditorGUIUtility.keyboardControl = 0;
                }
                GUI.backgroundColor = Color.white;

                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Directory", GUILayout.Width(70));
                    EditorGUILayout.TextField(setting.DirectoryName);
                    var path = FileHelper.GetDraggedObject(Event.current, GUILayoutUtility.GetLastRect());
                    if (!string.IsNullOrEmpty(path))
                    {
                        UndoHelper.BuilderDataUndo("Change FileNameChecker Setting");
                        setting.DirectoryName = FileHelper.AssetPathToBuildPath(BuildRootPath, path);
                    }
                }
                EditorGUILayout.EndHorizontal();

                if (setting.IsActive)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        Undo.IncrementCurrentGroup();
                        UndoHelper.BuilderDataUndo("Change FileNameChecker type");
                        GUILayout.Label("Directory type", GUILayout.Width(70));
                        setting.DirectoryType = ( DirectoryLabelNameType )EditorGUILayout.EnumPopup(setting.DirectoryType);
                    }
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Space(5);

                    EditorGUILayout.BeginHorizontal();
                    {
                        Undo.IncrementCurrentGroup();
                        UndoHelper.BuilderDataUndo("Change FileNameChecker regex");
                        GUILayout.Label("Regex", GUILayout.Width(70));
                        setting.RegexPattern = EditorGUILayout.TextField(setting.RegexPattern);
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    {
                        Undo.IncrementCurrentGroup();
                        UndoHelper.BuilderDataUndo("Change FileNameChecker filetype");
                        GUILayout.Label("File Type", GUILayout.Width(70));
                        setting.FileType = ( LabelCheckerFileType )EditorGUILayout.EnumPopup(setting.FileType);
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    {
                        Undo.IncrementCurrentGroup();
                        UndoHelper.BuilderDataUndo("Change FileNameChecker checkerType");
                        GUILayout.Label("Checker Type", GUILayout.Width(70));
                        setting.CheckerType = ( LabelCheckerType )EditorGUILayout.EnumPopup(setting.CheckerType);
                    }
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Space(5);
                }
            }
            EditorGUILayout.EndVertical();

            GUILayout.Space(3);

            if (IsContextClick(Event.current, rect))
            {
                var menu = new GenericMenu();
                menu.AddItem(new GUIContent("Delete"), false, () => {
                    UndoHelper.BuilderDataUndo("Delete FileNameChecker Setting");
                    FileNameChecker.Remove(setting);
                });
                menu.ShowAsContext();
            }
        }