[FREE] YAPP - Yet Another Prefab Painter (Open Source, GitHub)

YAPP - Yet Another Prefab Painter

Introduction

There are already many prefab painters available for Unity, this is yet another one. In case you have use for this one, feel free to download and use YAPP.

It’s FREE and Open Source, so also feel free to fork, modify and add more features to it.

Here’s a quick demo use case video to get you started:

Example screenshot:

Requirements

  • Unity 2018.3+

Download

or via Package Manager git url:

https://github.com/Roland09/PrefabPainter.git?path=/Assets/Yapp

Quick Setup

Installation

  • create a new Unity project

  • add the Yapp folder of the GitHub repository to your project

  • in Hierarchy view open the context menu and press Yapp → Create PrefabPainter

5207384--518186--context menu.png

First Steps

The created prefab painter looks like this initially in the inspector:

5207384--518189--initial setup.png

There are 2 things that are now required:

  • a container to put your prefabs in. You can use any gameobject for that. For convenience when you hit the New button, a container is generated automatically as child object of your prefab painter gameobject. But you can use whatever you prefer, it doesn’t necessarily have to be a child. Just drag your container gameobject into the container slot.

  • prefabs which should be instantiated in the scene by this prefab painter and put into the specified container. The container can be cleared, i. e. the container children deleted, by using the Clear button.

Now you can already start painting. Please read the scene view instructions about how to use the current brush, e. g. shift + mouse drag is painting with the brush.

The Idea

When I started Unity I thought this might be a good idea to learn coding. Creating a prefab painter is something rather trivial. All you need to do is analyze an area around the mouse cursor and instantiate a prefab there.

However as usual one thing leads to the other and it turned out that there’s always something that one wants more. The existing prefab painters - free and commercial - didn’t meet my requirements. So I created my own.

A big shoutout to the awesome people of the Unity Community who provided tutorials which I used for the more advanced features. Please see the credits section in the GitHub repository. Thanks to them coding this asset took about a week.

Features

Among others, these are the core features:

  • Container based

Operates on gameobjects which are considered containers (or folders) for grouping and contain the actual prefab instances

  • Paint modes

  • Brush
    Brush settings like size, rotation, terrain alignment, slope dependency, distribution

  • Spline
    Spline settings like curve resolution, loop, separation distance, multiple lanes along the spline, snap to terrain

  • Prefab Instantiation

Probability, scale variation, position offset, rotation offset, random rotation

  • Batch operations

Batch operations on container children like applying Physics (gravity, other forces), copy/paste transforms

Beta

Please note that this is still beta and work in progress, so features may change. Also the UI might change. Currently I used standard Unity UI setup, it was rather trivial and straightforward to do so.

Feedback is very welcome.

Have fun :slight_smile:

22 Likes

Thanks a lot.
A fantastic tool.
I like the way to just drag a prefab on your panel to add it to “painting”.
6R

2 Likes

Thank you very much for the feedback in PM guys, it’s very much appreciated :slight_smile:

Here’s something that was requested after my post and I could add quickly: Limit the random rotation, so that bushes and trees can be painted:

5207579--518207--limit.png

In the setup I simply set the random rotation to only affect the y axis. If you need some feature to set this up quicker, I’m open to suggestions. I guess adding buttons about resetting the relevant axis might be a quick start.

Painting bushes via spline and brush looks now like this:

5207579--518213--bushes.gif

I already uploaded the new version.

4 Likes

I just saw that Asset Maiden released a new Western Town Asset. His Medieval Village was already awesome, so I bought this one without hesitation. Especially for $ 5.35 it’s a must have.

Then I opened his demo scene, removed everything and tried the spline prefab painter on the houses :slight_smile:

5209598--518477--town-opt.gif

Size doesn’t matter on prefabs :smile:

I guess it makes sense to have random free space around the prefab bounds. I’ll add that option.

ps: I’m not involved with Asset Maiden. His AAA assets are very cheap, I have no idea why that is, but this way he’s really supporting the Community. I love to support him back, hence the mentioning.

2 Likes

I thought I’d visualize the physics option for better understanding what’s happening when you click that button and apply forces:

5269593--527523--physics animated.gif

That’s physics running in Editor mode. I’ll push it as an option to github with the next update in case anyone fancies this kind of visualization :slight_smile:

It could be actually fun to have every prefab of a scene painted at the center of the scene and then have the physics applied and the prefabs distributed that way randomly. I might call that Genesis or the Big Bang :smile:

6 Likes

I uploaded a new version, new features:

  • Splines: new Separation type “Prefab Forward Size” as preparation for Fence Builder using Splines

  • Operations: added new Selection Tool to select few (~25%), medium (~50%), many (~75%), all prefabs
    Use case: lower e. g. painted rocks randomly into the ground

  • Operations: Physics
    Created One-Shot Simulation of which the length depends on the number of Max Iterations.
    In addition to that added a Continuous Simulation which runs until the Stop button is pressed.
    The physics run as mentioned above in Editor mode.

There’s also a new Force Apply Type:
Initial: Applies forces only at the start of the simulation, e. g. like explosion effect
Continuous: Applies forces at every step of the simulation, e. g. like wind

Snapshot of the new settings:

And a demo with force being applied in one direction and on the other hand sending the prefabs randomly into all directions:

5282658--529566--physics.gif

Watching this again, I guess it would make sense to allow you to change the gravity yourself. Will be in the next update.

1 Like

Looks great, thanks for sharing

1 Like

@Rowlan This asset is simply amazing!

Thank you very much for developing and sharing this great placement tool!

1 Like

@Rowlan Would it be possible to explain what is the Fall off distribution mode?

Thanks again!

The randomness of the distribution is determined by a curve. You could e. g. have more prefabs instantiated in the center and less on the outer bounds of the brush. Like so:

5874232--625465--falloff 2.jpg
or linear:

5874232--625468--falloff 1.jpg
But I just noticed I didn’t push the code that effectively distributes the prefabs to github, since it was only an experiment. I think I’ll remove it anyway, I haven’t found a good use case yet.

1 Like

@Rowlan

Thank you for the detail explanation. I really like the spline spawner. It 's great to be able to spawn prefabs along a spline without the need to use a third party spline asset. I also like to use the spline with a selected number of lanes. The physics operation is a great feature too. This is a great tool!

1 Like

@Rowlan
are you open for a feature request?

Depends on what it is :slight_smile:

Draw and area using spline then fill the area with prefabs using distribution sampling method ie poisson disc sampling.

You mean auto-updating and such while you resize the spline area? And with spline “area” you mean a polygon shape or something different?

1 Like

ah yeah polygon shape might be a better term. It doesn’t have to be auto updating, might be not too performant for a large area, having a button to refresh/update area might be a better solution

Oh wait you already used poisson disc sampling, just need to add polygon shape fill mode it seem

Yes. Question is what is the benefit of polygon shape? You are rather fast with adding and deleting using the brush.

6166152--674544--ui.png

Demo:

https://www.youtube.com/watch?v=xH_Szb_hpDw

If you own Vegetation Studio Pro, I rather advise to use that one in case you want filling shapes, it has a lot of advanced options like smaller scale at the borders of the Biomes and such. Nothing I couldn’t add though.

2 Likes

ah i don’t own VS, one benefit i can find from filling polygon shape are when we want to fill a large area quickly.

Amazing tool you got there, I was looking for a replacement to Polybrush.
I do have a few errors to remark.

A “Fill shape” option like proposed could be a nice addition !

The Align to Terrain option works 1 on 10 times (same thing when painting on a Mesh) :

Sometimes you can unintentionally paint prefabs on the painted prefabs. It results in a nice pile of prefabs in direction of the camera.

When choosing Poisson distribution the prefabs no longer paint on Meshes, but only spawn on the Terrain under.

Do you take in account if the model you’re painting on has a collider ?

Otherwise, great work !