1.3.1: Fixed type name issue in SerializeReferenceTo, due to Unity using their own type naming scheme
This commit is contained in:
parent
e1d0e0e90b
commit
ec2afb78db
|
|
@ -39,13 +39,14 @@ namespace Module.Inspector.Editor
|
|||
height = EditorGUIUtility.singleLineHeight
|
||||
};
|
||||
|
||||
int index = Array.IndexOf(arrStrings, ConvertUnityToCSharp(property.managedReferenceFullTypename));
|
||||
int index = Array.IndexOf(arrStrings, ConvertUnityTypeFullnameToCSharpName(property.managedReferenceFullTypename));
|
||||
int newIndex = EditorGUI.Popup(rect, label, index, arrGui);
|
||||
|
||||
if (newIndex != -1 && index != newIndex)
|
||||
{
|
||||
Type newType = EditorTypeUtility.GetType(arrStrings[newIndex]);
|
||||
|
||||
|
||||
if (newType != null && IsSupported(newType))
|
||||
property.managedReferenceValue = FormatterServices.GetUninitializedObject(newType);
|
||||
else
|
||||
|
|
@ -118,15 +119,36 @@ namespace Module.Inspector.Editor
|
|||
return true;
|
||||
}
|
||||
|
||||
private static string ConvertUnityToCSharp(string unityNaming)
|
||||
private static string ConvertUnityTypeFullnameToCSharpFullname(string unityNaming)
|
||||
{
|
||||
if (string.IsNullOrEmpty(unityNaming))
|
||||
return string.Empty;
|
||||
|
||||
int index = unityNaming.LastIndexOf(' ');
|
||||
string str;
|
||||
|
||||
if (index != -1)
|
||||
unityNaming = unityNaming.Substring(index);
|
||||
{
|
||||
str = unityNaming.Substring(0, index).Trim();
|
||||
str += ", ";
|
||||
str += unityNaming.Substring(index).Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
str = unityNaming;
|
||||
}
|
||||
|
||||
unityNaming = unityNaming.Replace('/', '+');
|
||||
return unityNaming.Trim();
|
||||
return str.Replace('/', '+');
|
||||
}
|
||||
|
||||
private static string ConvertUnityTypeFullnameToCSharpName(string unityNaming)
|
||||
{
|
||||
if (string.IsNullOrEmpty(unityNaming))
|
||||
return string.Empty;
|
||||
|
||||
int index = unityNaming.LastIndexOf(' ');
|
||||
string str = index != -1 ? unityNaming.Substring(index).Trim() : unityNaming;
|
||||
return str.Replace('/', '+');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.module.inspector",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"displayName": "Module.Inspector",
|
||||
"description": "Custom inspector with various useful property drawers",
|
||||
"unity": "2019.2",
|
||||
|
|
|
|||
Loading…
Reference in a new issue