1.8.1: Fixed issue with certain drawers using EditorGUI.PropertyField, which would invoke a second draw with the same attribute

This commit is contained in:
Anders Ejlersen 2023-04-21 18:44:44 +02:00
parent eb19150d98
commit b189ec8b97
8 changed files with 21 additions and 14 deletions

View file

@ -20,8 +20,10 @@ namespace Module.Inspector.Editor
var rect0 = new Rect(position.x, position.y, position.width - WIDTH, position.height); var rect0 = new Rect(position.x, position.y, position.width - WIDTH, position.height);
var rect1 = new Rect(rect0.xMax, position.y, WIDTH, position.height); var rect1 = new Rect(rect0.xMax, position.y, WIDTH, position.height);
string temp = EditorGUI.TextField(rect0, label, property.stringValue);
EditorGUI.PropertyField(rect0, property, label); if (!temp.Equals(property.stringValue))
property.stringValue = temp;
if (GUI.Button(rect1, "Find")) if (GUI.Button(rect1, "Find"))
{ {

View file

@ -20,8 +20,10 @@ namespace Module.Inspector.Editor
var rect0 = new Rect(position.x, position.y, position.width - WIDTH, position.height); var rect0 = new Rect(position.x, position.y, position.width - WIDTH, position.height);
var rect1 = new Rect(rect0.xMax, position.y, WIDTH, position.height); var rect1 = new Rect(rect0.xMax, position.y, WIDTH, position.height);
string temp = EditorGUI.TextField(rect0, label, property.stringValue);
EditorGUI.PropertyField(rect0, property, label); if (!temp.Equals(property.stringValue))
property.stringValue = temp;
if (GUI.Button(rect1, "Find")) if (GUI.Button(rect1, "Find"))
{ {

View file

@ -20,8 +20,10 @@ namespace Module.Inspector.Editor
var rect0 = new Rect(position.x, position.y, position.width - WIDTH, position.height); var rect0 = new Rect(position.x, position.y, position.width - WIDTH, position.height);
var rect1 = new Rect(rect0.xMax, position.y, WIDTH, position.height); var rect1 = new Rect(rect0.xMax, position.y, WIDTH, position.height);
string temp = EditorGUI.TextField(rect0, label, property.stringValue);
EditorGUI.PropertyField(rect0, property, label); if (!temp.Equals(property.stringValue))
property.stringValue = temp;
if (GUI.Button(rect1, "Find")) if (GUI.Button(rect1, "Find"))
EditorWindowStringToField.Open(att.type, property); EditorWindowStringToField.Open(att.type, property);

View file

@ -20,12 +20,13 @@ namespace Module.Inspector.Editor
var rect0 = new Rect(position.x, position.y, position.width - WIDTH, position.height); var rect0 = new Rect(position.x, position.y, position.width - WIDTH, position.height);
var rect1 = new Rect(rect0.xMax, position.y, WIDTH, position.height); var rect1 = new Rect(rect0.xMax, position.y, WIDTH, position.height);
string temp = EditorGUI.TextField(rect0, label, property.stringValue);
EditorGUI.PropertyField(rect0, property, label); if (!temp.Equals(property.stringValue))
property.stringValue = temp;
if (GUI.Button(rect1, "Find")) if (GUI.Button(rect1, "Find"))
EditorWindowStringToType.Open(att.assignableFrom, property); EditorWindowStringToType.Open(att.assignableFrom, property);
} }
EditorGUI.EndProperty(); EditorGUI.EndProperty();
return true; return true;

View file

@ -526,7 +526,7 @@ namespace Module.Inspector.Editor
case SerializedPropertyType.BoundsInt: case SerializedPropertyType.BoundsInt:
return property.boundsIntValue.ToString(); return property.boundsIntValue.ToString();
case SerializedPropertyType.ManagedReference: case SerializedPropertyType.ManagedReference:
return property.objectReferenceValue != null ? property.objectReferenceValue.ToString() : "null"; return property.managedReferenceValue != null ? property.managedReferenceValue.ToString() : "null";
} }
return "Unable to draw value as string"; return "Unable to draw value as string";

View file

@ -1,6 +1,6 @@
{ {
"name": "com.module.inspector", "name": "com.module.inspector",
"version": "1.8.0", "version": "1.8.1",
"displayName": "Module.Inspector", "displayName": "Module.Inspector",
"description": "Custom inspector with various useful property drawers", "description": "Custom inspector with various useful property drawers",
"unity": "2019.2", "unity": "2019.2",