1.8.2: Fixed a couple of more issues with certain using EditorGUI.PropertyField, and removed label element from SerializeReferenceTo when used in an array
This commit is contained in:
parent
b189ec8b97
commit
61c7356b3a
|
|
@ -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, "Go"))
|
if (GUI.Button(rect1, "Go"))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Module.Inspector.Editor
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Note: Why not use EditorGUI.PropertyField?
|
// Note: Why not use EditorGUI.PropertyField?
|
||||||
// The reason is that the foldout uses Toggle and ObjectField and if if we don't use
|
// The reason is that the foldout uses Toggle and ObjectField and if we don't use
|
||||||
// Label and ObjectField here, then ObjectField will be given a new control id when changing
|
// Label and ObjectField here, then ObjectField will be given a new control id when changing
|
||||||
// objectReferenceValue from an existing object to null and back again. The new object will
|
// objectReferenceValue from an existing object to null and back again. The new object will
|
||||||
// not be set, due to null giving a new control id.
|
// not be set, due to null giving a new control id.
|
||||||
|
|
@ -102,7 +102,6 @@ namespace Module.Inspector.Editor
|
||||||
|
|
||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|
||||||
{
|
{
|
||||||
bool prevEnabled = GUI.enabled;
|
bool prevEnabled = GUI.enabled;
|
||||||
GUI.enabled = prevEnabled && editable;
|
GUI.enabled = prevEnabled && editable;
|
||||||
|
|
@ -116,7 +115,6 @@ namespace Module.Inspector.Editor
|
||||||
|
|
||||||
GUI.enabled = prevEnabled;
|
GUI.enabled = prevEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasChanged = EditorGUI.EndChangeCheck();
|
bool hasChanged = EditorGUI.EndChangeCheck();
|
||||||
EditorGUI.indentLevel--;
|
EditorGUI.indentLevel--;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,11 @@ namespace Module.Inspector.Editor
|
||||||
height = EditorGUIUtility.singleLineHeight
|
height = EditorGUIUtility.singleLineHeight
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SerializedProperty parent = property.GetParent();
|
||||||
|
GUIContent labelContent = parent != null && parent.isArray ? GUIContent.none : label;
|
||||||
|
|
||||||
int index = Array.IndexOf(arrStrings, ConvertUnityTypeFullnameToCSharpName(property.managedReferenceFullTypename));
|
int index = Array.IndexOf(arrStrings, ConvertUnityTypeFullnameToCSharpName(property.managedReferenceFullTypename));
|
||||||
int newIndex = EditorGUI.Popup(rect, label, index, arrGui);
|
int newIndex = EditorGUI.Popup(rect, labelContent, index, arrGui);
|
||||||
|
|
||||||
if (newIndex != -1 && index != newIndex)
|
if (newIndex != -1 && index != newIndex)
|
||||||
{
|
{
|
||||||
|
|
@ -53,7 +56,7 @@ namespace Module.Inspector.Editor
|
||||||
EditorUtility.DisplayDialog("Error", "Failed to set managed reference to selected type.\n\nType must be:\nSerializable\nNot abstract\nNon-generic\nNot a specialization of UnityEngine.Object", "Ok");
|
EditorUtility.DisplayDialog("Error", "Failed to set managed reference to selected type.\n\nType must be:\nSerializable\nNot abstract\nNon-generic\nNot a specialization of UnityEngine.Object", "Ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorGUI.PropertyField(position, property, true);
|
EditorGUI.PropertyField(position, property, GUIContent.none, true);
|
||||||
}
|
}
|
||||||
EditorGUI.EndProperty();
|
EditorGUI.EndProperty();
|
||||||
bool hasChanged = EditorGUI.EndChangeCheck();
|
bool hasChanged = EditorGUI.EndChangeCheck();
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,10 @@ namespace Module.Inspector.Editor
|
||||||
|
|
||||||
var r0 = new Rect(position.x, position.y, position.width - WIDTH, position.height);
|
var r0 = new Rect(position.x, position.y, position.width - WIDTH, position.height);
|
||||||
var r1 = new Rect(r0.xMax, r0.y, WIDTH, r0.height);
|
var r1 = new Rect(r0.xMax, r0.y, WIDTH, r0.height);
|
||||||
|
string temp = EditorGUI.TextField(r0, label, property.stringValue);
|
||||||
|
|
||||||
EditorGUI.PropertyField(r0, property, label);
|
if (!temp.Equals(property.stringValue))
|
||||||
|
property.stringValue = temp;
|
||||||
|
|
||||||
if (GUI.Button(r1, "Go"))
|
if (GUI.Button(r1, "Go"))
|
||||||
Application.OpenURL(property.stringValue);
|
Application.OpenURL(property.stringValue);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "com.module.inspector",
|
"name": "com.module.inspector",
|
||||||
"version": "1.8.1",
|
"version": "1.8.2",
|
||||||
"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",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue