Search Unity

SpriteTile, a fast dynamic tile system (RELEASED)

Discussion in 'Assets and Asset Store' started by Eric5h5, Dec 11, 2013.

  1. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Thanks for taking the time to do that. I followed the steps, and several variations, trying different versions of Unity, and can't reproduce it. I spent some time going over the code and can't find anything that could trigger it. What Unity version, SpriteTile version, and OS version are you using? Is there anything else you can think of that you might be doing?

    --Eric
     
  2. Prometheusheir

    Prometheusheir

    Joined:
    Aug 15, 2015
    Posts:
    20
    I am using SpriteTile 2.11 and Unit 5.2.1. On OS Yosemite.

    Another (unfortunate) thing that happened about a day before my issues is that I renamed a tilesheet in Unity and found the TileEditor had accordingly lost references to all tiles in the respective set (white squares showing). I selected all of them and deleted them (worked fine). Then I re-populated the set with the "from folder" button, which left the entire TileEditor window one grey square (stalled). Not sure how I got out of it but next time I opened TileEditor was fine and all the re-populated tiles in the set affected were showing.

    so in essence not long before my issues I broke some tile references.

    Hence still keen to uninstall and re-install to be safe. I should be updating to 2.12 anyway I guess (can you resend me the 2.12 files to the volkerelzner email address? I am not sure I ever received the update email).

    thanks.
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I sent you an update notice; please turn on update notifications so you get them automatically. Renaming a tilesheet in Unity is fine and won't break anything (the tiles are stored by reference and not by name); perhaps you renamed it outside Unity?

    --Eric
     
  4. Prometheusheir

    Prometheusheir

    Joined:
    Aug 15, 2015
    Posts:
    20
    just imported 2.12 into a test project that had 2.11 before, and it throws two exceptions:

    Assets/GameScript.cs(11,17): error CS0433: The imported type `SpriteTile.Tile' is defined multiple times


    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'UnityScript.Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
    at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
    at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00000] in <filename unknown>:0
    at Mono.Cecil.DefaultAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00000] in <filename unknown>:0
    at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
    at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
    at Mono.Cecil.TypeReference.Resolve () [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Steps.MemberReferenceReplacer.MemberReferenceReplacementForProperty (Mono.Cecil.MethodReference method) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Steps.MemberReferenceReplacer.MemberReferenceReplacementFor (Mono.Cecil.MethodReference methodReference) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Steps.MemberReferenceReplacer.Visit (Mono.Cecil.MethodReference methodReference, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.Cil.Instruction instruction, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.Cil.MethodBody methodBody, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.MethodDefinition methodDefinition, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.TypeDefinition typeDefinition, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.ModuleDefinition moduleDefinition, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit (Mono.Cecil.AssemblyDefinition assemblyDefinition, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
    at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    --- End of inner exception stack trace ---
    at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Visitor.Visit[AssemblyDefinition] (Mono.Cecil.AssemblyDefinition node, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Extensions.DoAccept[AssemblyDefinition] (Mono.Cecil.AssemblyDefinition definition, Unity.Cecil.Visitor.Visitor visitor) [0x00000] in <filename unknown>:0
    at Unity.Cecil.Visitor.Extensions.Accept (Mono.Cecil.AssemblyDefinition assemblyDefinition, Unity.Cecil.Visitor.Visitor visitor) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Steps.AssemblyUpdaterStepBase.Apply (AssemblyUpdater.Core.AssemblyUpdaterContext context) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Core.AssemblyUpdaterPipeline.Run (AssemblyUpdater.Core.AssemblyUpdaterContext context) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Application.Program.CheckForObsoleteAPIUsage (AssemblyUpdater.Application.CommandLineSpec config) [0x00000] in <filename unknown>:0
    at AssemblyUpdater.Application.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
    UnityEditor.Scripting.APIUpdaterHelper:DoesAssemblyRequireUpgrade(String)

    I simply imported the Unity5 package, and had both DLL files selected. should I have done something different?
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I would suggest removing all SpriteTile files.

    --Eric
     
  6. bitbiome_llc

    bitbiome_llc

    Joined:
    Aug 3, 2015
    Posts:
    58
    Hi Eric,

    Are the DeleteTileBlock() action changes to the level saved out by GetLevelBytes()? When a client first connects in my game I use GetLevelBytes() and push the map from the server to the client. I then load the level from the byte array. It appears that selections that I have used DeleteTileBlock() on are still present when loading the level from the byte array. Or maybe I'm just doing something wrong in the process.
     
  7. Prometheusheir

    Prometheusheir

    Joined:
    Aug 15, 2015
    Posts:
    20
    removing all files and importing 2.12 makes the import smooth.

    bad news: the corrupt level display is still occurring.

    Maybe the corruption (although it keeps occurring for all new levels) is a factor of the level. This is the most basic level, layers 0 and 1. layer 0 uses set 0 tile 0 and layer 1 uses set 0 tile 1.

    here is the file:
    https://drive.google.com/file/d/0BwM42ULJ025qT2xWa0xKamRGWlU/view?usp=sharing

    and here are 3 screenshots:
    https://drive.google.com/file/d/0BwM42ULJ025qb2I2TDd4bm1RelE/view?usp=sharing
    https://drive.google.com/file/d/0BwM42ULJ025qcndjRVNHbENZMFE/view?usp=sharing
    https://drive.google.com/file/d/0BwM42ULJ025qc2pKT2RldHVxNlE/view?usp=sharing

    one shows layer 1 with SHOW ALL on: I see deep water tile active in this layer. and shallow water, half transparent, as it is a tile in layer 0.
    one shows layer 1 without SHOW ALL. so only deep water tile in layer 1 shows. as active.
    one shows layer 0 without SHOW ALL: no shallow water tile!! but showing the deep water tile from layer 1. as active layer tile.

    this is true for all my levels now even those created months ago. adding new layers does the following:
    - all active tiles from previous layer are then assumed to go into the new active layer.
    - all previous layers fail to display their content, tile size setting or any other of their individual setting.

    EDIT: more correct description of the corruption: layer 0 shows the layer 1 active tiles. that it shouldn't show. but does not show any active tiles it has itself.

    EDIT 2: and any tiles added whether layer0 or layer1 is selected, end up showing as active tiles in either (I assume this means they get added to the highest layer as I can overwrite what the highest layer had there).
     
    Last edited: Nov 6, 2015
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I just can't get it to repro at all. Unless OS X 10.10 is causing it somehow (I'm on 10.9.5), I have no idea. Can you send me your project please (via PM).

    --Eric
     
  9. Prometheusheir

    Prometheusheir

    Joined:
    Aug 15, 2015
    Posts:
    20
    done, sent you the plain project I referred to above.
     
    Last edited: Nov 6, 2015
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I think I might have figured it out...are you using the "move layer up/down" buttons? Those are for actually moving the layers up and down in the list, not for switching layers. To switch layers, use the drop-down layer menu, or use the alt-up/down arrow keyboard command to cycle through them.

    --Eric
     
  11. Prometheusheir

    Prometheusheir

    Joined:
    Aug 15, 2015
    Posts:
    20
    Oh wow. *facepalm*

    Thanks for clarifying, I did use the buttons with the same intention as the dropdown menu. Because the layer 'name' is actually showing the layer number, it looks as if doing the same because the dropdown menu / list never changes its appearance/content. if the layers had names like "layer0 - background" then I would have spotted that turning into "layer1 - background"...

    Thanks again.
     
  12. bitbiome_llc

    bitbiome_llc

    Joined:
    Aug 3, 2015
    Posts:
    58
    Not an issue at all with spriteTile. :oops: It was my issue of how I was dynamically adding or removing a "fog" layer. Can't say enough about how easy it is to use spriteTile once you figure out how to fit it into your design. Super easy to push levels out to clients. :D
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Oops, I didn't mean to ignore your previous post, sorry! I'm glad you got it sorted.

    That's a good point, although note that the sorting layer doesn't change when you use the move up/down buttons, and it does if you just switch layers. Hmm, I'll have to think about that.

    --Eric
     
  14. Eric-Gu

    Eric-Gu

    Joined:
    Feb 19, 2014
    Posts:
    28
    Hi, Eric. I mean whether there is way to assign one image for a specific tile and then gradually change that image to another one. I think I need some interface, such as
    SetTile(position : Int2, layer : int = 0, tileInfo1 : TileInfo, tileInfo2 : TileInfo, transitPercent : int).
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's not something that's part of the Unity sprite system, so there isn't a way to do that directly. You could convert the tile to a sprite (actually two sprites), then fade between them (fade one out and the other one in), then convert back to a tile.

    --Eric
     
  16. journeyman

    journeyman

    Joined:
    Mar 19, 2013
    Posts:
    7
    Hi Eric!

    I have trouble importing my Tiled .TMX map into SpriteTile. The map contains 2 tile and 2 object layers. Oddly enough though If I remove the 2nd tile layer it imports ok, but still throws an exception.
    Unity version is 5.2.2, SpriteTile version 2.12.

    I sent you a PM with the zipped project. Repro steps further below.

    The import process throws 2 exceptions:

    InvalidOperationException: Operation is not valid due to the current state of the object
    System.Collections.Stack.Peek () (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections/Stack.cs:321)
    UnityEngine.GUILayoutUtility.EndLayoutGroup ()
    UnityEngine.GUILayout.EndHorizontal ()
    TileEditor.LevelControls ()
    TileEditor.OnGUI ()
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

    IndexOutOfRangeException: Array index is out of range.
    TileEditor.GetTileNumber (TileInfo tInfo)
    FileIO.AddLayer (Int32 layerWidth, Int32 layerHeight, System.Int32[,] tiles, System.Int32[,] sets, SpriteTile.Flip[,] flips, System.Int32[,] rotations, System.Collections.Generic.List`1 thisMapLayers)
    FileIO.BuildTMXMap ()
    FileIO.DrawTilesetSelection ()
    TileEditor.OnGUI ()
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

    Steps to reproduce:

    - open enclosed unity project
    - open SpriteTile editor window (notice the tileset has already been imported, but feel free to reset SpriteTile and re-import)
    - click "Import" button to import TMX file
    - select Assets/tilemap_big_2_tile_layers.tmx for import
    - notice first exception gets thrown as "Select matching SpriteTile set..." is shown
    - press OK (doesn't matter whether you check option to create colliders)
    - notice TileEditor level display stays empty, and another exception gets thrown in console window

    You can also try importing Assets/tilemap_one_layer_only.tmx - it is the same map but without tile layer #2. It imports fine, but still throws the first exception.

    Can you please tell me what's wrong?
     
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's some kind of bug with the Unity editor; close the asset store window and the error goes away.

    --Eric
     
  18. journeyman

    journeyman

    Joined:
    Mar 19, 2013
    Posts:
    7
    Thank you for your reply! I closed all other windows (only unity main window and spritetile editor are open now) and it still doesn't work. There is only 1 instead of 2 exceptions being thrown now though. This exception gets thrown:

    IndexOutOfRangeException: Array index is out of range.
    TileEditor.GetTileNumber (TileInfo tInfo)
    FileIO.AddLayer (Int32 layerWidth, Int32 layerHeight, System.Int32[,] tiles, System.Int32[,] sets, SpriteTile.Flip[,] flips, System.Int32[,] rotations, System.Collections.Generic.List`1 thisMapLayers)
    FileIO.BuildTMXMap ()
    FileIO.DrawTilesetSelection ()
    TileEditor.OnGUI ()
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
     
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Using the project file you sent me, if you close the asset store window, both of the TMX files import without errors. Although even with the asset store window open, all it does is print an error in the console related to the UI, but still functions correctly. (So basically the error is mildly annoying but harmless.)

    --Eric
     
  20. journeyman

    journeyman

    Joined:
    Mar 19, 2013
    Posts:
    7
    I just tried again, and it works now, but only if I do not let SpriteTile generate colliders upon import. If I check that box though, i still throws the IndexOutOfRangeException. Sorry I think I wrote in my initial error report that it does not matter whether you tick the box or not, but it seems it does matter. I would really like to be able to auto-generate my colliders though :)

    Being curious, I replaced the SpriteTile.dll with the provided source version of the plugin, and set a couple of breakpoints. It seems that as soon as FileIO.AddLayer() wants to add Tile Layer #2 of my file, tInfo.tile gets the value -1 on the first tile (x=0, y=0) somehow, which leads to the IndexOutOfRangeException when it calls GetTileNumber() with that index of -1.

    EDIT: I think I found it, in FileIO.js, line 371:
    if (tileID == 0) { //Empty
    vartileset = 0;
    tileID = -1;
    }
    This is where the the tileID gets set to -1 because in my TMX file, most of the tiles in layer have indeed a gid of 0, therefore a tileID of 0.

    Now am I using SpriteTile wrong? Can't I have empty tile positions in layers when generating colliders?
     
    Last edited: Nov 15, 2015
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You're right, there's a bug with setting the collider checkbox if there are empty tiles in the layer; sorry about that. In the SpriteTile/Editor/FileIO script, in the AddLayer function, the "if (setCollidersForImport..." line should read:

    Code (csharp):
    1.             if (setCollidersForImport && tInfo.tile >= 0 && tileSets[tInfo.set].tileData[GetTileNumber (tInfo)].useCollider) {
    --Eric
     
    journeyman likes this.
  22. journeyman

    journeyman

    Joined:
    Mar 19, 2013
    Posts:
    7
    ah that makes sense! I changed the code and it works like a charm now! Thanks again for the quick response!
     
  23. JayJennings

    JayJennings

    Joined:
    Jun 24, 2013
    Posts:
    184
    Just spent the Seahawks halftime working on a new level and it didn't get saved. I got the save dialog and gave it a name, then worked on more and when I tried to save it again I saw in the save dialog that what I had saved earlier wasn't listed among the files.

    So I did Command-1 to switch back so I could see the console and discovered the error message below. Upon switching back to the SpriteTile editor the level I was working on was gone and an earlier level had been loaded. Frack!

    Basically, my level editing is going as well as the Seahawks are playing. Not sure if there's a direct correlation, but it seems like it here..

    Jay

    DirectoryNotFoundException: Could not find a part of the path "/Users/jay/Documents/Unity5 Projects/Word Dungeons/Assets/Maps/Level01.bytes/Level01a.bytes".
    System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/FileStream.cs:292)
    System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
    (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int)
    System.IO.File.Create (System.String path, Int32 bufferSize) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:135)
    System.IO.File.Create (System.String path) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:130)
    System.IO.File.WriteAllBytes (System.String path, System.Byte[] bytes) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:594)
    FileIO.Save (Boolean saveGroups, Boolean saveAs)
    TileEditor.LevelControls ()
    TileEditor.OnGUI ()
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
     
  24. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I swear I have nothing to do with the Seahawks. I'm so far out of that scene I don't even know what sport that is. ;) In any case, you appear to be attempting to save a file into another file, which is of course not a good idea, though I can't get that to happen or see how that would even be possible. So congratulations on achieving the impossible. In any case, I made a change which can't hurt, but may or may not make any difference. If there's any chance you can manage to figure out what sequence of events leads to the problem, it would help a lot.

    --Eric
     
    JayJennings likes this.
  25. JayJennings

    JayJennings

    Joined:
    Jun 24, 2013
    Posts:
    184
    The sequence of events on my end is simple -- I click the Save As button and give it a name. Boom.

    Here's a 59-second video showing what I'm doing:

    (It's an unlisted video so nobody searching on SpriteTile will see it.)

    My workaround right now is to duplicate an existing file, rename it, and work on it. I can't save a New map at all. I also can't figure out any way to save the Group stuff -- that doesn't work for me, either (although it did at one point because I have some objects in there). I'm using OS X 10.11.1 and don't think I have any "weird" 3rd-party stuff running in the background on my system.

    I *am* using a patched version of Unity to try and fix a different problem I was running into -- v5.2.2p2 Personal is what I'm using.

    Jay
     
  26. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Nope, definitely can't duplicate that behavior no matter what I do. However I did send you a PM with the updated editor scripts; you can see if that helps or not.

    --Eric
     
  27. JayJennings

    JayJennings

    Joined:
    Jun 24, 2013
    Posts:
    184
    I think it's fixed! I was able to create and save a new level as well as save new groups. So whatever you did, remember it so the next time you can't duplicate something, just do that thing again. ;)

    Thanks for the great customer support.

    Jay

    PS - I had been using the DLLs but had switched to source because for some reason I thought I needed to in order to use this update. If I didn't need to, maybe it was an issue with the DLL? As long as it works, I don't much care, but just some extra data for you to consider.
     
  28. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The source and DLLs are the same code, as long as you're using the same version for both. In any case, I'll keep the change for the next version. (And the changelog will be "Somehow fixed that thing that J. A. Whye was having an issue with.")

    --Eric
     
  29. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    I notice that the SpriteTile have a degraded performance in 5.3.0 Betas. Can you fix it on your side?
     
  30. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If there's any degraded performance it would be up to Unity to fix it. You can submit a bug report (including SpriteTile is fine).

    --Eric
     
  31. vonchor

    vonchor

    Joined:
    Jun 30, 2009
    Posts:
    249
    Bought this a while ago and am finally starting a project with it. One issue I have is that of having to hard code tile and layer numbers like when examining the set and tile info from a call to GetTile().

    Since the TileManager.asset appears to included in the built project (at least in Windows) it seems easy to scan it at runtime and create a Dictionary with the tile names from each sprite list as keys and the layer/position as values. There may be an issue with duplicate names but that's not too hard to handle.

    So what I want to ask is has the Eric done this or has someone else? I have no problem creating this sort of utility and posting it but don't want to waste time.

    Also - Eric - is there a reason that I shouldn't do this? It seems much better to use tile names / strings in a large project than having to hardcode numerics.
     
  32. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Using strings isn't really a great idea in general. I'd suggest enums instead.

    --Eric
     
  33. JayJennings

    JayJennings

    Joined:
    Jun 24, 2013
    Posts:
    184
    Code (CSharp):
    1. Dictionary<Int2, GameObject> dungeonObjects;
    I ended up creating a Dictionary and using the Int2 position of the object as the key. When I load the level I run through looking for certain triggers and swap those tiles with prefabs and then add each one to my dictionary. During the game when my guy runs up against something I just use that position to grab the gameobject from the dictionary and can see what it is.

    Code (CSharp):
    1. if (playScene.dungeonObjects.ContainsKey(mapPos + dir))
    2.         dObj = playScene.dungeonObjects[mapPos + dir];
    If there were a tool to handle that kind of thing I'd be all over it.

    Jay
     
  34. vonchor

    vonchor

    Joined:
    Jun 30, 2009
    Posts:
    249
    yeah, i know that strings have issues from the design point of view - but the tile names are strings already and from a maintainability point of view strings make a lot of sense to me. Unless you have an awful lot of tiles and/or awfully long tile names, it can't waste all that much memory.

    enums would be annoying unless the names of the enums were the same as the tiles so I'd also have to made a edit-time tool that'd take all the names from the asset file and create a c# file with an enum decl in it. That of course also has conceptual issues and one would have to remember to update the enum every time you made changes to the tilesets etc.

    Anyway, and as a reply to Jay, I'll be looking at this more closely soon (with interruptions for family time over the next 10 days or so). I'll eventually report back.

    My main question to Eric is - is there any circumstance where that asset file wouldn't be available at runtime as far as you know? Unsure if it's something your code needs at runtime or not.
     
    JayJennings likes this.
  35. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    SpriteTile can't work without the TileManager.asset file.

    --Eric
     
  36. mengkheang

    mengkheang

    Joined:
    May 27, 2015
    Posts:
    5
    why aren't my levels load at the center of camera? how to make it load at the center of my camera?

     
  37. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The bottom-left tile is normally located at (0, 0). You can move your camera to wherever you want; the center of a level is (levelWidth/2 * tileWidth, levelHeight/2 * tileHeight).

    --Eric
     
  38. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    Beside memory, string cause a lot of garbage collection, and you can mistype and the compiler won't report any error. You can make enum that can change to a matching number.
     
  39. Prometheusheir

    Prometheusheir

    Joined:
    Aug 15, 2015
    Posts:
    20
    Eric,
    I just noticed something that could be intentional, or an oversight, not sure:

    When a tile has a certain trigger value (say zero because one never initially set any), and then defines the trigger value later (say '1'), then any new tiles you place in the level carry the '1' trigger but any tiles placed previously do not, they still carry a '0' trigger.

    I thought the trigger information is a parameter of all instances of the Tile, I was expecting all previously placed Tiles to be reading the same trigger integer.

    Regards,
    Volker
     
  40. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's correct behavior; each cell in the level/map can have any arbitrary trigger number. There are many reasons why you might want two cells, which have the same tile, to have different triggers. If you want to change all existing tiles of a specific type in a layer to the same trigger, double-clicking a cell will select all instances of that tile, then you can change the trigger value and everything that's selected will be changed.

    --Eric
     
  41. Prometheusheir

    Prometheusheir

    Joined:
    Aug 15, 2015
    Posts:
    20
    I am not using triggers that way but I can see how it makes sense for others. thanks!
     
  42. Azaphrael

    Azaphrael

    Joined:
    Nov 17, 2011
    Posts:
    41
    I'd wish it was possible to color tint the tiles in the TileEditor, much like you can do with SetColor().

    Or is that somehow possible already and I just didn't see how?
     
  43. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Not yet.

    --Eric
     
  44. mcwool

    mcwool

    Joined:
    Jan 8, 2014
    Posts:
    14
    Hi

    I'd just like to say that this is a great asset, well documented and easy to use. But i do have one important request that would improve this asset for me immensely.

    I would like a way too tell (physics)colliders in the scene to use an effector. Much like i now draw a custom collider and import to a tile, i'd like to do the same with a "Platform Effector 2D". Even better if i could just draw in level editor (the way i now draw colliders) with another color where an effector should be used.

    Please consider this request, and thank you for a great asset.

    //Martin
     
  45. Azaphrael

    Azaphrael

    Joined:
    Nov 17, 2011
    Posts:
    41
    Half Life 3 confirmed.
     
  46. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Unfortunately this seems problematic since physics colliders are grouped into chunks rather than per-tile. (In order to prevent overloading the scene with too many GameObjects.)

    Shhh!

    --Eric
     
  47. Azaphrael

    Azaphrael

    Joined:
    Nov 17, 2011
    Posts:
    41
    Would it be very bold to ask if there's an approximate ETA on that feature?
     
  48. mcwool

    mcwool

    Joined:
    Jan 8, 2014
    Posts:
    14
    Ok, maybe it would be a little overkill to implement in the editor. Did a quick fix for now that works fine for oneway physics collision.

    void Start(){
    GameObject polyColliders = GameObject.Find ("SpriteTileColliders");
    foreach (Transform child in polyColliders.transform) {
    if(child.gameObject.layer == 10){
    child.gameObject.AddComponent<PlatformEffector2D>();
    child.GetComponent<PolygonCollider2D>().usedByEffector = true;​
    }​
    }​
    }

    Thanks again for the asset.
     
  49. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It would be very, very, very bold. ;) (No ETA right now, sorry.)

    Oh, you want the effector to be applied to all colliders? That's much more feasible to implement (as you've shown).

    --Eric
     
  50. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    I load a new Unity scene (which have no tile as it's a menu scene), but the tile level from the previous scene is still persist. Is this the expected behavior? Tile.EraseLevel() is the only way in this case?