Brush preview skewed when using brush to place objects

Futch
New Member
Registered: 2017-02-28
Posts: 6

Topic

Hello. We're using this tool to make a level editor for our designers. All of our prefabs appear fine in the Brush tab preview and also are fine when placed in the scene.

However, once a brush is selected and the process of placing the object begins (to be clear I mean when the red highlighting of the tile and preview are happening under the mouse in the scene view) the preview is skewed/scaled to odd proportions. While it doesn't seem to affect the final object that is being placed it is causing confusion and dissatisfaction among the designers which are using it as they are not seeing what is ending up in the scene after click. The issue seems exacerbated by child objects of the prefab as well.

We've tried removing and pulling the asset again with our brush set and and no object in the heirarchy has a scale that is not (1,1,1). Again, the brush preview in the Brush tab appears fine.

I thought of overriding the custom preview image with that thumbnail but see the Brush.Preview is no longer supported(and I would imagine the 'placement preview' would be based on it as well).

Any assistance in fixing this issue would be much appreciated. Thanks

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

Response 1

I am unsure what you mean by skewed; can you provide a screenshot to demonstrate the issue?

Immediate tile previews can be disabled by deselecting "Display immediate previews" if they are causing confusion (see user preferences).

Immediate tile previews can also be disabled on a per-brush basis from the "Extended Properties" section in the brush designer window.

Immediate tile previews can be entirely customized on a per prefab basis by creating a custom implementation of the CustomImmediatePreview component and adding this to the root object of your tile prefab(s).

Futch wrote:

I thought of overriding the custom preview image with that thumbnail but see the Brush.Preview is no longer supported(and I would imagine the 'placement preview' would be based on it as well).

I do not recall there being a field or property with the name Brush.Preview; unless I'm simply forgetting it or this was something that was inherited from MonoBehaviour that has since become obsolete. There is, however, a field called Brush.customPreviewImage which allows you to override the thumbnail shown in the brushes palette window. This does not affect the immediate preview (the red one) that is drawn in the scene view.

Futch
New Member
Registered: 2017-02-28
Posts: 6

Response 2

Apologies as I knew this was going to be difficult to explain and tried my best to outline it.

BrushPreviewThumnail
BrushPreview

This is small, but an accurately scaled preview of the prefab asset associated with the Brush

Placement Preview
Placement Preview Skewed

For consistency in terminology, I call this the "Placement Preview". It is the red highlighted preview shown when using the brush in the scene view prior to clicking to actually place the object. It is this image that is being skewed - and by that I mean the image is being scaled inconsistently with the prefab. You can see the cannon on top of the car is stretched and scaled up quite a bit. The base object is also scaled larger. No settings were changed and all objects are scaled (1,1,1)

Prefab in scene
Prefab in scene

For reference this is what the prefab in the scene properly scaled.

I'm aware of the CustomImmediatePreview component in the designer but my assumption would have been that the same setup for the brush thumbnail preview would be used in the 'Placement Preview' and was hoping for a way to rectify this without having to create something to update all the custom previews to the same image that I expected to be there(and which was there until recently)

Any help is greatly appreciated. Thanks.

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

Response 3

Thank you for the additional information.

Are you able to provide the brush that you show above so that I can diagnose the cause? (I will provide you with contact details via a private message).

Futch
New Member
Registered: 2017-02-28
Posts: 6

Response 4

Hi Lea,
I responded via email with the requested assets. Please let me know you've received them and if they work for you.

We're now experiencing another issue which may have an easier fix: When using the brushes sometimes another random prefab is placed adjacent to the brush as if it was an oriented brush with randomization. However these brushes are meant to just place a single prefab with no other 8 way orientation(and none are set). Is there a setting we've missed?

Thanks again for any help you may be able to provide. We have all the making of a strong level editor for our game now with brushes for everything and these are the last issues designers are struggling with to make use of you assets fully as we move deeper into development.

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

Response 5

Futch wrote:

I responded via email with the requested assets. Please let me know you've received them and if they work for you.

Okay I have looked at your file and believe that there are 2 separate (but related) issues leading to this.

Your sprite packing is set to "Tight"; if you change this to "Full Rect" the problem is partially resolved. You have customized the pivot points of the sprite data, unfortunately when drawing the preview we don't have access to this customized pivot.

At the time of implementing the immediate preview, Unity did not provide an API for drawing nor accessing the "tight mesh" of a packed sprite. I am not sure whether this situation has changed but after a quick look at the Graphics class it does not appear that there is a DrawSprite method at the moment.

If you can export the sprite slices as separate images from your graphics package then you should get better packing in "Full Rect" mode plus half the problem is immediately solved. With regards to the custom pivot; if you can customize the pivot using the game object hierarchy rather than the sprite itself; then that issue would also be resolved.

Failing that you could always disable immediate preview if it is too confusing for affected brushes.

I will see if Unity have added a way to access the sprite mesh and custom origin in their more recent releases.

Futch wrote:

We're now experiencing another issue which may have an easier fix: When using the brushes sometimes another random prefab is placed adjacent to the brush as if it was an oriented brush with randomization. However these brushes are meant to just place a single prefab with no other 8 way orientation(and none are set). Is there a setting we've missed?

Can you send a demonstration of the issue so that I can figure out what might be causing it?

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

Response 6

Since later versions of Unity 5 the components of the sprite mesh are now exposed via the Sprite class. Building the immediate preview mesh from this data resolves both of the original issues.

This will be included in the next update of Rotorz Tile System for Unity 5.5.1+ but cannot be supported in the latest Unity 4 build of Rotorz Tile System since Unity 4 simply doesn't provide the API.

Futch
New Member
Registered: 2017-02-28
Posts: 6

Response 7

Hi Lea,
Thanks for the input. Yes, we have many sprites that this is occurring to now and we look forward to the fix in the next update. Not to be pushy but is there an expected date for this?

Thanks again for all your work!

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

Response 8

I was awaiting further information regarding the other issue you raised:

Futch wrote:

We're now experiencing another issue which may have an easier fix: When using the brushes sometimes another random prefab is placed adjacent to the brush as if it was an oriented brush with randomization. However these brushes are meant to just place a single prefab with no other 8 way orientation(and none are set). Is there a setting we've missed?

I'll assume that you resolved this issue and will push the other fix to the asset store team for approval over the weekend.

Many thanks :)

Futch
New Member
Registered: 2017-02-28
Posts: 6

Response 9

Apologies. Yes it was resolved in a way.

It appeared to be caused by prefabs/tiles being deleted in the Hierarchy as opposed to using the Brush tools. Over time this resulted in chunks retaining data to objects which were no longer present. While it did not always happen, it was reproducable to a point. Deleting the objects with the brush tool(and having chunks auto-destroy when empty) has mitigated the issue for now.

Thanks!

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

Response 10

The update package has been submitted to the Unity Asset Store and is pending approval.

Please let me know how it goes!

Many thanks

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

Response 11

The update has been approved and is now available from the asset store.

Futch
New Member
Registered: 2017-02-28
Posts: 6

Response 12

Thank you. This fixed our major issue