Skip to content

Commit

Permalink
Merge branch 'wip' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerTemp committed Dec 26, 2024
2 parents d136435 + c1bd829 commit cd69617
Show file tree
Hide file tree
Showing 50 changed files with 2,020 additions and 994 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 3.12.0 ##

1. Add `SaintsEditorWindow` to easily make an `EditorWindow`.
2. IMGUI: Fix `OnValueChanged` didn't work with `Dropdown` and `AdvancedDropdown`

## 3.11.0 ##

1. Add `FlagsDropdown` to toggle flags with search support, [#96](https://github.com/TylerTemp/SaintsField/issues/96)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,20 @@ protected override float GetFieldHeight(SerializedProperty property, GUIContent
return EditorGUIUtility.singleLineHeight;
}

private static string GetKey(SerializedProperty property) => $"{property.serializedObject.targetObject.GetInstanceID()}_{property.propertyPath}";

private static readonly Dictionary<string, object> AsyncChangedCache = new Dictionary<string, object>();

protected override void DrawField(Rect position, SerializedProperty property, GUIContent label,
ISaintsAttribute saintsAttribute, OnGUIPayload onGUIPayload, FieldInfo info, object parent)
{
string key = GetKey(property);
if (AsyncChangedCache.TryGetValue(key, out object changedValue))
{
onGUIPayload.SetValue(changedValue);
AsyncChangedCache.Remove(key);
}

AdvancedDropdownAttribute advancedDropdownAttribute = (AdvancedDropdownAttribute)saintsAttribute;
AdvancedDropdownMetaInfo metaInfo = GetMetaInfo(property, advancedDropdownAttribute, info, parent);
_error = metaInfo.Error;
Expand Down Expand Up @@ -73,6 +84,8 @@ protected override void DrawField(Rect position, SerializedProperty property, GU
}

// Vector2 size = new Vector2(position.width, maxChildCount * EditorGUIUtility.singleLineHeight + 31f);

// OnGUIPayload targetPayload = onGUIPayload;
SaintsAdvancedDropdownIMGUI dropdown = new SaintsAdvancedDropdownIMGUI(
metaInfo.DropdownListValue,
size,
Expand All @@ -83,11 +96,12 @@ protected override void DrawField(Rect position, SerializedProperty property, GU
ReflectUtils.SetValue(property.propertyPath, property.serializedObject.targetObject, info, parent, curItem);
Util.SignPropertyValue(property, info, parent, curItem);
property.serializedObject.ApplyModifiedProperties();
onGUIPayload.SetValue(curItem);
if(ExpandableIMGUIScoop.IsInScoop)
{
property.serializedObject.ApplyModifiedProperties();
}
AsyncChangedCache[key] = curItem;
// Debug.Log($"Advanced Changed: {AsyncChangedCache[key].changed}/{AsyncChangedCache[key].GetHashCode()}");
// if(ExpandableIMGUIScoop.IsInScoop)
// {
// property.serializedObject.ApplyModifiedProperties();
// }
},
GetIcon);
dropdown.Show(position);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,17 @@ protected override void OnAwakeUIToolkit(SerializedProperty property, ISaintsAtt
// Debug.Log(root.worldBound);
// Debug.Log(Screen.height);
// float maxHeight = Mathf.Max(400, Screen.height - root.worldBound.y - root.worldBound.height - 200);
float maxHeight = Screen.height - root.worldBound.y - root.worldBound.height - 100;

// float maxHeight = Screen.height - root.worldBound.y - root.worldBound.height - 100;
float maxHeight = Screen.currentResolution.height - root.worldBound.y - root.worldBound.height - 100;
Rect worldBound = root.worldBound;
// Debug.Log(worldBound);
if (maxHeight < 100)
{
// worldBound.x -= 400;
worldBound.y -= 300 + worldBound.height;
worldBound.y -= 100 + worldBound.height;
// Debug.Log(worldBound);
maxHeight = 300;
maxHeight = 100;
}

UnityEditor.PopupWindow.Show(worldBound, new SaintsAdvancedDropdownUIToolkit(
Expand Down
Loading

0 comments on commit cd69617

Please sign in to comment.