mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +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 base property is not found, look for the sibling property.
|
||||||
if (relativeProperty == null) {
|
if (relativeProperty == null) {
|
||||||
string propertyPath = property.propertyPath;
|
string propertyPath = property.propertyPath;
|
||||||
int localPathLength = 0;
|
int localPathLength = property.name.Length;
|
||||||
|
|
||||||
if (property.isArray) {
|
string newPropertyPath = propertyPath.Remove(propertyPath.Length - localPathLength, localPathLength) + propertyName;
|
||||||
const int internalArrayPathLength = 14; // int arrayPathLength = ".Array.data[x]".Length;
|
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 propertyPathLength = propertyPath.Length;
|
||||||
int n = propertyPathLength - internalArrayPathLength;
|
|
||||||
// Find the dot before the array property name and
|
int dotCount = 0;
|
||||||
// store the total length from the name of the array until the end of the propertyPath.
|
const int siblingOfListDotCount = 3;
|
||||||
for (int i = internalArrayPathLength + 1; i < n; i++) {
|
for (int i = 1; i < propertyPathLength; i++) {
|
||||||
if (propertyPath[propertyPathLength - i] == '.') {
|
if (propertyPath[propertyPathLength - i] == '.') {
|
||||||
localPathLength = i - 1;
|
dotCount++;
|
||||||
break;
|
if (dotCount >= siblingOfListDotCount) {
|
||||||
|
localPathLength = i - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
localPathLength = property.name.Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
propertyPath = propertyPath.Remove(propertyPath.Length - localPathLength, localPathLength) + propertyName;
|
newPropertyPath = propertyPath.Remove(propertyPath.Length - localPathLength, localPathLength) + propertyName;
|
||||||
relativeProperty = property.serializedObject.FindProperty(propertyPath);
|
relativeProperty = property.serializedObject.FindProperty(newPropertyPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return relativeProperty;
|
return relativeProperty;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user