Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

[Feature Request]Customizing the Tile Palette "Scene"

Discussion in '2D' started by spryx, Aug 10, 2019.

  1. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    400
    I would like to be able to add my own gizmos, labels, etc to the "scene" or window the tile palette runs in. While this functionality does appear to exist in OnPaintSceneGui(),

    Code (CSharp):
    1. public override void OnPaintSceneGUI(GridLayout grid, GameObject brushTarget, BoundsInt position, GridBrushBase.Tool tool, bool executing)
    2.     {
    3.         base.OnPaintSceneGUI(grid, brushTarget, position, tool, executing);
    4.         //if (brushTarget.scene.name != "Preview Scene") {
    5.         //    Handles.Label(grid.CellToWorld(position.position), position.position.AsVector2Int().ToString());
    6.         //}
    7.         //else
    8.         //{
    9.             var tileName = ((AdvancedTileBrush)target).cells[0]?.tile?.name;
    10.             //if (tileName != null)
    11.             //{
    12.                 Handles.Label(
    13.                    grid.CellToWorld(position.position)
    14.                     , "test",//tileName,
    15.                     new GUIStyle
    16.                     {
    17.                         fontSize = 30,
    18.                         fontStyle = FontStyle.Bold,
    19.                         normal = new GUIStyleState { textColor = Color.white }
    20.                     });
    21.             //}
    22.         //}
    23.    
    24.     }

    I have found that it only works for the select tool and somewhat randomly at that - the label is only drawn sometimes:
    current palette.PNG
    In my case, the label only appears when I have the select tool enabled and when I click on a tile. Furthermore, the label is not always visible for every tile. The label should always be shown.

    Something like this is what I want - The ability to add text or gizmos:
    Wanted.png

    Just to reiterate, I want to have the same capability for scene tooling that exists in any standard scene. The tile palette seems to run in its own weird "Preview Scene" so technically, this should already be possible.
     
    Last edited: Aug 10, 2019
  2. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    400
    @ChuanXin Sorry, I just realized I probably need to post this in 2D Preview. Apologies for the mention, but this is really important to me.
     
  3. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    476
    Thanks for your suggestion! We will look into adding this to improve the Tile Palette window.

    Would these gizmos and labels be specific to the brush or tool mode you are using or be applied to the Tile Palette on the whole?
     
    spryx likes this.
  4. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    400
    Currently, it seems that the Tile Palette runs in its own scene. I think the best approach might be to use the existing functionality of gizmos and editor customization for standard scenes. If this cannot be done, then yes, I think the best approach may be through a custom brush. It is already possible to populate scenes with brush data (The 2d extras, Coordinate Brush is a great example of this). The code I posted above does paint the 2d coordinates "test" on the scene. The problem is that is doesn't always work in the palette preview scene.

    To summarize and answer your question, I believe the brush approach might be a good one. Brushes only exist in the context of editing as far as i'm aware and are only applicable within the editor. If possible, the existing custom inspector workflows should be leveraged so that the tile palette scene can be augmented with labels and gizmos.
     
  5. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    476
    Yes, there is a unique scene that the Tile Palette uses with a simple rendering pass to get the Tile Palette image. We will try to see if the SceneView gizmo rendering workflow will work with the Tile Palette and its scene.
     
    spryx likes this.
unityunity