Ingame painting tools

jlevet
Member
From: Marseille, France
Registered: 2014-03-31
Posts: 33
Website

Topic

Hello,

That would be nice for an ingame (runtime) tilesystem editor to have access to the painting tools offered in your RTS: Tools window

- Line
- Rectangle
- Picker
- Fill
- Regular  paint tool

and theirs options (size / shape etc..)


Game Developper working on Zombie Night Terror.

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 1

Hey there!

The plan is to provide a better demonstration of an in-game level designer once the new Unity GUI has been released. I agree that it would be nice to include examples of some of the in-editor tools.

In the next release 2.3.0 the API which is used by the painting tools will be exposed in a new public and documented class called PaintingUtility. This is the same class used by in-editor tools and is extremely easy to use. This can be used as a basis to implement in-game painting tools of a similar nature to the in-editor ones.

Whilst the API is still subject to change, here is a little taster of how this can be used:

// Paint point circle with radius of 3 (paint tool with circle nozzle):
PaintingUtility.PaintCircle(
	system : yourTileSystem,
	index  : new TileIndex(5, 5),
	radius : 3,
	args   : PaintingArgs.GetDefaults(yourBrush)
);

// Draw simple line of tiles (line tool with radius 1):
PaintingUtility.PaintLine(
	system : yourTileSystem,
	from   : new TileIndex(0, 0),
	to     : new TileIndex(10, 10),
	args   : PaintingArgs.GetDefaults(yourBrush)
);

// Stroke line of tiles with circle of radius 3:
PaintingUtility.StrokeLineWithCircle(
	system : yourTileSystem,
	from   : new TileIndex(0, 0),
	to     : new TileIndex(10, 10),
	radius : 3,
	args   : PaintingArgs.GetDefaults(yourBrush)
);

Like you mentioned, it will also be possible to customize painting arguments:

var paintingArgs = PaintingArgs.GetDefaults(yourBrush);
// Change fill rate to make a spray tool!
paintingArgs.fillRatePercentage = 50;
// Randomize rotation of painted tiles.
paintingArgs.randomizeRotation = true;
// Paint around existing tiles (instead of overwriting them).
paintingArgs.paintAroundExistingTiles = true;

From a coding perspective, it is already very simple to implement custom tools for painting rectangles since you just need to loop through the area and use yourBrush.Paint(system, row, column).

And likewise, the ability to pick the brush from an existing tile is literally just the case of looking up the tile data and then reading its brush:

var tile = yourTileSystem.GetTile(mouseRow, mouseColumn);
var pickedBrush = ( tile != null )
    ? tile.brush
    : null;

I hope that this helps and is of interest to you.

jlevet
Member
From: Marseille, France
Registered: 2014-03-31
Posts: 33
Website

Response 2

Hi again,

First of all, thanks for your complete and fast answer.
The public exposition of your PaintingUtility class is exactly what i need, just to avoid re-write your functions myself looping through indexes.

Do you have an ETA for 2.3 release? or a Beta access?

Thanks

Jérome levet.


Game Developper working on Zombie Night Terror.

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 3

jlevet wrote:

Do you have an ETA for 2.3 release? or a Beta access?

The release will happen soon after the Unity 4.5 release. I will send you a private E-mail regarding beta access.