You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After generating a Reference ScriptableObject script with the SO code generator using a custom serializable struct with its own propertyDrawer, the representation of the struct has the wrong height when folded out in the editor. As far as I know, this only happens for SO References, not any of the other SO classes. It requires the "Use Constant" flag to be true. The height for the resulting representation of the property is always wrong, as the foldout icon takes up an entire line's height.
Reproduction flow
Take a simple struct, in this case called CameraView. It contains two Vector3 values, to determine the desired rotation (in Euler angles) and position of a camera. This is the struct definition:
[Serializable]
public struct CameraView {
public Vector3 cameraPosition;
public Vector3 cameraRotation;
}
Since the struct is serializable by the UnityEditor, we have a very basic PropertyDrawer, that just draws the fields as intended:
After this, we generate SO Architecture code for the CameraView type, including a CameraViewReference. This allows us to create a few CameraViewVariable assets, which look fine in the editor: (Of course, we're ignoring the developer description as that was already mentioned in a different issue.)
When we finally include this reference in a MonoBehaviour, like so:
public CameraViewReference cameraView;
It looks fine as a variable:
But when we select "Use Constant", we are immediately presented with the foldout icon, positioned a bit strangely:
This isn't a major issue though, as it's still possible to click the rightmost edge of the foldout icon, which results in the images shown at the top of this issue.
Another issue would be the indentation of this struct, as it would be better suited using the full width underneath. However, that is not the main focus.
Potential solution
After digging around in the BaseReferenceDrawer, I found a potential solution. In GetPropertyHeight, the SupportsMultiLine bool is false for custom structs. When manually set to true for testing purposes, the height changes when the field is folded out.
Closed:
Folded out:
But as you can see, the height is still a bit strange, as it now results in a bit of unused space. Regardless, I noticed the use of the [MultiLine] attribute for classes would allow one to make use of this behaviour. However, as it stands, this is only reserved for classes, and not for structs.
The text was updated successfully, but these errors were encountered:
I've encountered the same problem in the collection editor.
I did things a bit different this time along. I generated these scriptable objects for a class instead of a struct, and putting the MultiLine attribute above the class declaration doesn't seem to have any effect.
I figure that this is probably the result of the same problem. To reproduce this one, just follow the original reproduction flow, but generate a collection as well. Using a class VS a struct might make a difference but I'm not completely sure about that.
I'm working on a fix by implementing #110 - this is, as you might imagine, quite a big feature. Once it's done everything should render properly, since I'm also re-writing all the editors.
Once it's done you won't have to implement PropertyDrawers either, unless you want some custom behaviour, of course.
Issue
After generating a
Reference
ScriptableObject script with the SO code generator using a custom serializable struct with its own propertyDrawer, the representation of the struct has the wrong height when folded out in the editor. As far as I know, this only happens for SO References, not any of the other SO classes. It requires the "Use Constant" flag to be true. The height for the resulting representation of the property is always wrong, as the foldout icon takes up an entire line's height.Reproduction flow
Take a simple struct, in this case called
CameraView
. It contains two Vector3 values, to determine the desired rotation (in Euler angles) and position of a camera. This is the struct definition:Since the struct is serializable by the UnityEditor, we have a very basic PropertyDrawer, that just draws the fields as intended:
OnGUI:
And GetPropertyHeight:
After this, we generate SO Architecture code for the

CameraView
type, including aCameraViewReference
. This allows us to create a fewCameraViewVariable
assets, which look fine in the editor:(Of course, we're ignoring the developer description as that was already mentioned in a different issue.)
When we finally include this reference in a MonoBehaviour, like so:
It looks fine as a variable:

But when we select "Use Constant", we are immediately presented with the foldout icon, positioned a bit strangely:

This isn't a major issue though, as it's still possible to click the rightmost edge of the foldout icon, which results in the images shown at the top of this issue.
Another issue would be the indentation of this struct, as it would be better suited using the full width underneath. However, that is not the main focus.
Potential solution
After digging around in the


BaseReferenceDrawer
, I found a potential solution. InGetPropertyHeight
, theSupportsMultiLine
bool is false for custom structs. When manually set to true for testing purposes, the height changes when the field is folded out.Closed:
Folded out:
But as you can see, the height is still a bit strange, as it now results in a bit of unused space. Regardless, I noticed the use of the [MultiLine] attribute for classes would allow one to make use of this behaviour. However, as it stands, this is only reserved for classes, and not for structs.
The text was updated successfully, but these errors were encountered: