void OnGUIRule(ABPackRuleConfig.Rule rule, bool selected) { ABPackRuleConfig config = AutoABNamePostprocessor.config; EditorGUILayout.BeginVertical(selected ? GUI.skin.button : GUI.skin.box); EditorGUILayout.BeginHorizontal(); rule.path = EditorGUILayout.TextField("Path: ", rule.path); if (Event.current.type == EventType.DragUpdated && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) { if (DragAndDrop.objectReferences[0] is DefaultAsset) { DragAndDrop.visualMode = DragAndDropVisualMode.Move; DragAndDrop.AcceptDrag(); Event.current.Use(); } } else if (Event.current.type == EventType.DragPerform && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) { rule.path = GetAssetPath(DragAndDrop.paths[0]); Event.current.Use(); EditorUtility.SetDirty(config); } if (GUILayout.Button("Select", GUILayout.Width(100))) { string result = EditorUtility.OpenFolderPanel("", "选择目录", ""); if (result != null) { rule.path = GetAssetPath(result); GUI.FocusControl(null); EditorUtility.SetDirty(config); } } EditorGUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(rule.path)) { rule.typeFilter = EditorGUILayout.TextField("TypeFilter: ", rule.typeFilter); if (Event.current.type == EventType.DragUpdated && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) { DragAndDrop.visualMode = DragAndDropVisualMode.Move; DragAndDrop.AcceptDrag(); Event.current.Use(); } else if (Event.current.type == EventType.DragPerform && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) { rule.typeFilter = string.Join(",", DragAndDrop.objectReferences.Select(x => x.GetType().Name).Distinct().ToArray()); Event.current.Use(); EditorUtility.SetDirty(config); } rule.ruleType = EditorGUILayout.Popup("Rule: ", rule.ruleType, AutoABNamePostprocessor.packRuleNames.ToArray()); } EditorGUILayout.EndVertical(); }
private void OnGUIRule(Rule rule, bool isSelect) { GUILayout.BeginVertical(GUI.skin.box); { GUILayout.BeginHorizontal(); { rule.path = EditorGUILayout.TextField("Path ", rule.path, TableStyles.TextField); if (GUILayout.Button("Select", TableStyles.ToolbarButton, GUILayout.MaxWidth(160))) { string result = EditorUtility.OpenFolderPanel("", "选择目录", ""); if (result != null) { string path = GetAssetPath(result); if (AssertPath(path)) { GUI.FocusControl(null); rule.path = path; EditorUtility.SetDirty(config); } else { m_hostWin.ShowNotification(new GUIContent("rule选择错误")); } } } if (GUILayout.Button("Remove", TableStyles.ToolbarButton, GUILayout.MaxWidth(120))) { config.rules.Remove(rule); EditorUtility.SetDirty(config); } } GUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(rule.path)) { rule.typeFilter = EditorGUILayout.TextField("TypeFilter: ", rule.typeFilter, TableStyles.TextField); if (Event.current.type == EventType.DragUpdated && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) { DragAndDrop.visualMode = DragAndDropVisualMode.Move; DragAndDrop.AcceptDrag(); Event.current.Use(); } else if (Event.current.type == EventType.DragPerform && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) { rule.typeFilter = string.Join(",", DragAndDrop.objectReferences.Select(x => x.GetType().Name).Distinct().ToArray()); Event.current.Use(); EditorUtility.SetDirty(config); } rule.ruleType = EditorGUILayout.Popup("Rule: ", rule.ruleType, AutoABNamePostprocessor.packRuleNames.ToArray()); } } GUILayout.EndVertical(); }