Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

2D Extras - Prefab Brush gone??

Discussion in '2D' started by meebou, Apr 30, 2021.

  1. meebou

    meebou

    Joined:
    Mar 6, 2017
    Posts:
    39
    I don't rembember exactly when, but let's say last year.... i made a prefab brush for my prefabs with the help of the 2D EXTRAS package...
    Now, with Unity 2021.1.4f and 2D extras package 2.00 i don't see the option to create a prefab brush anymore?
    I then read somewhere, its called GameObject Brush now. Okay. but i also cannot create it in my project folder,
    so i can drag & drop it into a tile palette. The only thing i found was in the tile palette itself. I can choose Gameobject Brush instead of default brush.

    upload_2021-4-30_15-57-35.png

    And then i can drag&drop a prefab inside... But that's not the good way it was before? I want my prefabs in my tilepallete so i can see the sprite and click on it etc... How do i achieve that? I can't find any tutorials. The only official unity tutorial is about the prefab brush. Now they changed it but there is no explanation on how to use that...
     
  2. meebou

    meebou

    Joined:
    Mar 6, 2017
    Posts:
    39
    No one? ... nevermind. The Prefab Brush is there if you choose in the package manager version 1.5 of the 2d Extras.. Then you have the prefab brush, but you can't add it into the tile palette anymore. I don't understand why would unity make something worse than better. It was the best thing to have the prefab brushes in the tile palette.
     
  3. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    We added the GameObject Brush which contains most of the functionality of the PrefabBrush when it comes to painting GameObjects. You can also populate and pick from a Tile Palette with GameObjects using the GameObject Brush. A drawback would be that you would not be able to create and save different Brush assets which are selectable from the Brush dropdown unfortunately.

    A workaround to this would be to manually add the PrefabBrush scripts from https://github.com/Unity-Technologies/2d-extras/tree/master/Editor/Brushes/PrefabBrushes to your project. This will enable the PrefabBrush functionality. Let us know if you have any concerns about this!
     
  4. meebou

    meebou

    Joined:
    Mar 6, 2017
    Posts:
    39
    huh? that first thing sounds exactly what i wanted. since when you can but the gamobject brush into a tile palette? last time i checked, i can only choose gameobject brush from the dropdown and then manually put my prefab everytime again and again. are there more informations about that? tutorial?
     
  5. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Not a great tutorial, but I have a video on how you can use this:



    The idea is that the GameObject Brush should work with the Tile Palette similarly to the Default Brush.
     
  6. Zebadiah

    Zebadiah

    Joined:
    Apr 6, 2014
    Posts:
    61
    Sorry to necro an old thread but google brought me here with the same issue. I'm glad to see it's possible, and this way is definitely better than having a brush for every prefab...but wouldn't it be better if we could just drag a prefab directly into the TilePalette? Why the need to have them in a scene and then select them with the eye dropper. That doesn't seem very intuitive at all.

    Also for any one else here you have to make sure your Active Tilemap is set to wherever your object is in the hierarchy. In my case I tried with my object at the root level and the eye dropper wasn't working until I noticed the setting in the video.

    Not a perfect experience, feels a bit redundant needing to drag my prefabs into a scene, align them to the grid, eye drop, then paint into the Tile Palette. Still loving the Tile tools though and I hope they continue to get developed.
     
    Last edited: Aug 21, 2022
    Wabadaba likes this.
  7. Xiangting_Su

    Xiangting_Su

    Unity Technologies

    Joined:
    Sep 22, 2020
    Posts:
    246
    True that! Test Depending on the Editor version you are on, it is already possible to drag in Prefabs/GameObjects directly into the Tile Palette clipboard. Just make sure to toggle on the Edit Mode. The workflow is very similar to dragging in new Sprites/Sprite Sheets into the Tile Palette. Dragging in GameObjects will also pop a dialog prompt asking for the location to save these newly generated Tile assets.

    My bad! This is not yet supported but definitely something we would like to look into.

    Edit Mode.png

    Alternatively, for users on 21.3 or older, it is also possible to drag in GameObjects into the Tile Palette Prefab Scene (in Prefab mode) by means of populating the Tile Palette.

    GameObject Brush.png

    Small note: When editing the Tile Palette prefab, it’s best to populate your GameObjects/Prefabs in the first Tilemap layer i.e. Layer1 because the GameObject Brush only picks from one layer.

    On the other hand, if you have a custom brush, say the Layer Brush, it will take objects (Tiles/GameObjects) from each cell across each Tilemap layer like a bunch of stacked brushes. If that's the case, you are free to populate GameObjects on any other layers however you like.

    More details and short video demo here.

    Hope this helps!
     
    Last edited: Oct 3, 2022
    Zebadiah likes this.
  8. Aridez

    Aridez

    Joined:
    Feb 12, 2014
    Posts:
    13
    I made sure to toggle the Edit mode on, then created a new Prefab with a sprite renderer and tried to drag it from its folder onto the palette I couldn't do it. The only way I could use the GameObject brush was to instantiate a prefab object, open the brush, drag and drop the Prefab in the cell and then paint a square in the Palette for future use.

    Am I missing something here? Is there a faster way to import Prefabs to the tile Palette? Or a video documenting how should it be done?
     
  9. kayroice

    kayroice

    Joined:
    Feb 7, 2017
    Posts:
    46
    @Aridez What you can do as a work around is to create a Tile asset, click on it in the Project View to open it in the Inspector, and then toggle Debug Mode on. This will expose the private SerializedFields of the Tile asset. The field you want is InstancedGameObject; drag your Prefab into that field and you now have a Tile asset that uses your Prefab.

    @Xiangting_Su, I also have never had any luck dragging and dropping a Prefab from the Project View into the Tile Palette. I've tried all manner of adding the Prefab to Tile Palettes, editing a Tile Palette's game object, etc., with no success (maybe I'm still doing something wrong?). What does work without fail is simply creating a Tile asset, and then updating its private fields (please don't remove that functionality!). It'd be great if those fields were exposed by default, instead of requiring users to go into the Inspector's debug mode. Having said that, I'd also like the ability to simply drag and drop a prefab into the Tile Palette (maybe something has changed recently; I haven't tried in a couple months, definitely have tried in previous/earlier versions of 2022.1.x). Can you verify which version of Unity shipped that allows for dragging and dropping an arbitrary Prefab into the Tile Palette?
     
  10. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    @Aridez @kayroice Unfortunately, there isn't a way for you to drop a Prefab/GameObject onto the Tile Palette window directly. Right now, you will need to use the GameObject Brush, fill in the GameObject in the Cell and paint it onto the Tile Palette, or open up the Tile Palette asset in Prefab view and place your GameObjects in that view.

    This is a really good suggestion though, and we will work on implementing this!

    We will also expose all the properties of the Tile asset in its Inspector in the normal view as well.
     
    Aridez and kayroice like this.
  11. ikorsa

    ikorsa

    Joined:
    Dec 7, 2017
    Posts:
    7
    What about randomization? Is that option not included? I am on 2021.3 editor version
     
    Callvix likes this.
  12. Xiangting_Su

    Xiangting_Su

    Unity Technologies

    Joined:
    Sep 22, 2020
    Posts:
    246
    Oops sorry guys, my bad! I might have accidentally tested the drag-and-drop functionality on an internal build. (Which I'm guessing had some internal R&D sorcery in it so sorry for the confusion.) :p

    Yes, so I went back to try it on 22.1.17f1 proper, dragging the GameObjects prefabs into the Tile Palette window in Edit Mode is indeed, not yet supported. But like mentioned, it's definitely a worthy interaction to look into.

    However, it's possible to drag-and-drop GameObjects prefabs into the Tile Palette Prefab in the Scene view already. I've recorded a 1 minute short video to show how it works. This might possibly be an alternative (and perhaps easier/quicker way) to use the GameObject brush for the time being?



    Just one small note, remember to make the GameObjects Prefabs the children of the default Tilemap Layer 1 for this to work.

    GameObjects Prefabs.png
     
    kayroice likes this.
  13. Callvix

    Callvix

    Joined:
    Nov 17, 2022
    Posts:
    1
    Hey
    I would like to ask the same question. Can anyone help me with this?

    When I was watching youtube tutorial, they were using prefab brush to create random 3D objects. How can I do it different way without this brush?
     
  14. Xiangting_Su

    Xiangting_Su

    Unity Technologies

    Joined:
    Sep 22, 2020
    Posts:
    246
    Hey @Callvix and @ikorsa, as far as I'm aware, the GameObject Brush does not support randomisation at this moment. You may consider using the Prefab Random Brush instead which is available for download on GitHub.

    The simplest way to load the Prefab Random Brush into your project is to:
    • Download the 2d-extras-master package from https://github.com/Unity-Technologies/2d-extras.
    • Unzip the 2d-extras-master folder.
    • Drop the folder into your project's Package Manager folder.
    • Click back to Unity to reload the script assemblies. (This should be automatic.)
    • Right-click in the project window to create a Prefab Random Brush asset.
      • 2D > Brushes > Prefab Random Brush.
      • You can create as many Prefab Brushes as you need.
    Once done, you should be able to see your new Prefab Random Brush (together with other new Brushes) in your Tile Palette window. With that, you can start painting random 3D Objects.

    Quick tip: To change the random distribution of Prefabs painted, change the Perlin Scale property. This will change the distribution of Prefabs painted on a particular cell. Still curious? You can read more about the Prefab Brush in our docs manual here.
     
    Last edited: Dec 12, 2022