Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Built with Unity 2021.2.
- Native trough component ([#229](https://github.com/freezy/VisualPinball.Engine/pull/229), [#248](https://github.com/freezy/VisualPinball.Engine/pull/248), [#256](https://github.com/freezy/VisualPinball.Engine/pull/256), [Documentation](https://docs.visualpinball.org/creators-guide/manual/mechanisms/troughs.html)).

### Changed
- Decouple light components from transformation override ([#350](https://github.com/freezy/VisualPinball.Engine/pull/350)).
- Refactored drag points. They are nicely separated and typed now.
- Collider debug view is now much faster and intuitive. It's also activated per default when there is no visible mesh.
- Drop and hit targets are now different components.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,31 @@ In order to start creating or modifying tables with VPE, the first thing you'll

Unity uses an application called *Unity Hub* to update itself and provide quick access to your projects. The install process is straight-forward and documented [here](https://docs.unity3d.com/Manual/GettingStartedInstallingHub.html) if you run into troubles.

When installing Unity, use the latest **2020.3** version. You can leave all the other options unchecked.
When installing Unity, use the latest **2021.2** version. You can leave all the other options unchecked.

Once Unity is downloaded and installed, you're ready to create a new VPE project. Unity has multiple render pipelines, and you'll be asked which render pipeline to use:
Once Unity is downloaded and installed, you're ready to create a new VPE project. Click on *New Project*, be sure to have selected the 2021.2 version at the top, and you'll see the following choices:

![New Unity Project](unity-create-new-project.png)

You'll have the choice between:
The relevant options for VPE are:

- **2D** - For 2D games. VPE doesn't support this renderer.
- **3D** - Unity's original built-in renderer.
- **High Definition RP** - Unity's new [HDRP](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@0.0.0/manual/index.html), used for high-end platforms.
- **Universal Render Pipeline** - Unity's new [URP](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@8.2/manual/index.html) is aimed at mobile and low-end platforms.
- **3D (URP)** - Unity's [Universal Render Pipeline](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@8.2/manual/index.html) is aimed at mobile and low-end platforms.
- **3D (HDRP)** - Unity's [High Definition Render Pipeline](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@0.0.0/manual/index.html) used for high-end platforms.

We recommend using HDRP. It's not as mature as the built-in renderer, but it's able to achieve better visuals, and it's what Unity will be focusing on in the future.

> [!NOTE]
> If you're just creating a throw-away project for testing out gameplay, the built-in renderer is more mature and faster to set up. We also support the URP, but it's not as well tested as the other two pipelines.
We recommend using HDRP. It's what we're using when developing and should be the most stable pipeline. Alternatively if you're on a laptop don't have a beefy GPU, use the URP. The built-in renderer is legacy not recommended.

Next, enter a project name and a location for your project. We recommend putting the render pipeline into the name, because in the future you might want to test out other pipelines in their own projects.

Clicking *Create* launches the Unity editor, pulls in all the dependencies for the new project, and compiles them. This will take a few minutes.
Clicking *Create project* launches the Unity editor, pulls in all the dependencies for the new project, and compiles them. This will take a few minutes.

### HDRP Setup

If you create an HDRP project, Unity provides you with a sample scene:
Once the editor has opened you can click away the HDRP Wizard that opens. You should now see an empty scene:

![HDRP Sample Scene](unity-hdrp-default-scene.png)
![HDRP Empty Scene](unity-hdrp-empty-scene.png)

The sample scene is impressive but contains lots of content we don't need, so we're going to discard it and create a new one. Click on *File -> New Scene* and select the *Basic Indoors (HDRP)* template. Save it in your *Assets/Scenes* folder as `TestTable.unity`.
Click on *File -> New Scene* and select the *Basic Indoors (HDRP)* template. Save it in your *Assets/Scenes* folder as `TestTable.unity`.

In this base scene there's a plane that will [Z-fight](https://en.wikipedia.org/wiki/Z-fighting) with our imported table later. Select it in the *Hierarchy* and move it down a little by setting the *Y Position* under *Transform* in the *Inspector* to `-0.1`. Your scene should now look like this:

Expand All @@ -58,22 +54,27 @@ To do that, go to *Edit -> Project Settings*, and select the *Package Manager* p
- URL: `https://registry.visualpinball.org/`
- Scope(s): `org.visualpinball`

Your settings page should now look like this:
Also check *Enable Pre-release Packages* (and confirm), as well as *Show dependencies*. Your settings page should now look like this:

<img alt="Scoped Registry" width="953" src="unity-scoped-registry.jpg" />
<img alt="Scoped Registry" width="916" src="unity-scoped-registry.png" />

Hit *Save* and close the window. Now you'll add VPE's HDRP package, which will automatically pull in the core package and the assets package.

Open the package manager by clicking on *Window -> Package Manager*. Then click on the "plus" icon on the top left corner of the window, and choose *Add package from git URL*.
Open the package manager by clicking on *Window -> Package Manager*. Then click on the "plus" icon on the top left corner of the window, and choose *Add package by name..*.

<p><img alt="Package Manager" width="294" src="unity-package-manager.png"/></p>
<p><img alt="Package Manager" width="237" src="unity-package-manager.png"/></p>

There, enter `org.visualpinball.engine.unity.hdrp` and click *Add*. This will take a moment as Unity downloads and compiles all of VPE's dependencies. If during this time, you see the following warning about the input system:
There, enter `org.visualpinball.engine.unity.hdrp` and click *Add*. This will take a moment as Unity downloads and compiles all of VPE's dependencies and parses all the assets that we ship in our library. If during this time, you see the following warning about the input system:

<p><img alt="Unity Input System Warning" width="390" src="unity-input-system-warning.png" /></p>

Click *Yes*. When complete, you should now have a *Visual Pinball* menu in the editor, and you should see the following new packages in the package manager (version numbers may vary):
Click *Yes*.

> [!WARNING]
> Our patcher, which is currently part of the main package, depends on the PinMAME package. Until we move the patcher into a separate package, you will have to install the PinMAME package as well. To do that, click on the plus button again and enter `org.visualpinball.engine.pinmame`, then click on *Add*.

When complete, you should now have a *Visual Pinball* menu in the editor, and you should see the following new packages in the package manager (version numbers will vary):

![Package Manager after installation](unity-packages-after-installation.png)
<p><img alt="Unity Input System Warning" width="907" src="unity-packages-after-installation.png" /></p>

Now that VPE is installed let's [import a table](xref:setup_running_vpe)!
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: How to run VPE
---
# Running VPE

Now we can get begin with some simple game play. Open Visual Pinball, create a new "blank" table, and save it somewhere. In Unity, go to *Visual Pinball -> Import VPX* and choose the new `.vpx` file.
Now we can get begin with some simple game play. Open [Visual Pinball](https://github.com/vpinball/vpinball), create a new "blank" table, and save it somewhere. In Unity, go to *Visual Pinball -> Import VPX* and choose the `.vpx` file you've just created.

You should now see Visual Pinball's blank table in the Editor's scene view:

Expand All @@ -19,11 +19,11 @@ Now that we have the camera of the scene view somewhat aligned, we still can't s

![Imported blank table](unity-imported-table-ugly-gizmos.png)

These orange artifacts are what Unity calls [Gizmo Icons](https://docs.unity3d.com/Manual/GizmosMenu.html). They are enabled by default, and since VPE uses icons for its playfield elements, they are all over the place. In order to hide them, click on *Visual Pinball -> Editor -> Disable Gizmo Icons*.
<img src="unity-gizmo-size.png" width="350" alt="Gizmo Size" class="img-responsive pull-right" style="margin-left: 15px"/>

Since a pinball table is a relatively small object, the remaining icons are huge when working on a table, so click on the *Gizmos* dropdown in the scene view and use the top slider to shrink them down a bit.
These orange artifacts are what Unity calls [Gizmo Icons](https://docs.unity3d.com/Manual/GizmosMenu.html). They are enabled by default, and since VPE uses icons for its playfield elements, they are all over the place. Unity's default gizmo size is adapted for rather large scenes and we're dealing with a pinball table, let's make them smaller by clicking on the gizmo icon in the *Scene* view, and pull the size *3D Icons* slider down until you're happy. You can additionally hide the VPE icons by clicking on *Visual Pinball -> Editor -> Disable Gizmo Icons*.

And while we're at it, choose *Visual Pinball -> Editor -> Setup Layouts* to populate a bunch of pre-made editor layouts that give you easy access to the tooling we've added to the editor.
And while we're at it, choose *Visual Pinball -> Editor -> Setup Layouts* to populate a bunch of pre-made editor layouts that give you easy access to the tooling we've added to the editor. Then, click on the top right drop down in the editor where it says *Default*, and choose *3) VPE Simple*.

![Scene view camera on table](unity-imported-table-aligned.png)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void OnSceneGUI()
#region Dragpoint Tooling

public DragPointData[] DragPoints { get => MeshComponent.DragPoints; set => MeshComponent.DragPoints = value; }
public Vector3 EditableOffset => new Vector3(-MeshComponent.MainComponent.Position.x, -MeshComponent.MainComponent.Position.y, MeshComponent.PositionZ);
public Vector3 EditableOffset => new Vector3(-MeshComponent.MainComponent.transform.localPosition.x, -MeshComponent.MainComponent.transform.localPosition.y, MeshComponent.PositionZ);
public Vector3 GetDragPointOffset(float ratio) => Vector3.zero;
public bool PointsAreLooping => true;
public IEnumerable<DragPointExposure> DragPointExposition => new[] { DragPointExposure.Smooth, DragPointExposure.Texture };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class LightInspector : MainInspector<LightData, LightComponent>
private static readonly string[] LightStateLabels = { "Off", "On", "Blinking" };
private static readonly int[] LightStateValues = { LightStatus.LightStateOff, LightStatus.LightStateOn, LightStatus.LightStateBlinking };

private SerializedProperty _positionProperty;
//private SerializedProperty _positionProperty;
private SerializedProperty _surfaceProperty;
private SerializedProperty _bulbSizeProperty;
private SerializedProperty _stateProperty;
Expand All @@ -47,7 +47,7 @@ protected override void OnEnable()
{
base.OnEnable();

_positionProperty = serializedObject.FindProperty(nameof(LightComponent.Position));
//_positionProperty = serializedObject.FindProperty(nameof(LightComponent.Position));
_surfaceProperty = serializedObject.FindProperty(nameof(LightComponent._surface));
_bulbSizeProperty = serializedObject.FindProperty(nameof(LightComponent.BulbSize));

Expand All @@ -68,7 +68,7 @@ public override void OnInspectorGUI()

OnPreInspectorGUI();

PropertyField(_positionProperty, updateTransforms: true);
//PropertyField(_positionProperty, updateTransforms: true);
PropertyField(_surfaceProperty, updateTransforms: true);
PropertyField(_bulbSizeProperty, "Bulb Mesh Size", updateTransforms: true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ protected virtual void OnEnable()
continue;
}


var item = itemTransform.GetComponent<IMainRenderableComponent>();
var isRenderableItem = item != null;
var overrideTransform = isRenderableItem && item.OverrideTransform;
_itemSelected = itemTransform.GetComponent<IMainComponent>() != null;
useDefault = useDefault && !_itemSelected && itemTransform.GetComponent<IMeshComponent>() == null;
useDefault = useDefault && (!_itemSelected || !overrideTransform) && itemTransform.GetComponent<IMeshComponent>() == null;

// must be main but not the table itself
if (item != null && !(item is TableComponent)) {
if (isRenderableItem && item is not TableComponent) {

if (_primaryItem == null) {
_primaryItem = item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public override void PostPatch(GameObject tableGo)
private static void SetupLamps(GameObject tableGo, GameObject playfieldGo)
{
var displayRegEx = new Regex("^[a-c][0-9a-f][0-9a-f]$");

foreach (var child in playfieldGo.transform.Find("Lights").gameObject.transform.Cast<Transform>().ToList()) {
var go = child.gameObject;

Expand All @@ -83,15 +83,15 @@ private static void SetupLamps(GameObject tableGo, GameObject playfieldGo)
var lampGroups = CreateEmptyGameObject(playfieldGo, "Lamp Groups");

var lampGroup1 = CreateEmptyGameObject(lampGroups, "LampGroup1");

AddLightGroup(tableGo, lampGroup1,
"gi2", "gi4", "gi6", "gi7", "gi9",
"gi10", "gi11", "gi12", "gi13", "gi14", "gi15", "gi16", "gi17", "gi18", "gi19",
"gi20", "gi21", "gi23", "gi25", "gi26", "gi28", "gi29",
"gi30", "gi31");

var lampGroup12 = CreateEmptyGameObject(lampGroups, "LampGroup12");

AddLightGroup(tableGo, lampGroup12,
"gi22", "gi24", "gi27");

Expand Down Expand Up @@ -367,7 +367,7 @@ public void DisableLamps(GameObject go)
[NameMatch("gi14")]
public void FixGI14(GameObject go)
{
go.GetComponent<LightComponent>().Position = new Vector3(894.29f, 178.4f);
go.GetComponent<LightComponent>().transform.localPosition = new Vector3(894.29f, 178.4f);
}

[NameMatch("gi2")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void HandleDisplayAvailable(object sender, AvailableDisplays availableDi
_displayGameObjects[display.Id].Clear();

} else {
Logger.Error($"Cannot find DMD game object for display \"{display.Id}\"");
Logger.Warn($"Cannot find DMD game object for display \"{display.Id}\"");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ public interface IMainRenderableComponent : IMainComponent
{
bool IsLocked { get; set; }

/// <summary>
/// If true, no transformation gizmos are displayed
/// </summary>
bool CanBeTransformed { get; }

/// <summary>
/// If true, we override the transformation gizmos to be able to sync transformation
/// with the component data. Otherwise, Unity's transformation is used.
/// </summary>
bool OverrideTransform { get; }

string ItemName { get; }

/// <summary>
Expand Down
Loading