com.wallstop-studios.unity-helpers 2.0.0-rc18 → 2.0.0-rc20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ namespace UnityHelpers.Editor
2
+ {
3
+ #if UNITY_EDITOR
4
+ using System;
5
+ using UnityEditor;
6
+ using UnityEngine;
7
+ using UnityHelpers.Core.Helper;
8
+
9
+ [CustomPropertyDrawer(typeof(StringInList))]
10
+ public class StringInListDrawer : PropertyDrawer
11
+ {
12
+ // Draw the property inside the given rect
13
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
14
+ {
15
+ if (attribute is not StringInList stringInList)
16
+ {
17
+ return;
18
+ }
19
+
20
+ string[] list = stringInList.List;
21
+
22
+ switch (property.propertyType)
23
+ {
24
+ case SerializedPropertyType.String:
25
+ {
26
+ int index = Mathf.Max(0, Array.IndexOf(list, property.stringValue));
27
+ index = EditorGUI.Popup(position, property.displayName, index, list);
28
+ if (index < 0 || list.Length <= index)
29
+ {
30
+ base.OnGUI(position, property, label);
31
+ return;
32
+ }
33
+
34
+ property.stringValue = list[index];
35
+ break;
36
+ }
37
+ case SerializedPropertyType.Integer:
38
+ {
39
+ property.intValue = EditorGUI.Popup(
40
+ position,
41
+ property.displayName,
42
+ property.intValue,
43
+ list
44
+ );
45
+ break;
46
+ }
47
+ default:
48
+ {
49
+ base.OnGUI(position, property, label);
50
+ break;
51
+ }
52
+ }
53
+ }
54
+ }
55
+ #endif
56
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 32e167906e4845f4b2aebb7ca3494aea
3
+ timeCreated: 1738520991
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc18",
3
+ "version": "2.0.0-rc20",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},