Skip to content

Tools ‐ Detail Creator

Etherpod edited this page Nov 21, 2024 · 7 revisions

The Detail Creator is a tool that lets you spawn a large number of prefabs randomly in an area quickly and easily. It is intended to be used for things like grass, but it can really be used for anything.

Setup

To open the Detail Creator, navigate to the dropdown labeled Tools at the top of your Unity project, then click the option called Detail Creator. This should bring up a window that you can drag around and attach to any existing windows.

How To Use the Detail Creator

The first thing required for using the tool is to set a target transform. This should be an empty GameObject with no children, as prefabs that are generated will be added as children to this object.

After dragging in an object to the Target Transform field in the Detail Creator window, it will show the rest of the settings. Most of these can be ignored for now.

Find the setting called Prefabs to Spawn near the bottom of the window and click the up arrow button on the right. This should add an item to the list, which you can expand by clicking the name of the setting.

­

The item called - Element 1 - can also be expanded, which will show the settings for this specific prefab.

­

Drag a prefab from your Assets window into the Prefab field so that the tool can spawn it.

­

Then move a GameObject that has a collider into the cylinder shape that is shown on the target transform you chose.

  • If the cylinder shape disappeared when you deselected the target transform, turn off Hide Spawn Area in the Detail Creator window.
  • If you are unable to find the target transform, try selecting it in the Hierarchy and pressing F.

Make sure the GameObject you moved into the area is in the lower half of the cylinder shape. Prefabs will spawn at the center of the cylinder and attempt to move downward onto something.

­

Now, just click the button at the bottom labeled Generate Prefabs. It should spawn a number of the prefab that you selected on the GameObject that you moved into the cylinder.

  • If nothing is spawning on your GameObject:
    • Try clicking Generate Prefabs a few more times.
    • Make sure your GameObject has a collider.
    • Try increasing the size of your GameObject.
    • Make sure the size of the Snap Targets list is 0.
    • Turn off Remove Floating Prefabs and see if anything shows up. If not, right click the Detail Creator tab at the top and close it. Then follow all of the previous steps again.
    • If you made it back here and it still isn't working, you may be on an old version of the assets repository. Follow the guide on the wiki for updating your assets repository.

Settings Overview

It may seem a bit confusing at first, but this will go over all of its functions. You can also see tooltips for all of the settings in Unity by hovering your cursor over the setting names.

Preset

The current preset being used. Closing the tool window or closing Unity will reset all of the settings, so make sure to save your settings in a preset if you plan to use those settings again.

  • If the preset is not being applied or you want to reapply it, simply select it from the preset dropdown again.
  • Changes to the settings cannot be reverted, but presets can be reapplied to "undo" changes.
  • The presets are saved under Assets/Editor/DetailCreatorPresets and can be shared with others.

- Save Preset -

Overwrites the selected preset with the current settings.

- Delete Preset -

Deletes the selected preset. Cannot be undone.

- Save New Preset -

Lets you save the current settings as a new preset. Type in what you want it to be named in the text box.

Target Transform

Before accessing the rest of the settings, the first thing you need to do is set a target transform.

­

The target transform serves as the tool's location in the scene, and any prefabs that are generated will generate as children to this object. You probably will want to make a new empty GameObject to use as the target transform. Drag the object you want to use into the Target Transform field of the tool, which will expand the rest of the options the tool offers.

Amount

Specifies the amount of prefabs that can spawn when generating. It will choose a random value between the minimum and maximum values you set.

Spawn Area Type

Specifies the shape of the spawn area, which can either be a cylinder or a box. You can change the dimensions of these areas by adjusting the values underneath this setting.

  • Prefabs will always be spawned at the center height of each shape.
  • The spawn area can be rotated and scaled with the target transform.
    • Any prefabs that spawn will inherit any scale or rotation.

Image 1: Cylinder shape - Image 2: Box shape

Hide Spawn Area

Disables the spawn area outline when the target transform is not selected. Useful when the area outline is cluttering up your screen, as turning off gizmos does not affect the outline.

Remove Floating Prefabs

Removes any prefabs that may be floating after generation.

Image 1: Disabled - Image 2: Enabled

When generating, depending on your prefab settings the tool will attempt to snap the prefabs down to the nearest collider. If any prefabs are unable to snap to a collider, they will be left floating, which may be an undesired outcome.

Prevent Overlap

Specifies whether the tool should try to avoid overlapping prefabs on top of each other when generating.

Image 1: Disabled - Image 2: Enabled

This works by moving each prefab away from other prefabs that are close to it, resulting in a more spread-out generation. This is not 100% effective, as it may not help or make many changes.

- Minimum Distance -

When moving, prefabs will check for any other prefabs that are closer than this distance.

- Correction -

The distance to move when moving away from other prefabs.

- Iterations -

Since moving one prefab may bring it too close to another prefab, this will repeat the process the specified number of times to try to fix any imperfections.

Allow Prefab Stacking

Allows prefabs to stack on top of each other when generating together. Does not affect previously generated prefabs.

Image 1: Disabled - Image 2: Enabled

Snap Targets

Adding GameObjects to the list of snap targets forces the tool to only snap prefabs to the GameObjects specified. GameObjects in the snap targets list will only be used if they have a collider.

If you want to snap to everything, set the size of the list to 0.

- Ignore Snap Targets -

Snaps to everything except the snap targets, as opposed to only the snap targets. Prefabs will not snap to objects behind ignored snap targets.

Prefabs to Spawn

The list of prefabs that can be spawned with the tool.

  • To add a prefab, click the up arrow button. This will add a new item under the list that you can expand.
  • To remove a prefab:
    • Click the down arrow button to remove the last prefab in the list.
    • Expand one of the prefabs and click the "Remove Prefab" button.
  • You can also set the size of the list by changing the value on the right of the two arrows.

The next sections cover the settings you can adjust for each individual prefab.

- Prefab -

The prefab that will be spawned. Make sure you assign something from your Assets, not from the scene.

- Weight -

How likely it is for this prefab to spawn compared to the others. If all of the prefab weight values are the same number, they will all have an equal chance of spawning. If one prefab's weight value is twice as big as the rest, it will be twice as likely to spawn.

Weight is not based on percentage.

- Scale -

The tool will pick a random value between the minimum and maximum scale when generating.

- Phase -

Specifies how much random rotation the prefab should have when generating. Setting this to 0 will result in the same rotation every generation, 0.5 will result in a rotation between -90 and 90 degrees, and 1 will result in a rotation between -180 and 180 degrees.

Image 1: No phase - Image 2: Max phase

- Phase Axis -

The axis to randomly rotate the prefab on.

Selecting All will give the prefab different random rotations on all 3 axes.

- Snap to Surface -

Attempts to snap the prefab straight down to the nearest collider within the spawn area. If there are no places to snap to, it will be left floating.

- Snap From Top -

Checks for colliders from the top of the spawn area rather than from the center. In other words, this prefab will snap to objects above the center of the spawn area first if this is enabled.

Image 1: Disabled - Image 2: Enabled

- Align To Surface -

Rotates the prefab's Y axis to be perpendicular to the surface it is snapping to.

Image 1: Disabled - Image 2: Enabled

Clear On Generate

Destroys all children of the target transform before generating more prefabs.

Seed

The seed used for any random results when generating. You can click the "Randomize" button to randomize this seed.

- Auto Randomize -

Automatically randomizes the seed when generating. Disable this to get the same result every time you generate with the same settings.

Target Parent

The object in the scene that generated prefabs will be moved under when Confirm Prefabs is clicked.

Generate Prefabs

Generates the prefabs.

Clear Prefabs

Destroys all children of the target transform.

Confirm Prefabs

Moves all the children of the target transform to be children of the target parent. These prefabs will no longer be affected.

Use the Pages sidebar above and click "Show x more pages..." at the bottom of the sidebar to navigate all pages.

Clone this wiki locally