unity-technologies / 2d-extras Goto Github PK
View Code? Open in Web Editor NEWFun 2D Stuff that we'd like to share!
License: Other
Fun 2D Stuff that we'd like to share!
License: Other
I've been trying to create a script that would "stamp" one Tilemap onto another, but I've run into an issue. The Tilemap.WorldToCell method seems to produce inconsistent results, and I can't figure out why.
public class TileStamp : MonoBehaviour {
public Tilemap wallMap;
public Tilemap targetWallTilemap;
public TileBase wallTile;
void Start () {
Stamp(transform.position);
}
public void Stamp(Vector2 loc) {
transform.position = loc;
for (int x = 0; x < 10; x++)
{
for (int y = 0; y < 6; y++)
{
if (wallMap.HasTile(new Vector3Int(x, y, 0)))
{
Vector3 vec = wallMap.CellToWorld(new Vector3Int(x, y, 0));
Debug.Log(vec);
targetWallTilemap.SetTile(targetWallTilemap.WorldToCell(vec), wallTile);
}
}
}
}
}
This code should, in theory, clone the tiles from wallMap to the targetWallTilemap. While it does copy the tiles, some of them are offset, seemingly at random. The debug log outputs the expected tile locations, so I think the issue is with WorldToCell.
In this image, the vertical bar is the "stamp"
When you press Play, this is the tile configuration that's applied.
If you move the stamp around the scene, the resulting tiles aren't consistently offset. I would really appreciate some insight into this. I'm also including a package I made of the test scene. Thank you.
https://drive.google.com/file/d/1KnXTltvVYM0xqg_Kj7n5xamq1bDu35ne/view
Hi there - I'm trying to create a new Prefab Brush to place prefabs in a Tilemap, but the brush isn't appearing in the menu in the Tile Palette window. Do new brushes need to be in a particular directory to be discoverable? Do I need to add them to an array or list somewhere? Thanks for your help!
The last line drawn with LineBrush can not be erased. The tiles are actually erased but remain visible (most of them) until another game object is selected (or another line is drawn after the erasing). It seems like something related to the "line preview" done by LineBrushEditor.OnPaintSceneGUI method.
It would nice if there were some basic instructions for installing these 2D extras into your project
Tin brush (smooth) works well (when i changed material) but 'Tint brush' not works. nothing happen when i draw, erase.
Problem: Tile Cannot change Tilemap, in fact it can not pass data to brush at all from tile.
The current task I am trying to accomplish, is to create a Rule tile for making nice looking caps for walls, and then creating the walls below it at the same time. This would increase the speed of design greatly since this is tedious work. I would like to accomplish this by grabbing 3 rule tiles with the
I understand that encapsulating the brush and tiles is a clean way to design, but there are lots of times when I would want to create tools that simplify design for users. We cannot change the base Tile, nor do we have access to the code that actually paints the tile so letting a tile decide it's own tilemap seem impossible.
there is a thread discussing this here: https://forum.unity.com/threads/different-collision-layers-for-different-tile-in-the-new-tilemap-system.505392/
RuleTile seems to be a generic way.
I Think add a RuleOverrideTile(like an AnimatorOverrideController) is a good way,
Animated / Pipeline / Random / Terrain, and more custom can be implemented with RuleOverrideTile and no coding.
I'm wondering - is there a way to spawn specific prefabs on a specific tiles? I can see that tile co-ordinate data can be retrieved, but I'd like certain tiles to spawn prefabs regardless of their position.
IT isn't exactly clear which pipeline images would go here:
tile.m_Sprites[0] = (Sprite) EditorGUILayout.ObjectField("None", tile.m_Sprites[0], typeof(Sprite), false, null);
tile.m_Sprites[2] = (Sprite) EditorGUILayout.ObjectField("One", tile.m_Sprites[2], typeof(Sprite), false, null);
tile.m_Sprites[1] = (Sprite) EditorGUILayout.ObjectField("Two", tile.m_Sprites[1], typeof(Sprite), false, null);
tile.m_Sprites[3] = (Sprite) EditorGUILayout.ObjectField("Three", tile.m_Sprites[3], typeof(Sprite), false, null);
tile.m_Sprites[4] = (Sprite) EditorGUILayout.ObjectField("Four", tile.m_Sprites[4], typeof(Sprite), false, null);
Although it's obvious enough that a cross "+" would go in index 4.
I have a tile set that has gradual slopes that require a 5x5 tile check... but I don't know C# and the changes I have tried in the script have not worked. Can anyone provide me with - or help me make the changes to the script - that would enable a 5x5 check and change the size of the grids in the inspector to 5x5? Or is this already possible and I just don't understand how it is done?
This issue is thankfully fairly easy to fix by flagging textures used in tilemap with read/write. Wanted to mention it here so that this could possibly be fixed for new users that don't know how to fix this behavior. There are a few threads about this including this one.
https://forum.unity.com/threads/unity-2d-2017-2-0-b10-tile-collider-not-working-on-build.494916/
It seems the intent behind 'Default Collider' was to enable subsequently added tiles to use the 'Default Collider' setting. This does not happen due to RuleInspectorOnGUI() using the hardcoded value of Tile.ColliderType.Sprite from RuleTile.cs.
We should use the value from tile.m_DefaultColliderType in RuleTileEditor.cs instead.
RuleInspectorOnGUI() is static which prevents this from being a super simple fix potentially. Are there any side effects of RuleInspectorOnGUI() not having the 'static' modifier?
I have implemented BoxFill by just looping through the bounds and putting a random tile in each spot?
but how can I implement FloodFill? I cannot just use Tilemap.FloodFill because that uses the same tile instead of random tile?
I cannot find the source for tilemap.FloodFill in the source either https://github.com/Unity-Technologies/UnityCsReference
I guess if each user has to implement their own floodFill I will but I was hoping there was something I could plug into?
thanks
Can't import asset, new package, or drag and drop... Not sure how to include this in my project?
Hi, I am programmatically building a map using RuleTiles and RandomTiles. "Floor" is a random tile and "Walls" is a RuleTile. Each work fine when I manually draw them on a map. Programmatically the wall tiles don't seem to be generated. If I swap out "Walls" with any other Tile i have it renders fine.
My question is is there anything with the RuleTile that would prevent it from working pragmatically? Is there a better way to do what I am doing?
Also Tile.SetColor() doesn't seem to work at all in WebGL.
foreach (Cell cell in dungeonMap.GetAllCells())
{
Vector3Int tile = new Vector3Int(cell.X, cell.Y, 0);
if (cell.IsWalkable)
{
Tile t = Resources.Load("Floor") as Tile;
tilemap.SetTile(tile, t);
tilemap.SetTileFlags(tile, TileFlags.None);
}
else
{
Tile t = Resources.Load("Walls") as Tile;
tilemap.SetTile(tile, t);
tilemap.SetTileFlags(tile, TileFlags.None);
}
}
Thank you.
I am registering my game objects to a dynamic sorting library that changes their sorting layers at runtime. Is support for this type of workflow planned? A practical example of this effect is when a player in a 2D Zelda game walks behind a building in a town.
the animated tile option doesn't show up for me plz help
I get this error in the editor, but everything works fine with the tile.
UnityEditor.GridPaintingState.UnregisterPainterInterest (UnityEngine.Object painter) (at /Users/builduser/buildslave/unity/build/Modules/TilemapEditor/Editor/Managed/Grid/GridPaintingState.cs:197)
UnityEditor.GridPaintPaletteWindow.OnDisable () (at /Users/builduser/buildslave/unity/build/Modules/TilemapEditor/Editor/Managed/Grid/GridPaintPaletteWindow.cs:565)
Rule tiles do not take into account positions of other tiles in the same grid even if they are on the same tilemap. It would be nice to have a toggle to allow rules to take other tiles (non rule tile or normal tiles) into account when deciding which sprite to use.
Hi guys. I don't know what I'm doing wrong here but unzipping files won't work for me, no matter which Unity version is used. I have really standard folders structure but maybe 2d extrasss should be placed in specific folder (or separate folders?) Right now I can only see Default Brush and basic Tile to chose form Assets->Create menu. I have no clue how to expand editor functionality to include 2d extras. Can you have a look and help me with that please?
(*tech demo works fine when imported as a separate project)
None of my tiles show up in the palette in Unity 2018.1.0f2.
The tile is set correctly because if I pick the correct blank tile in the palette I can draw with it like normal.
When I imported this asset I immediately received this error.
Assets/2d-extras-master/Assets/Tilemap/Brushes/GameObject Brush/Scripts/Editor/GameObjectBrush.cs(182,36): error CS0117: 'UnityEditor.PrefabUtility' does not contain a definition for 'GetCorrespondingObjectFromSource'
Does it support isometric tiles based from new Unity 2018.3 beta ?
I edited the TintBrush.cs script, which is at the following path: 2d-extras/Assets/Tilemap/Brushes/Tint Brush/Scripts/Editor/TintBrush.cs
On line 12, a Color variable named m_Color has been created. This variable is used on line 23 when calling SetColor. m_Color is set to be white. I tried changing the value to blue. That doesn't seem to be working. It still just paints white. On the other hand, if I directly pass in 'Color.blue' when calling the SetColor method, everything works just fine. I'm really not sure why that is.
Can anyone else test this out and tell me if the same issue comes up? If the same issue comes up, maybe the code in the repo should be changed so that the color is directly passed in instead of a variable.
PS: I'm not sure if it makes a difference but I should mention that I'm using Unity 2017.3.0p4.
When I set a object for RuleTile's DefaultGameObject, this Tile will be created indefinitely when I brush the Tile, causing Unity to crash.
Firstly, great work with this. I once spent a long time doing this myself, good to see somone has done this and done it much better than I ever could have :)
So my question, I must be missing something but how do you specify that the provided sprite should be rotated on a rule?
For example in the above image note the pink area, I would like the selected sprite to be correctly rotated.
Changing the rule seems to alter the wrong one:
Any ideas?
It would be helpful, when using a Rule Tile, to setup multiple layers. For example: Drawing in top-down perspective for an RPG, you might have different layers for walls, ground and ceilings, etc.. If you draw on the walls layer, the corresponding ground tile and ceiling tiles would also be drawn on their respective layers. This would allow for even more rapid development and changes. Each Rule (Ground, Wall, Ceiling, Shallow Water, Deep Water, etc..) would still be implemented in their own Rule Tile.
The creation of a new Multi-Layer Rule Tile, would allow you to set a rule and a layer to draw on.
While allowing each Rule Tile to be used also independently, without having to re-setup the rule.
Thanks Guys for your work. I´m trying to create a forest with trees 3x1 tiles high. And want to be able to place them one tile behind. so I think the GameObject Brush would do what i would like to achieve. But how do these type of brush work, or how do i even create one.
thanks for your help.
Our game features more terrain tiles than specified in TerrainTile (for example, "one side bottom" and "one side top" are different, not simply mirrors of eachother). The current code isn't exactly super easy to grok for the purposes of extensibility for this feature.
I opened up the TintBrush.cs file and changed the value of m_Color from Color.white to Color.blue. That's it. I hit save and go back to the Editor. Suddenly I get a NullReferenceException saying the following:
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.GridPaintingState.UnregisterPainterInterest (UnityEngine.Object painter) (at C:/buildslave/unity/build/Modules/TilemapEditor/Editor/Managed/Grid/GridPaintingState.cs:197)
UnityEditor.GridPaintPaletteWindow.OnDisable () (at C:/buildslave/unity/build/Modules/TilemapEditor/Editor/Managed/Grid/GridPaintPaletteWindow.cs:565)
Anyone else having this issue?
I should mention that I'm using Unity 2017.3.
I opened a mainScene and add a stageScene(tilemap over here),
use PrefabBrush paint on stageScene, but the only mainScene be set to dirty
because
PrefabBrush.Paint "Undo.RegisterCreatedObjectUndo" is early then "SetParent",
sorry about my poor english
I cloned this down and directly moved it into my project's codebase. Is this the correct way to use this library? Also, if I want to update, can I safely grab the latest code from the repo and overwrite the older version that is in my project?
Hi,
I can't seem to see any UI controls for the Tint Brush. I saw on a Robodash demo video, that there was a color and blend parameter displayed on the Tilemap Pallette UI. I just don't see them.
The brush itself seems to work - it paints white colour on tiles with manually modified colour.
I'm using Unity 2018.2.1f1.
I tried the 2d-techdemos, but it's not working there neither. BTW. upon opening it says the project has been saved with Unity 2017.2, despite readme saying it's been saved with 2018.2....
Also - how do you setup the TintBrush Smooth? There's no example scene in the 2d-techdemos. No documentation anywhere. I have no idea what to do with the shader file - I tried applying it to a Tilemap Renderer, but it's not being recognized as a valid shader.
Any help will be greatly appreciated, as I've already spent some time trying to figure out stuff with no luck.
Thanks,
J.
I'm trying to create a sequence of tiles as part of a custom Rule Tile. Basically, I have three variants of surface tiles that only tile in order (like A -> B -> C). So I can't use random output; I have to check which tile is to the left and right. I was thinking of doing this by adding a Left Tile and Right Tile field to TilingRule, just like the GameObject field, but I can't override it. Is it possible to do this with Rule Tiles?
Hi,
@ChuanXin-Unity could you please describe in details what has changed in your latest commit and how should we be using the scripts?
Also, if it's possible, it would be nice to have a little more info on how to use the GridInformation script.
Thank you
Hi,
I would love to use your RuleTileEditor with my tiles. I found only solution (Robodash and Penny) where you are using it but how can I add it to my project. I'm beginner in Unity so if there is somewhere article how to implement this I would really appreciate any help. Great work anyway!
Sorry for adding this in issues but I have no idea how to ask you directly...
Hi,
Everything is in the question! Would be cool to grab all plugins upgrade at the same place ;)
Let's say I have a set of rules to paint walls with, in a top-down game. Now, I want to add windows to the walls at specific points. The windows would be one extra tile, and should take the place of a straight wall segment, where I paint it. I cannot add a window tile to the existing rules, because the rules for a straight segment, and a straight segment with a window, would be the same. So you would always get only one or the other.
I tried using the rule override tiles, overriding a straight segment with a windowed segment. When I now paint this on the same layer, to replace a straight wall segment, I expect a window to appear, and the wall tiles from the base rule should connect as they normally would, except the existing tiles don't connect to the new overridden tile. The rules don't work across both the base rules, and the overridden rules. It seems this is only useful for is creating another set of rules with the same tiles. The end result is that you have to use your override tiles somewhere else on your tile map.
Is there some way of doing this? There's no sample project that makes use of the Rule Override Tile, so I can't really tell, and from my experiments, it doesn't do what the name implies.
When I use a tile like a tree that is bigger than the tile size and RandomTile, the draw order seems to get confused. Even if the sort order on the Tilemap Renderer is set appropriately, some of the tiles are drawing on top of the other tiles with no consistent pattern.
Unity 2019.1.0a7
Hi! I'm trying to use prefab brush in my project as shown in official unity tutorial here -> https://unity3d.com/learn/tutorials/topics/2d-game-creation/custom-tilemap-brush-spawn-prefabs?playlist=17093 but it doesn't work.
It just places one object and then it doesn't paint more prefabs and there are thrown some exceptions in the console
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.PrefabBrush.Paint (UnityEngine.GridLayout grid, UnityEngine.GameObject brushTarget, UnityEngine.Vector3Int position) (at Assets/vendor/2d-extras/Tilemap/Brushes/Prefab Brush/Scripts/Editor/PrefabBrush.cs:20)
UnityEditor.PaintableSceneViewGrid.Paint (UnityEngine.Vector3Int position) (at C:/buildslave/unity/build/Modules/TilemapEditor/Editor/Managed/Grid/PaintableSceneViewGrid.cs:169)
UnityEditor.PaintableGrid.HandleBrushPaintAndErase () (at C:/buildslave/unity/build/Modules/TilemapEditor/Editor/Managed/Grid/PaintableGrid.cs:370)
UnityEditor.PaintableGrid.OnGUI () (at C:/buildslave/unity/build/Modules/TilemapEditor/Editor/Managed/Grid/PaintableGrid.cs:100)
UnityEditor.PaintableSceneViewGrid.OnSceneGUI (UnityEditor.SceneView sceneView) (at C:/buildslave/unity/build/Modules/TilemapEditor/Editor/Managed/Grid/PaintableSceneViewGrid.cs:81)
UnityEditor.SceneView.CallOnSceneGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:2912)
UnityEditor.SceneView.HandleSelectionAndOnSceneGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:2159)
UnityEditor.SceneView.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:2020)
So here it is, plain and simple. I've got a Rule Tile with an animation on one of the tiles but when I hit play the animation doesn't play and shows the wrong tile.
If I change the Sprite in question to a single sprite without an animation in my rule list, it shows the sprite fine and dandy.
Here are some screenshots that represent my issue:
With Animation: https://imgur.com/a/4Q0A6WZ
With Output Set to "Single": https://imgur.com/a/3TaynT2
While not exactly an issue, this is a call for help. I posted something on the 2D forums a week ago. The RuleTile, and others that extend BaseTile, require an ITilemap in order to refresh the tile. If tiles are changing at runtime, how do you force the Tilemap or RuleTile to update?
There's a _ruleTile.RefreshTile(IntVector3 pos, ITilemap tilemap); but I cannot figure out how to get an ITilemap from the RuleTile or the Tilemap.
Currently it seems to be based on the functional division of the directory structure, there are up to 38 directories, if you use the Assembly Definition, I need to set up at least 9 Assembly Definition files. Because it is based on the directory, each Editor directory needs an Assembly Definition file, Otherwise it cannot be constructed.
Although I created all the required Assembly Definition files to solve the problem, I hope this project can simplify the directory structure, because the work of recreating the Assembly Definition files is very boring. The tools between Unity should not be mutually exclusive.
I suggest changing to this directory structure, Only need to create 2 Assembly Definition files:
Hope to consider my suggestions.
I get this error on iOS works fine in Unity Editor.
LevelNew:TileFrom(TileType)
LevelNew:AddTile(Vector3)
LevelNew:Update()
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
NullReferenceException: A null value was found where an object instance was required.
at UnityEngine.Tilemaps.TileBase.RefreshTile (Vector3Int position, UnityEngine.Tilemaps.ITilemap tilemap) [0x00000] in <filename unknown>:0
at UnityEngine.Tilemaps.Tilemap.SetTile (Vector3Int position, UnityEngine.Tilemaps.TileBase tile) [0x00000] in <filename unknown>:0
at LevelNew.Update () [0x00000] in <filename unknown>:0
UnityEngine.Tilemaps.Tilemap:SetTile(Vector3Int, TileBase)
LevelNew:Update()
(Filename: currently not available on il2cpp Line: -1)
Error running RefreshTile for previous TileNullReferenceException: A null value was found where an object instance was required.
at UnityEngine.Tilemaps.TileBase.RefreshTile (Vector3Int position, UnityEngine.Tilemaps.ITilemap tilemap) [0x00000] in <filename unknown>:0
at UnityEngine.Tilemaps.Tilemap.SetTile (Vector3Int position, UnityEngine.Tilemaps.TileBase tile) [0x00000] in <filename unknown>:0
at LevelNew.Update () [0x00000] in <filename unknown>:0
UnityEngine.Tilemaps.Tilemap:SetTile(Vector3Int, TileBase)
LevelNew:Update()
(Filename: currently not available on il2cpp Line: -1)
NullReferenceException: A null value was found where an object instance was required.
at UnityEngine.Tilemaps.TileBase.RefreshTile (Vector3Int position, UnityEngine.Tilemaps.ITilemap tilemap) [0x00000] in <filename unknown>:0
at UnityEngine.RuleTile.RefreshTile (Vector3Int location, UnityEngine.Tilemaps.ITilemap tileMap) [0x00000] in <filename unknown>:0
at UnityEngine.Tilemaps.Tilemap.SetTile (Vector3Int position, UnityEngine.Tilemaps.TileBase tile) [0x00000] in <filename unknown>:0
at LevelNew.Update () [0x00000] in <filename unknown>:0
UnityEngine.Tilemaps.Tilemap:SetTile(Vector3Int, TileBase)
LevelNew:Update()
(Filename: currently not available on il2cpp Line: -1)
Error running RefreshTile for previous TileNullReferenceException: A null value was found where an object instance was required.
at UnityEngine.Tilemaps.TileBase.RefreshTile (Vector3Int position, UnityEngine.Tilemaps.ITilemap tilemap) [0x00000] in <filename unknown>:0
at UnityEngine.RuleTile.RefreshTile (Vector3Int location, UnityEngine.Tilemaps.ITilemap tileMap) [0x00000] in <filename unknown>:0
at UnityEngine.Tilemaps.Tilemap.SetTile (Vector3Int position, UnityEngine.Tilemaps.TileBase tile) [0x00000] in <filename unknown>:0
at LevelNew.Update () [0x00000] in <filename unknown>:0
UnityEngine.Tilemaps.Tilemap:SetTile(Vector3Int, TileBase)
LevelNew:Update()
(Filename: currently not available on il2cpp Line: -1)
I'm using RuleTile with some rules using Collider set to Grid and MirrorX and MirrorY, this causes the colliders created by a combination of TileMapCollider2D and CompositeCollider2D to be incorrect. (Because of the negative scaling.)
I just unzipped the 2d-extras in a project and I get an error on RuleTile.cs.
I tried to look through why that would happen but I can't figure it out. Thoughts?
Compile error is:
Assets/Tilemap/Tiles/Rule Tile/Scripts/RuleTile.cs(58,24): error CS0115: `UnityEngine.RuleTile.GetTileData(UnityEngine.Vector3Int, UnityEngine.Tilemaps.ITilemap, ref TileData)' is marked as an override but no suitable method found to override
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.