Skip to content

Commit 9f8c441

Browse files
authored
Merge pull request #1 from yunnsbz/feature-options
Feature options
2 parents b61d047 + 8e7927a commit 9f8c441

File tree

11 files changed

+962
-535
lines changed

11 files changed

+962
-535
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using UnityEditor;
5+
using UnityEngine;
6+
7+
namespace ScriptableObjectManager
8+
{
9+
10+
// Custom Popup Window for Config Type Selection
11+
internal class ConfigTypeSelectionPopup : PopupWindowContent
12+
{
13+
private readonly List<Type> SelectedTypes;
14+
private readonly List<Type> AvailableTypes;
15+
private readonly Action OnSelectionChanged;
16+
private Vector2 ScrollPos = new();
17+
18+
public ConfigTypeSelectionPopup(List<Type> selectedTypes, Action onSelectionChanged, List<Type> availableTypes)
19+
{
20+
this.SelectedTypes = selectedTypes;
21+
this.OnSelectionChanged = onSelectionChanged;
22+
this.AvailableTypes = availableTypes;
23+
}
24+
25+
public override Vector2 GetWindowSize()
26+
{
27+
return new Vector2(200, 400); // Define the dimensions of the popup window
28+
}
29+
30+
public override void OnGUI(Rect rect)
31+
{
32+
GUILayout.Label("Select Config Types", EditorStyles.boldLabel);
33+
34+
if (AvailableTypes.Count > 0)
35+
{
36+
ScrollPos = EditorGUILayout.BeginScrollView(ScrollPos);
37+
38+
// Display each available type with a toggle to enable or disable it
39+
foreach (var type in AvailableTypes)
40+
{
41+
bool isSelected = SelectedTypes.Contains(type);
42+
bool toggle = EditorGUILayout.Toggle(type.Name, isSelected);
43+
44+
if (toggle && !isSelected)
45+
{
46+
SelectedTypes.Add(type); // Add the type to the selection list
47+
OnSelectionChanged.Invoke();
48+
ScriptableObjectEditorWindow.BasicFilters = SelectedTypes.Select(t => t.Name).ToArray();
49+
}
50+
else if (!toggle && isSelected)
51+
{
52+
SelectedTypes.Remove(type); // Remove the type from the selection list
53+
OnSelectionChanged.Invoke();
54+
ScriptableObjectEditorWindow.BasicFilters = SelectedTypes.Select(t => t.Name).ToArray();
55+
}
56+
}
57+
// Close the scrollable area within the popup
58+
EditorGUILayout.EndScrollView();
59+
}
60+
}
61+
}
62+
63+
}

Assets/Editor/Editor Windows/ConfigTypeSelectionPopup.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
273 Bytes
Loading

Assets/Editor/Editor Windows/Icons/check.png.meta

Lines changed: 127 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
173 Bytes
Loading

Assets/Editor/Editor Windows/Icons/options.png.meta

Lines changed: 127 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)