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

Fix Unity structs drawn in property drawer #68

Conversation

jeffcampbellmakesgames
Copy link
Contributor

Summary

This PR resolves the issues discussed in #66 where certain Unity structs cannot be shown well via a catch-all property field. This PR resolves that by adding specific checks for those types and displays them how they are edited normally elsewhere in the editor.

Testing

I've created a test script and scene at Assets/PR Test Content/UnityStructTestScene.unity where References can be viewed for each of the affected types as well as Variables/Collection assets for those same types in that folder. Try the inspector for each of these and switch them from constant to variable and back in the case of References.

Changes

Removed redundant call to set rect height

  • Removed redundant call to set rect height as it the height for an element in a reorderable list is set by its elementHeightCallback, which in this case is GetElementHeight. Removed padding GetElementHeight so that a single line item does not appear stretched.

Modified collection, reference editors

  • Modified GenericPropertyDrawer to include edge case checks for both layout and non layout modes when the type of value being displayed is a Vector2/3/4 and Quaternion so that they can be displayed in the proper format for Variables, Collections, and References.
  • Modified the CollectionEditor to include an edge case for Vector4, Quaternion to display them on a single line rather than use the reported property height which covers several lines.
  • Modified BaseReferenceDrawer to draw constant values using GenericPropertyDrawer methods; this has the benefit of keeping existing functionality for constants, plus covering edge cases for Vector2/3/4 and Quaternions.

Added internal extension methods for Vector4, Quaternion

  • Added conversion extension methods for Vector4, Quaternion to each other.

jzapdot added 4 commits April 21, 2019 15:15
* Added conversion extension methods for Vector4, Quaternion to each other.
* Modified GenericPropertyDrawer to include edge case checks for both layout and non layout modes when the type of value being displayed is a Vector2/3/4 and Quaternion so that they can be displayed in the proper format for Variables, Collections, and References.
* Modified the CollectionEditor to include an edge case for Vector4, Quaternion to display them on a single line rather than use the reported property height which covers several lines.
* Modified BaseReferenceDrawer to draw constant values using GenericPropertyDrawer methods; this has the benefit of keeping existing functionality for constants, plus covering edge cases for Vector2/3/4 and Quaternions.
* Removed redundant call to set rect height as it the height for an element in a reorderable list is set by its `elementHeightCallback`, which in this case is `GetElementHeight`. Removed padding `GetElementHeight` so that a single line item does not appear stretched.
* This is content added to make it easier to test this PR in the editor, it can be discarded after reviewing.
@DanielEverland DanielEverland added this to the Release 1.6.0 milestone Apr 21, 2019
@DanielEverland DanielEverland merged commit 84f9a75 into DanielEverland:master Apr 21, 2019
@jeffcampbellmakesgames jeffcampbellmakesgames deleted the fix/render_structs_in_property_drawer branch April 22, 2019 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants