VisualPinball / VisualPinball.Engine.Mpf

Mission Pinball Framework support for VPE
MIT License
0 stars 1 forks source link

Portable machine folder #23

Closed arthurkehrwald closed 6 days ago

arthurkehrwald commented 1 month ago

The machine folder is currently always saved as an absolute path. If the Unity project or a build is opened on a different computer, MPF will stop working. Unity has a special StreamingAssets folder that allows files to be included in the build process without being converted to binary. I think this is a good place for the MPF machine folder, because it allows a user to keep everything related to a table inside the Unity project and in one repository. I have turned the MpfGamelogicEngine.machineFolder field into a property with some parsing logic to recognize when the machine folder is inside the StreamingAssets folder. The folder is then serialized as a relative path and reconstructed to an absolute path whenever the property getter is called. This makes it portable between different computers. Additionally, I have changed the custom inspector of MpfGamelogicEngine to show the project's StreamingAssets folder when selecting a machine folder if there is no path set already. The user can still select a machine folder outside of StreamingAssets, but a warning will be displayed in that case.

freezy commented 6 days ago

Awesome!