Extending Brushes

Wolfs
New Member
Registered: 2016-10-24
Posts: 8

Topic

Incoming newbie question:

I've been trying to extend an Alias Brush in some form by adjusting the offsets. The final goal just was to have a custom interface box where I could plug in a number, and it'd offset the z of the placed tile by this. It sounded like something really simple.  (essentially, I wanted to use a alias brush to paint an oriented brush at a higher offset to not replicate various path/mud/flower brushes by doing the prefabs over and over)

Something like this should, I thought, have worked at least somewhat:

        var tileTransform = args.GameObject.transform;
        var localTilePosition = tileTransform.localPosition;
        if (args.Brush.DesignableType == "Alias Brush")
        {
            float checkH = Mathf.Round(localTilePosition.z);
            if (checkH == 0)
            {
                localTilePosition.z = -(CustomOffset2);
                tileTransform.localPosition = localTilePosition;
            }
        }

While it does let me place a single tile with an offset as expected, the problem arises for tiles around it - they rise too, if placed by an Alias Brush, even though the offset here should have set the localTilePosition to a flat value. They KEEP rising too, if I change the tiles around them.
Am I misunderstanding something really fundamental, or is the approach just wrong?


Apologies for the third newbie question in a row! The tool works really well, edge cases like this aside, which probably are caused more by specific needs :)

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

Response 1

It sounds like the surrounding tiles are just being refreshed because their orientation changes as adjacent tiles are painted or erased.

Are you aware of the prefab offset feature which allows offsets to be specified on a per prefab basis?

Side Note: To detect whether a brush is an alias brush you should use the following instead because the Brush.DesignableType property is a localized property whose value may vary by translation.

if (args.Brush is AliasBrush)

,or alternatively, if you would like to be able to access properties of the alias brush:

var aliasBrush = args.Brush as AliasBrush)
if (aliasBrush != null)
{
    Debug.Log(aliasBrush.target);
}

I hope that this helps!

Wolfs
New Member
Registered: 2016-10-24
Posts: 8

Response 2

Thank you! I'll try this out. :)

Wolfs
New Member
Registered: 2016-10-24
Posts: 8

Response 3

Sadly didn't solve the issue :(.
Let me explain:

I was indeed aware of the prefab offset - using that for a couple cubicle exports for trees :). I am a newbie, but I did watch your videos!
I wasn't trying to correct model issues, I was trying to simplify the usage of brushes in 3D:
http://i.imgur.com/98labEo.png

(added some colors to help show the use case)

I've got my floor, then the yellow highlighted higher area, an area even higher highlighted in blue, and a third one highlighted in red. I am doing those with four brushes total, one for floor, one for "blue", one "yellow", one "red". Purpose: Cut down game objects and colliders.

Works well.
Next: Variations/supplementary oriented brushes. You can see them outlined in pink (stone tile path), blue and dark pink. There's also a "dirt path", you can see a tiny sliver of it at the top of the screen. These spice up the floor level really well. Now I want to use them in the blue, yellow and red highlighted areas.

The first idea was to duplicate or alias a brush, but with a changed height offset (as this is all that is needed). Due to the blocky nature, the difference is always -(1*heigth level) unity units. I could then simply make the general height level brush join with the newly created brush, and bam, problem solved without adding hundreds of prefabs. Doing this on a brush level seemed to be very convenient and would solve everything!

Doesn't work. If I duplicate, say, the "stone tile path" brush, and then start changing the "prefab offset", it will be changed the same way for the duplicated brush. Alias brush too.

Adding a "paint with additional offset"option to the alias brush itself would be optimal, but seemed to be *way* outside my capabilities (and editing the code of the brush itself after it is created, to "sneak" in the offset, wasn't possible either, because they are all encrypted), that's why I tried to do it the way outlined in my original post. It wouldn't be ideal, but it'd still simplify the overall process by a *metric ton*.

tl, dr:
-goal: make brush, use another alias/duplicate brush with the same prefab settings, except with an additional z offset. Instant 3D grid while keeping prefabs/gameobjects down!
-despair: Not good enough to get this to work. It sounds really simple, but I seem to be missing the capabilities to do this.

[Still, added a review to the Unity asset store, mine is the newest. You rock for trying to help even when newbies like me seem rather confused]

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

Response 4

Hi

I am sorry, but I am not understanding your question / use case.

Wolfs wrote:

Adding a "paint with additional offset"option to the alias brush itself would be optimal, but seemed to be *way* outside my capabilities (and editing the code of the brush itself after it is created, to "sneak" in the offset, wasn't possible either, because they are all encrypted), that's why I tried to do it the way outlined in my original post. It wouldn't be ideal, but it'd still simplify the overall process by a *metric ton*.

What do you mean when you say "because they are all encrypted"?

Many thanks

Wolfs
New Member
Registered: 2016-10-24
Posts: 8

Response 5

I am really sorry for this. I am ESL, and write way too much :( Thank you for even looking at this.

Use case (side view):
ouL9sS6.png

All of this works if I do manual placement in the editor. All I need is to apply a z correction on a brush level. This would let me to use "floor" tiles at any height level (the two in the paint example, as well as many others), saving a tremendous amount of time and streamlining the stuff really well.

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

Response 6

What about creating several tile systems; one for each level; and then just painting the tiles on their respective levels? When painting you can use the page up/down keys to quickly cycle between the tile systems.