Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Unity struct types do now allow edit-time modification #66

Closed
jeffcampbellmakesgames opened this issue Apr 20, 2019 · 5 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@jeffcampbellmakesgames
Copy link
Contributor

jeffcampbellmakesgames commented Apr 20, 2019

Summary

There is currently a bug with the Inspector/Drawers for editing Reference constant, variable, or collections of Vector4 and Quaternion where only a foldout is shown with no editable fields (tested on 2019.1.0f2).

I have resolved this drawing issue by adding some hardcoded checks to GenericPropertyDrawer (for layout and non-layout methods) to check for these types and show the appropriate controls and changing the BaseReferenceDrawer to use this helper class, but the work is based on PRs #57 and #65 so I would wait until those are merged prior to making another PR.

Before

Vector4Variable
image

QuaternionCollection
image

Example script with various references
image

After

Vector4Variable
image

QuaternionCollection
image

Example script with various references
image

@DanielEverland
Copy link
Owner

There's still a couple of issues that I've confirmed aren't related to #68

There's a bit of a gap between the reference button and the following field

Constant values expand across several lines

@jeffcampbellmakesgames
Copy link
Contributor Author

Padding

There's still a couple of issues that I've confirmed aren't related to #68

There's a bit of a gap between the reference button and the following field

Constant values expand across several lines

The gap is related to the fix for the bug with that popup style mentioned here #57 (comment). Essentially when in a list that Popup button is being obscured by the propertyfield next to it which is somehow extending past the beginning of its rect (internal to Unity, our calculations seem fine), thus rendering it unclickable. I mitigated this issue by giving the popup button a width that includes its own width + buffer for the indent level. This results in there being a slight margin between the end of the rect for the popup and propertyfield, but allows the popup to remain clickable whether in a list or as a single field. I've added some screenshots here showing a pink box for the constant/variable propertyfield and how it interferes with the popup button, with and without the fix.

WithoutFix
image

With Fix
image

This behavior is something internal to the EditorGUI controls for vector fields which we likely are not going to be able to fix easily. One possible solution is to write our own EditorGUI Vector field methods which would allow us to more tightly control the spacing and avoid any blackbox behavior from the default Unity Vector field controls.

Overall the impact of this padding as a bug seems low to me, but could be mitigated with more custom editor code for these value types.

Constant Values on Next Line

Latest screenshot off of master for constant value drawers
image

The only time where I see constant values being placed onto the next line is where the inspector width has become small enough that the controls are not editable and being placed there. I tried some fixes to see what it would look like when it was forced to a single line, but this seems to cause a worse readability issue than symptom its trying to fix.

With fix to set single line always (less readable):
InlinePropertyDrawerWithoutHeightAdjustment

Current behavior where constant is pushed to next line with small inspector width (more readable):
InlinePropertyDrawerWithHeightAdjustment

@jeffcampbellmakesgames
Copy link
Contributor Author

jeffcampbellmakesgames commented Apr 22, 2019

I created a PR here that adds a Debug GUIStyle as well as some unrelated refactoring I did while testing this. If you feel like poking at this just add SOArchitecture_EditorUtility.DebugStyle to any EditorGUI call you want to debug and the background color should show as a slight pink.

@DanielEverland DanielEverland added the bug Something isn't working label May 1, 2019
@DanielEverland
Copy link
Owner

I fixed the following issues

  • Space between popup and value fields
  • Incorrect use of multiline for primitives (Types now require the [MultiLine] attribute)
  • Non-multiline fields will no longer draw beneath their labels on inspectors with low width

inspector

@Jeffrey-Campbell-Zapdot
Copy link

Nice job! Looks great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants