Unity-Technologies / 2d-extras

Fun 2D Stuff that we'd like to share!
Other
1.56k stars 344 forks source link

prefab brush and scale #189

Open daelfer opened 4 years ago

daelfer commented 4 years ago

I have different tilemaps using different scales and all seems fine. When i try to paint with a prefab brush on a tilemap set to any scale that is not 1,1,1 then the object is painted, but thrown far off of the location it should be on the grid. (Also just wanted to say that the prefab brush allows you to paint multiple objects in the same tile making for duplicates that are not needed.) Other than that im loving all of these additions.

ChuanXin-Unity commented 4 years ago

Could you share some details about the Tilemap component you are painting on? For example, a screenshot of the inspector of the Tilemap and Grid GameObjects?

There is a recent update to the PrefabBrush by vladderb that allows you to toggle whether you want multiple copies of the Prefab onto the same cell which would be helpful for the duplicates issue.

daelfer commented 4 years ago

in this image the long grass to the right of the camera is painted on the grid that has a scale of 1x1x1. It ended up where i painted it just fine except for some reason it placed the prefab at z position of 0.5 the grass to the left of the camera is on the grid with a scale of 0.125x0.125x0.125 and it did not end up where i painted it and you can see in the inspector that all of its transforms have been multiplied by 8. I painted it at position -1.5 , 0.125 , 0 Somehow it is trying to compensate for the scale Capture

ChuanXin-Unity commented 4 years ago

Could you share the screenshots of the Grid, Normal Grid 1x1x1 Scale and Grid 0.125x0.125x0.125 Scale? I assume that the Grid component is on the Grid GameObject, while its children have the scales adjusted?

daelfer commented 4 years ago

You said something interesting. I had been setting the scale of the object with the tilemap components to 0.125. This time i tried to create a 2nd gameobject with a grid component on it and scalled down that object then left the tilemap that i put on it at scale 1. This time it worked. It was still trying to rescale my prefab to compensate so i just set the scale of the prefab to 0.125. Now i just need to find this fix that vladderb did to solve the problem with duplicates and im back in motion.

daelfer commented 4 years ago

ummm so i looked around... where do i get this prefab brush fix from?

ChuanXin-Unity commented 4 years ago

The scaling issue looks like a bug, so we'll check it out and fix that.

You can use the PrefabBrush from master. There is a "Force Delete" option in the Brush Inspector at the bottom of the Tile Palette. Enabling that should help ensure only one of the prefabs exist per cell.

On Wed, 25 Mar 2020, 7:01 pm daelfer, notifications@github.com wrote:

ummm so i looked around... where do i get this prefab brush fix from?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Unity-Technologies/2d-extras/issues/189#issuecomment-603777213, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHA3TEWB4RV2Y5LK3H5X3ODRJHQCFANCNFSM4LR5JDAA .

daelfer commented 4 years ago

Ah that works perfectly. Shame that option isnt on the prefab random brush as well

daelfer commented 4 years ago

never mind. even though it doesnt have the check box it does it automatically. am so super stoked now about this project. My students will be so happy

daelfer commented 4 years ago

hmmm. i replaced the folder called "Prefab Brushes" with the fonder called "PrefabBrushes" and all seemed to be working great. until i went to build and i got tonnes of errors. Initially i installed the 2018.3 branch then under master i downloaded as zip and took the prefabbrushes folder from that zip file to add to my project and poof errors Capture1

ChuanXin-Unity commented 4 years ago

Do the errors occur only during building a Player?

For 2018.3, the folder structure for brushes are a little specific as they exist in the Assets folder. You will need to create an Editor folder like Assets\Tilemap\Brushes\Prefab Brushes\Editor, and move all the files into the Editor folder. This tells Unity that the script files under the Editor folder are only for the Editor and not the Player. The errors you get when building should not occur as Unity will not build the Prefab Brush scripts into the Player.

Hope this helps!

daelfer commented 4 years ago

this isnt making any sense the prefab brushes and the tiles are inside the editor folder not the other way around,, I even got rid of all of the 2016.3 files and added all of the files and folders in the master branch into assets and now im getting a whole new set of errors. i have no clue how to install this. The files in the 2018.3 download were easy to install since they were wrapped up in a folder to be installed into the assets folder but i dont know what to install from the files in the 2D-extras folder or where to install them.

ChuanXin-Unity commented 4 years ago

It is important that the Prefab Brush script (The .cs files) are contained in a folder (or with a parent folder) named Editor. Based on the console log screenshot you shared above, they do not appear to be so.

image

The Prefab Brushes and the Tiles you have created generally can be placed elsewhere, so they are fine.

You could try the following setup after making a backup of your existing project:

  1. Remove all the files you have downloaded from this repository from your project. If you downloaded from the 2018.3 branch, they should be all in Assets/Tilemap.
  2. Download and extract the 2018.3 branch and place the files in your project following the folder structure. For example, files from Assets/Tilemap should go to Assets/Tilemap in your project folder.
  3. Delete the Assets/Tilemap/Brushes/Prefab Brush folder from your project as you want to replace it with the Prefab Brush from the master branch here.
  4. Create a Prefab Brush folder at Assets/Tilemap/Brushes (You will get Assets/Tilemap/Brushes/Prefab Brush).
  5. Create an Editor folder at Assets/Tilemap/Brushes/Prefab Brush (You will get Assets/Tilemap/Brushes/Prefab Brush/Editor)
  6. Download the master branch.
  7. From the master branch, copy the contents of Editor/Brushes/PrefabBrushes to Assets/Tilemap/Brushes/Prefab Brush/Editor.
  8. Wait for Unity to recompile the script files and ensure that there are no errors in the Console window.
  9. Build a player.

If you are copying or deleting files outside of the UnityEditor, remember to copy or delete the corresponding .meta files as well.

daelfer commented 4 years ago

you wonderful wonderful wonderful person you. Thank you sooo much