Here is my script with a breakpoint and all informations displayed about property. Note that the values seams wrong regarding to the class above. Look at the array size, array element type, display name, isArray, etc
To make such a claim, you have at least changed your code 2 times between the two variants and each time you see the behaviour flip. If that’s not the case, it has absolutely nothing to do with it. It would be a post hoc ergo propter hoc fallacy.
If you can’t repeat it, it’s most likely not the cause. Maybe some other change you did before didn’t get saved properly before or something else has changed, maybe the data itself has changed which breaks your logic, who knows. Though empty lines in source code, especially this line would not do anything. New lines in source code are only relevant syntactically for 2 things: the termination of line comments and the termination of pre processor tags. Those are the only two things that require a new line at the end. Any other C# code could be written into a single line and would still work the same.
We can see that in the first case your property represents an array that is not expanded. In the second case your property represents the first element of an array. So you clearly have changed something in the inspector (expanded the array? / object?). We don’t know, since we don’t see, for what exact element this propertydrawer is used. The base class CollectionExtension is a normal serializable data class. So you have to actually use this as an instance somewhere. We don’t see the full picture yet, so we can not say what you may did wrong or where.
So how do you use this propertydrawer? Is it directly bound to the “AssetTableCollection” type or do you use a PropertyAttribute? If you use a PropertyAttribute (AssetTableCollectionExtensionAttribute by any chance?), are you sure you don’t use this attribute in any other place? PropertyAttributes have to go onto fields, not onto classes. So if that’s a PropertyAttribute, you’re using it wrong. Again, the important information is missing. So how does your “CustomPropertyDrawer” for your property drawer looks like?
Just to make that clear: When you used that PropertyAttribute at several places, it means Unity will use your drawer for different things. In the first case it looks like a char array or maybe a string field? So your PropertyDrawer may be executed for different properties. So this is most likely your actual issue.
I found where the problem was. Let me explain:
I make a call to property.CountInProperty() to calculate the height of that property (expecting to be my CollectionExtension) BUT, as the documentation states, this method “moves the property forward”, which changes the value of property to be the previous property of the TableCollection → Group.
I am not sure to fully understand what exactly means “move property forward” but I think there was a kind of random chance to either get the “extension” or the “group” depending on some serialization process
So I made a copy of the property to preserve its value and everything is fine !
Wow, that’s what I would call an unintuitive API, I can’t believe this ^^. Sure it may be useful when reading this property to move ahead since next you may want to iterate through those child properties. However given the name of that method it makes absolutely no sense. If I were in your situation, I’m sure it would take a while to figure that out
Thanks for posting back, I’m pretty sure I will never forget this one, it’s just too strange.