-
Notifications
You must be signed in to change notification settings - Fork 114
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
Implemented Scene Variable, Reference, and Collection #57
Implemented Scene Variable, Reference, and Collection #57
Conversation
The new icon doesn't scale properly in the inspector, I think it has to be the same size as the other icons. You don't have to fix that, though, I'll make sure it looks good prior to merging with master :) |
Thanks for the feedback, I'll take a look at this behavior and rectify it. What I noticed about using the popup style button is that it really responds to clicks on the little arrow and nothing else (not on the hamburger icon). I'm not sure what is aggravating that, but I will fix it one way or the other.
This is probably a side effect of using GetPropertyHeight to set the size of the rect and somehow the size is being misreported. This should be fairly easy to fix.
Word, thanks for taking a look at that. I am not an UI artist by any means, but I thought I'd take a first crack at it to make things easier. |
* Modified DrawValue method of BaseVariableDrawer to be virtual. * Modified BaseReferenceDrawer to check if constant property height is greater than a single line, and if it is to display it inline below the field rather than to the right of the label. For existing value type reference types this will not change their UX, but for more complex types it allows for more space to be displayed across the entire width of the inspector. Popup will display as normal.
* Created SceneVariable as a generic BaseVariable of type SceneInfo, where SceneInfo contains serializable information about a scene asset. * Created SceneVariableEditor to allow for custom inspection of SceneVariable as well as SceneInfoPropertyDrawer for the serializable value type. This allows for a user to assign a SceneAsset to an object field and ping it while only the serialized relevant values (full path, index and enabled status in build settings) are persisted in the ScriptableObject. Helpful warnings are shown for the user if a scene is not assigned, present in the build settings, or enabled in the build settings. * Created SceneCollection * Created AssemblyInfo.cs as a code file for assembly attributes for the ScriptableObject-Architecture Assembly Definition. The current assembly attribute allows for the internals of this assembly to be visible to ScriptableObject-Architecture.Editor. This allows for internal types and members to be used in inspectors, editor windows without directly exposing them to end-users.
9a440cd
to
b33605b
Compare
* Modified GetPropertyHeight in BaseReferenceDrawer to only use the inline height calculation if the constant value property height would be greater than a single line. * Modified the width of the popup style button to be a constant fixed width of 25f. This style seems to have an issue when shown in a list that its normal fixed width is obscuring the clickable element and buffing this width to a fixed size makes this area clickable again.
* This is content added to make it easier to test this PR in the editor, it can be discarded after reviewing
b33605b
to
f4eb0ae
Compare
@DanielEverland Those reference drawer issues should now be resolved with the commit titled I've also tweaked the usage of GetPropertyHeight so that simple value types or those whose height is only one line or less are shown adjacent to the label rather than inline below. |
Merged, not sure why GitHub didn't register automatically. |
Summary
The goal of this PR is to create a new Variable, Reference, and Collection type that allows for referencing a
SceneAsset
indirectly (as its an Editor-only type) by capturing only the relevant, serializable information about it. It allows for a user to assign aSceneAsset
directly to aSceneVariable
orSceneReference
as a constant and its full scene name, index in the build settings, and enabled status in the build settings are preserved in theScriptableObject
as a POCOSceneInfo
type..Variable Declaration Stub
Example code
Additionally I have added a custom inspector and property drawer for
SceneVariable
andSceneInfo
that allows for a user to assign aSceneAsset
directly, but only preserve the relevant info. On theSceneVariable
inspector, warnings will be shown if a scene is not assigned, its not in the build settings, or if its in the build settings and disabled.A small feature that was made to the
BaseReferenceDrawer
as a part of this is some dynamic behavior regarding the size of the constant property that is being shown. If it is less than or equal to a single line width, the current behavior is preserved to show the property field to the right of the label and popup selector. If it is larger than a single line height, it will be bumped to the next line and take up the full width of the inspector. This is useful for Reference classes whose generic T type that will be shown in a property field cannot easily be shown in the smaller width to the right of the label and needs the full width of the inspector. Indenting was also fixed so that SceneReferences in a list or array would be indented and aligned with their indexed element.I've also added custom icons for the
SceneVariable
andSceneCollection
ScriptableObject
classes that matches the existing style for other icons. I did make the size of these icons at 128x128 rather than 16x16 so that the displayed Unity icon portion of it was legible. If better versions of these could be made at the smaller resolution I'm more than happy to discard these.Testing
I've added an additional commit to the head of this branch that should make it easier to test this PR without additional work. Loading scene
Assets/PR Test Content/SceneVariableTestScene01.unity
and playing in the editor should loadAssets/PR Test Content/SceneVariableTestScene02.unity
additively on Awake. There is anSceneVariable
andSceneCollection
instance that can be played around with. The asset creation menus for these types should also be working and present in the right places.This commit should be discarded prior to merging.
Changes
Created Scene Variable, Collection, and Reference
Modified base Variable and Reference Drawer