Warning
Warning: Unity Simulation is deprecated as of December 2023, and is no longer available.
Explore Permutations samples
We've provided a sample project (separate from the package contents) in the Simulation Permutations repository to show examples of using the Scene Initializers and writing custom Operations. This page will guide you through adding the project and using the sample scenes.
Getting the project
Clone the Simulation Permutations repository to your machine. Note that the latest version of the sample scenes are currently on the
dev
branch.git clone -b dev https://github.com/Unity-Technologies/Simulation-Permutations
Add the project to your Unity Hub by clicking Open and selecting the
WarehouseExampleProject
in your cloned directory.Select the newly added project to open it in a Unity version 2021.1 or above.
From here, you can navigate to the sample scene you'd like to take a look at.
Loading Dock Scene
The Loading Dock scene (Assets/Scenes/LoadingDock.unity
) shows an example of a scene with constrained requirements: six loading docks, each with two rows of pallets with ten pallets each. After perturbing the pallets and rows, random numbers of pallets are pruned in LIFO-order.
Overview
This scene takes advantage of the MultiSceneInitializer component. This contains a list of Scene Initializers and simply runs them consecutively.
In the scene, each loading dock is actually comprised of two separate initializers: one for spawning pallets in the desired rows (SpawnPallets), and one for pruning the pallets in LIFO order (PruneInOrder). There is also an intermediate step that perturbs the entire output from SpawnPallets (PerturbSpawnerRegion).
SpawnPallets is a simple extension of the provided Spawn Assets in Region Initializer. It prunes any previously placed assets, uses a new custom Operation Place in Grid, and perturbs the placed pallets.
You can view the custom Place In Grid Operation at
Assets/Scripts/PlaceInGrid.cs
.
PerturbSpawnerRegion is a simple extension of the provided Perturb Objects in Region Initializer. This Initializer grabs all assets in each region with an additional asset filter (to grab only the root output objects—in this case, all root output objects begin with the string
SpawnPallets (
) and uses the Wiggle Randomly operation on them. Additionally, this Region uses one RegionSpline for each loading dock, allowing more or less loading docks to be added to the scenario.PruneInOrder uses the LifoFromSource asset selection option in order to take a source (or parent) Transform object and iterate through its children in a LIFO fashion. The Operation applied to the selected assets is to Prune them.
Usage
Once the scene is open, you can just enter Play mode and watch the Initializers run!
If you want to test it out in Edit mode, select the MultiPlan GameObject in the scene hierarchy. In its Inspector, find the MultiSceneInitializer component and click Execute all to run through the list of Initializers.