mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
[unity] Fix FindBaseOrSiblingProperty.
This commit is contained in:
parent
17ce8d5bcf
commit
9bf12a4299
@ -92,26 +92,30 @@ namespace Spine.Unity.Editor {
|
||||
// If base property is not found, look for the sibling property.
|
||||
if (relativeProperty == null) {
|
||||
string propertyPath = property.propertyPath;
|
||||
int localPathLength = 0;
|
||||
int localPathLength = property.name.Length;
|
||||
|
||||
if (property.isArray) {
|
||||
const int internalArrayPathLength = 14; // int arrayPathLength = ".Array.data[x]".Length;
|
||||
string newPropertyPath = propertyPath.Remove(propertyPath.Length - localPathLength, localPathLength) + propertyName;
|
||||
relativeProperty = property.serializedObject.FindProperty(newPropertyPath);
|
||||
|
||||
// If a direct sibling property was not found, try to find the sibling of the array.
|
||||
if (relativeProperty == null && property.isArray) {
|
||||
int propertyPathLength = propertyPath.Length;
|
||||
int n = propertyPathLength - internalArrayPathLength;
|
||||
// Find the dot before the array property name and
|
||||
// store the total length from the name of the array until the end of the propertyPath.
|
||||
for (int i = internalArrayPathLength + 1; i < n; i++) {
|
||||
|
||||
int dotCount = 0;
|
||||
const int siblingOfListDotCount = 3;
|
||||
for (int i = 1; i < propertyPathLength; i++) {
|
||||
if (propertyPath[propertyPathLength - i] == '.') {
|
||||
localPathLength = i - 1;
|
||||
break;
|
||||
dotCount++;
|
||||
if (dotCount >= siblingOfListDotCount) {
|
||||
localPathLength = i - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
localPathLength = property.name.Length;
|
||||
}
|
||||
|
||||
propertyPath = propertyPath.Remove(propertyPath.Length - localPathLength, localPathLength) + propertyName;
|
||||
relativeProperty = property.serializedObject.FindProperty(propertyPath);
|
||||
newPropertyPath = propertyPath.Remove(propertyPath.Length - localPathLength, localPathLength) + propertyName;
|
||||
relativeProperty = property.serializedObject.FindProperty(newPropertyPath);
|
||||
}
|
||||
}
|
||||
|
||||
return relativeProperty;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user