-
Notifications
You must be signed in to change notification settings - Fork 64
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
Refactor Scene Setup #302
Merged
Merged
Refactor Scene Setup #302
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## master #302 +/- ##
===========================================
+ Coverage 69.68% 83.62% +13.94%
===========================================
Files 136 136
Lines 6646 7444 +798
Branches 859 0 -859
===========================================
+ Hits 4631 6225 +1594
+ Misses 1785 1219 -566
+ Partials 230 0 -230
Continue to review full report at Codecov.
|
This was referenced Jul 22, 2021
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is still WIP, but I'll write some documentation here so people can validate before I go into too deeply (although the ground work is already done).
Before this PR, importing a VPX file would write the entire table data into the scene. This approach had several issues:
Table
object, hacks were necessary to update this object when stuff in the scene was added or removed. It actually didn't really work at all.Table Container
To solve the synchronization issue, we've split the
Table
class, which was the root object of all the data, into two classes:Table
now only holds the "table data", which are the global parameters of the table, but no game items, textures, or anything else.TableContainer
is an abstract class that provides access to the rest of the data, which are textures, materials, sounds, game items, collections, global table props, custom info tags, and mappings.Now, when the table file is read, we get a instance of
FileTableContainer
, a subclass ofTableContainer
. That's how we get access to all the data in the file. That data is then converted to a scene, where we have aSceneTableContainer
(as a field ofTableAuthoring
). This container also provides access to all the data, but it pulls it out of the scene. This means we don't need to sync anymore, since the oldFileTableContainer
doesn't exist anymore once import has finished.SceneTableContainer
doesn't contain any state, it just knows where to retrieve the state from. For example, the binary data of a texture would be retrieved from an image in the asset folder (see below), or the metadata of a flipper would be retrieved from the flipper'sFlipperAuthoring
component, which still sits in the scene.We currently refresh the references of
SceneTableContainer
onEditorApplication.hierarchyChanged
, but this might not be necessary, maybe we can lazy-refresh only when we actually need fresh data.Assets
When importing, assets are now written to separate files in the asset folder whenever possible, to keep as little as possible in the scene.
This means that we can now edit textures directly on the disk and Unity will automatically re-import them.
Note that we still store all the original data in the authoring component of the game object. However, we "free" heavy, fields once extracted. For example, after the mesh data of a primitive is saved as an asset, the mesh of the data object is nulled so it doesn't add redundant data to the scene.
Materials
Materials from Visual Pinball are saved for later export, but are ignored otherwise. That means updating them doesn't change anything in the converted Unity material, and changing the converted Unity material doesn't update the original material. If a material is used as physics material, or if it has the physics properties set, the material is saved as asset as a
PhysicsMaterial
object and linked to the collision authoring component. During gameplay, the asset is used instead of the table data.Side Car
The "side car" object was initially used to off-load heavy data into a separate
ScriptableObject
. I don't see any use of this anymore. However, we still would like to re-export data we currently don't use in VPE. Thus, this object was renamed toLegacyContainer
and contains data that is in the VPX file, but ignored by VPE.TODO
SceneTableContainer.GetMaterial()
SceneTableContainer.GetTexture()
When creating a new table, ask for a name(Table1 is fine, it can be renamed)Convert the "resources" dependency to prefabs(new issue)When exporting, add an option to automatically include all meshes in the scene as primitives (non-collidable toys), even when no(new issue - maybe)PrimitiveAuthoring
component is set.