Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rotorz Tile System for painting 2D and 3D tiles!

Discussion in 'Assets and Asset Store' started by numberkruncher, May 10, 2012.

  1. AndyGFX

    AndyGFX

    Joined:
    Jan 13, 2012
    Posts:
    98
    Hi, I'm fresh owner of your great Unity editor extension.

    I can't find eye icon for Hide/Show in RTS: Scene window.

    $icons.png

    and one more question.

    When I define brush by orientation matrix, must be created (rotated) model manualy to needed direction and saved as prefab or is it possible make it automaticaly by orientation matrix from "base" mesh?
     
  2. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    This feature is only available when using Unity 4.0.0+

    Yes rotation is defined for the prefab. This can be achieved in the regular Unity way or by using the "Use as Prefab Offset" feature which was introduced recently.

    Rotation is not automatically calculated for an orientation, though you could intercept the painting of tiles (in editor and/or at runtime) to perform custom rotation based upon the tile orientation. The following event was indeed introduced for this very purpose:

    Brush.TilePainted - http://rotorz.com/tilesystem/api?ref=C25E747A

    I hope that this helps with your project :)
     
  3. GermyGames

    GermyGames

    Joined:
    May 20, 2012
    Posts:
    38
    On thing that's been bugging me for a while is the lack of previews for tiles in my project. At some point, the Rotorz stopped creating previews.

    Example:
    $RotorzPreview.png

    It isn't a huge worry since we mostly paint tiles through code, but it can get annoying when adding new brushes. Any ideas as to what's causing it?
     
  4. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Are you using source control?

    Asset previews are rendered using the API provided by Unity (see AssetPreview.GetAssetPreview), but unfortunately asset previews seem to break when using source control or asset server.

    However, there is a workaround which forces RTS to regenerate its previews:
    1. Backup your files just in case you delete the wrong assets :)
    2. Delete the preview folder "Assets/TileBrushes/Editor/Preview".
    3. Select RTS|Tools|Rescan Brushes to regenerate previews.

    Edit: This might not fix your preview in the "Orientations:" section. Double-clicking the preview will take you to the prefab asset. To restore the preview you will need to force the prefab to re-save by making a change to it. Then reload Unity for the preview to be shown. Again, this is a known issue which I have reported to Unity. For some reason source control causes asset previews to break.


    I hope that this helps in your scenario, please let me know how it goes!
     
    Last edited: Apr 2, 2013
  5. GermyGames

    GermyGames

    Joined:
    May 20, 2012
    Posts:
    38
    That would explain it, the previews must have broke after I started using svn.
     
  6. AndyGFX

    AndyGFX

    Joined:
    Jan 13, 2012
    Posts:
    98
    Hi guys,
    because I'm lazy and I like automatic processes, I wrote simple extension for RTS/Tools called "Replicator" for create prefabs from selected base tile(s) in scene with properties:

    Prefab folder: (Application.dataPath+<user defined folder name>)
    mode:
    TOP = for TopDown tile orientation
    FRONT = for Platform tile oriantion
    rotation to direction: +/- X,Y,Z depend on selected mode.


    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEditor;
    4. using System.Collections;
    5.  
    6.  
    7. public enum TILE_MODE{FRONT=0,TOP=1}
    8.  
    9.  
    10. public class Replicator : EditorWindow
    11. {
    12.     private string prefabFolder = "Replicator Prefabs";
    13.    
    14.     private bool front = false;
    15.     private bool left = false;
    16.     private bool back = false;
    17.     private bool right = false;
    18.     private bool up = false;
    19.     private bool down = false;
    20.    
    21.     private string prefix = "";
    22.     private string postfix = "_F";
    23.     private string name_go = "";
    24.     private TILE_MODE mode = TILE_MODE.TOP;
    25.    
    26.     [MenuItem ("RTS/Tools/Replicator")]
    27.     private static void Init ()
    28.     {
    29.         EditorWindow.GetWindow (typeof (Replicator));
    30.     }
    31.    
    32.     void OnGUI()
    33.     {
    34.         this.prefabFolder = EditorGUILayout.TextField("Prefab folder: ",this.prefabFolder);
    35.         if (this.prefabFolder.Length==0) this.prefabFolder = "Replicator Prefabs";
    36.    
    37.         this.mode = (TILE_MODE)EditorGUILayout.EnumPopup("Mode",this.mode);
    38.        
    39.         if (this.mode==TILE_MODE.TOP)
    40.         {        
    41.             this.front     = EditorGUILayout.Toggle("(+Z) Front",this.front);                
    42.             this.back     = EditorGUILayout.Toggle("(-Z) Back",this.back);
    43.             this.right     = EditorGUILayout.Toggle("(+X) Right",this.right);
    44.             this.left     = EditorGUILayout.Toggle("(-X) Left",this.left);
    45.         }    
    46.        
    47.         if (this.mode==TILE_MODE.FRONT)
    48.         {        
    49.             this.up     = EditorGUILayout.Toggle("(+Y) Up   ",this.up);
    50.             this.down     = EditorGUILayout.Toggle("(-Y) Down ",this.down);
    51.             this.right     = EditorGUILayout.Toggle("(+X) Right",this.right);
    52.             this.left     = EditorGUILayout.Toggle("(-X) Left ",this.left);
    53.         }
    54.        
    55.         if (GUILayout.Button("Create"))
    56.         {
    57.             CreatePrefab();
    58.         }
    59.     }
    60.    
    61.     public void CreatePrefab()
    62.     {
    63.         GameObject[] obj = Selection.gameObjects;
    64.          
    65.         System.IO.Directory.CreateDirectory(Application.dataPath + "/" + this.prefabFolder);
    66.        
    67.         foreach (GameObject go in obj)
    68.         {
    69.             string name = go.name;
    70.             string localPath = "";
    71.             PrefabUtility.DisconnectPrefabInstance(go);
    72.            
    73.             if (this.mode==TILE_MODE.TOP)
    74.             {
    75.                 // SAVE +X dir                
    76.                 if (this.right)
    77.                 {
    78.                     localPath = "Assets/"+this.prefabFolder + "/" + name + " +X.prefab";
    79.                     this.CreateNew(go, localPath ,new Vector3(0,90,0));
    80.                 }
    81.                
    82.                 // SAVE -X dir
    83.                 if (this.left)
    84.                 {
    85.                     localPath = "Assets/"+this.prefabFolder + "/" + name + " -X.prefab";
    86.                     this.CreateNew(go, localPath ,new Vector3(0,-90,0));
    87.                 }
    88.                
    89.                 // SAVE +Z dir
    90.                 if (this.front)
    91.                 {
    92.                     localPath = "Assets/"+this.prefabFolder + "/" + name + " +Z.prefab";
    93.                     this.CreateNew(go, localPath ,new Vector3(0,0,0));
    94.                 }
    95.                
    96.                 // SAVE -Z dir
    97.                 if (this.back)
    98.                 {
    99.                     localPath = "Assets/"+this.prefabFolder + "/" + name + " -Z.prefab";
    100.                     this.CreateNew(go, localPath ,new Vector3(0,180,0));
    101.                 }
    102.                
    103.             }
    104.            
    105.             if (this.mode==TILE_MODE.FRONT)
    106.             {
    107.                 // SAVE +X dir    
    108.                 if (this.right)
    109.                 {
    110.                     localPath = "Assets/"+this.prefabFolder + "/" + name + " +X.prefab";
    111.                     this.CreateNew(go, localPath ,new Vector3(0,0,-90));
    112.                 }
    113.                
    114.                 // SAVE -X dir
    115.                 if (this.left)
    116.                 {
    117.                     localPath = "Assets/"+this.prefabFolder + "/" + name + " -X.prefab";
    118.                     this.CreateNew(go, localPath ,new Vector3(0,0,90));
    119.                 }
    120.                
    121.                 // SAVE +Y dir                
    122.                 if (this.up)
    123.                 {
    124.                     localPath = "Assets/"+this.prefabFolder + "/" + name + " +Y.prefab";
    125.                     this.CreateNew(go, localPath ,new Vector3(0,0,0));
    126.                 }
    127.                
    128.                 // SAVE -Y dir                
    129.                 if (this.down)
    130.                 {
    131.                     localPath = "Assets/"+this.prefabFolder + "/" + name + " -Y.prefab";
    132.                     this.CreateNew(go, localPath ,new Vector3(0,0,180));
    133.                 }
    134.                
    135.             }
    136.            
    137.             PrefabUtility.DisconnectPrefabInstance(go);
    138.             go.transform.rotation = Quaternion.Euler(0f,0f,0f);    
    139.         }
    140.          
    141.        
    142.     }
    143.  
    144.     public void CreateNew(GameObject obj, string localPath, Vector3 angles)
    145.     {
    146.         obj.transform.rotation = Quaternion.Euler(angles);
    147.         obj.transform.position = Vector3.zero;
    148.        
    149.         Object prefab = PrefabUtility.CreatePrefab (localPath, obj);
    150.        
    151.         EditorUtility.ReplacePrefab(obj, prefab, ReplacePrefabOptions.ConnectToPrefab);
    152.         AssetDatabase.Refresh();
    153.     }
    154.  
    155.    
    156. }
    157.  
    158.  
     
  7. tiggus

    tiggus

    Joined:
    Sep 2, 2010
    Posts:
    1,240
    Hello,

    I'm debating several approaches for a 2D tile based game and the look and feel I had liked the most was a 2D isometric view where the tiles would be diamond shaped with width 2x the height. Does rotorz have any support for this type of tilesystem? I am a bit unclear on the orientation brush as to whether that is what it is referring to.

    Also I am looking for a way to "hide" groups of tiles by making them transparent when they come between the camera and the player(think walking behind a tall 2d building to display the road). Initially I am thinking of adding a group identifier to each building tile gameobject so when a raycast hits one tile of the group I can hide the whole building which resides on a different tileset. Any comments on whether that is possible would be helpful, thanks!
     
  8. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Hi tiggus

    Rotorz Tile System does not provide support for an isometric grid. You can angle a grid and view with an orthographic camera to get an isometric effect, though this is not the same as the functionality provided by a dedicated 2D isometric solution.

    That said, you could create an isometric game using actual 3D blocks and again setup an orthographic camera.

    You could certainly do something like this if you were using 3D tiles, though I do not think that this is feasible with the 2D tile support provided by Rotorz Tile System. 3D tiles are literally instances of prefabs, so you can attach a script which controls their transparency based upon distance from camera (or better still, implement a specialised shader which might be able to offer better performance than a script).

    Please let me know if this is of help to you :)
     
  9. tiggus

    tiggus

    Joined:
    Sep 2, 2010
    Posts:
    1,240
    Thank you that is indeed helpful information.

    As far as complexity goes everything seems to be pushing me to use the 3D approach with orthographic camera as you mentioned or go with a true topdown 2D. If I go 3D turbosquid will probably be getting a lot more of my money because I am not that great at 3D :)

    Either way I am definitely interested in your tile system for quickly building levels without reinventing the wheel.

    Thanks!
     
  10. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Hi, this is a great project.

    Our project requires Unity Flash Export. Does this support Flash. We also need the in-game level designer to work in Flash.
     
  11. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Hi rocki
    Thanks!

    I do not have access to the Flash plugin for Unity, so unfortunately this is not something that I can test for you.

    I understand that some scripts have compatibility issues that are specific to the Flash platform because various functions are not implemented. Since Rotorz Tile System has not been tested against Flash, it is very possible that it makes use of unavailable functionality.

    Rotorz Tile System works with Android, iOS, WebPlayer, Windows and OS X, but nobody has reported their experiences with Flash so far.
     
    Last edited: Apr 9, 2013
  12. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    It's not really testing for me, it's kinda testing for your plugin as a plugin maker so you know which platform your plugin supports as you are selling the product. I think that the more platforms Rotorz Tile system supports then the larger the customer base. Responsibility of testing aside, Flash usually doesn't like Refection and Linq. I'm happy to test if you have some sort of trial version that expires. I have Unity Pro 4.1.2f . P.S. NGUI author got NGUI working with Flash and has good information if you ask him. I also have links to other plugin makers who have successfully Flashified their projects and are now All Unity Platform Complete.
     
    Last edited: Apr 9, 2013
  13. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    In an ideal world Rotorz Tile System would be tested on all platforms and devices, but this is just not possible due to financial constraints. Thank you for your kind offer to test support with the Flash plugin.

    The Rotorz Tile System runtime assembly makes use of Linq, Reflection (Type.GetMethod and MethodInfo.Invoke required for compatibility with both Unity 3.5.7 and 4.0.0) and lots of Generics (another troublesome feature in terms of Flash compatibility). Whilst usage of Linq could be eliminated by refactoring, it is not possible to avoid Reflection or Generics at this time.

    Unfortunately the runtime functionality of Rotorz Tile System is currently not compatible with the Flash plugin. It is possible to use Rotorz Tile System with Flash if all runtime functionality is stripped using the provided optimisation feature.

    The Unity development team have done an excellent job at making their game engine cross-platform and it seems that the only major component with compatibility issues is the Flash Export plugin. I suspect that Flash will be supported in the future as improvements are made to the Flash plugin.

    I apologise for any inconvenience caused by this.
     
  14. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    Hi, I just bought this tile system, and it seems to be pretty good, except I have 1 issue I'm trying to figure out. When you have the "Scene" window open, and click the "CreateTileSystem" button, a window should display options for creating the new tile system. The first time I clicked it, I got a window and was able to create a tile system. Then from that point on, it appears I get a flicker but the window does not show up. The preference window don't appear to show up either. I tried resetting my unity default layout, and reimporting rotorz, but no luck. I'm using windows 8, and unity 4.1.2. I just tried the same thing on my Mac, and the windows appear to open fine. Any ideas?
     
  15. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Hi sanjokids

    This is not an issue that I have been able to replicate. The "Create Tile System" window is shown using the regular functionality provided by the Unity API.

    Q1. Can you replicate this issue after restarting Windows?

    Q2. Does this issue occur for the following standard Unity-provided windows?

    - Edit | Preferences...
    - Help | About...

    In the past I have experienced a similar issue when using Unity where the Windows UAC alert box appears whilst Unity is actually running. This crashes the graphics context which causes all floating editor windows to appear empty. This is an issue which I reported to Unity and one of their developers confirmed the issue with UAC.
     
  16. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    I figured out a reason why the tile system create window wasn't popping up. I'm using parallels 8 on my Macbook retina, and have somewhat weird scaling options to get things to look good for windows 8, and all the scaling fiasco was causing the windows to show offscreen, hence I couldn't see it. After decreasing the resolution I was able to spot the tile system create window.
     
  17. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Fantastic, I am glad that you resolved the issue :)
     
  18. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Bought the package.

    Been exploring and learning more about it.

    I am mainly using the runtime component of Rotorz to Mobile and very concerned with the high number of draw calls. Is it possible to do incorporate MeshBaker from Unity asset store. This package is a perfect fit for making Rotorz Fast and Furious on Mobile devices. Rotorz is getting more and more attractive as it currently support Patho-lo-gical pooling and Playmaker. By adding MeshBaker support, Rotorz would be unstoppable on Mobile devices.

    Please let us know if this is something that could be possible.

    Thanks.
     
  19. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    You can optimise tile systems for use on mobile devices by merging tile meshes at design time. This helps to reduce the number of draw calls where multiple tiles share the same materials. You can tweak the tile system chunk size to better suit your scenario. I would recommend experimenting with various chunk sizes and profiling to determine which works best for you since this will vary depending upon what you are trying to achieve.

    See:

    Alternatively you can use Unity Pro static batching or third-party mesh optimisation tools instead of the one provided with Rotorz Tile System. Just make sure that you make any optimisations to a second copy of your scene (so that you can modify the master if and when needed).

    As with the Unity static batching feature, you may not want to statically merge all tile meshes. You can specify which tiles are merged by setting the "Static" brush flag as desired. The following excerpt from the Unity documentation also applies to the optimisation feature provided by Rotorz Tile System:

    - http://docs.unity3d.com/Documentation/Manual/DrawCallBatching.html

    Rotorz Tile System optimisations cannot be applied at runtime. You could achieve this using a custom or third-party script, though you will not be able to paint/erase tiles once tile meshes have been merged.

    I hope that this is of help to you!
     
  20. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    Is there an additional read on how auto tiling generates the tiles and atlas texture? Such as a known method I can google or is it a custom logic by you? I read the section on it in the docs, and it helped, but I don't quite get how the combinations form the final result, so not quite sure how to create the auto tile texture, besides playing with it and guessing until things fit right.
     
  21. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Hi sanjokids

    Okay let's use the "Basic" autotile layout to explain this in greater detail. The process does vary a little from the "Extended" layout, but hopefully this will make it a little clearer for you. The basic layout is split into 3 rows and 2 columns which are simply copied to the output atlas since they are useful `as-is`:

    $annotated.png

    From an artist perspective you just need to make sure that your sub-tiles "tile" onto one another. I have annotated the following illustration with some blue and green arrows to try and demonstrate this.

    $less-technical.png

    The additional tiles are generated by sub-dividing the "Cross" and "Corners" tiles and then mixing and matching. The following image illustrates the formation of several key tiles which should hopefully make this easier to understand. I have colour coded the sub-divisions so that you can see how they are formed.

    $example.png

    The following video demonstrates the creation of an autotile using the basic layout:



    I hope that this helps with your question, but please let me know if you are still confused and I will do my best to assist.
     
    Last edited: Apr 22, 2013
  22. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    Ok, it makes more sense. Pinned subtiles meaning if they appear, they are appear in the same quadrant the 4 part subtile of a tile. The green and blue arrows say that a outgoing blue arrow on a subtile can only transition to another subtile accepting a incoming blue arrow, but not green. Correct?

    As for the video, is that a special photoshop template with all the settings and layers to assist in creating the tiles? I'm not too familiar with photoshop, but I don't seen any photoshop file in the assets package. Seems like it might be useful.

    I imagine there's a nice algorithm to generate it, but it seems complex at the moment.
     
    Last edited: Apr 22, 2013
  23. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    I am trying to integrate MeshBaker with Rotorz runtime and have a question.

    1. It seems that as a new tile is painted, surrounding tiles are updated so as to graphically fit with the new tile. Is there somewhere I can easily get access to which tiles are updated. The reason is that a new tile is added, I have to add it to MeshBaker combined mesh, and if anything changes at anytime, I have to remove the old tiles and update combined mesh with the new tiles. It would really be handy to have access to an array of tiles that changed for every new tile added.
     
    Last edited: Apr 22, 2013
  24. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Yes, that's right.

    I created a series of Photoshop actions for the basic autotile layout which automatically re-arrange tiles making them easier (for me at least :p) to create. If you send me your E-mail address by PM I would be happy to send you these actions. There are currently only actions for the basic layout.
     
  25. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    You can determine when tiles are added/refreshed using the following event handler, though this will not tell you when tiles have been erased:
    http://rotorz.com/tilesystem/api?ref=C25E747A

    Though, I guess that you will likely know when a tile is being erased.

    Another option which gives you more control is to define a custom object factory. There are two advantages to this, 1) you can make use of a pooling solution, 2) you can control over how tiles are both painted and erased. When a tile is painted you might be able to copy the mesh data directly from the prefab without actually instantiating it (which would be much better for performance).

    http://rotorz.com/tilesystem/api?ref=BECAC858

    Please let me know if this helps with your scenario, I suspect that the object factory solution will be the most appropriate for you.
     
  26. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    I am using the hatguy_level_designer scene as test. Each time a tile is added or deleted, I call meshBaker.AddDeleteGameObjects() to update the combinedMesh.

    Can you make a sample script of how the object factory solution would look like in code. Also how would the PoolManager code fit into this ? Thanks.



    if (leftButton _lastPainted != index) {
    // Ignore if this tile was painted last!
    _lastPainted = index;

    // Paint with left mouse button
    _brush.Paint(_currentSystem, index.row, index.column);

    TileData tile = _currentSystem.GetTile(index.row, index.column);
    if (tile != null) {
    // Tile exists!
    meshBaker.AddDeleteGameObjects(tile,true);
    }

    _currentSystem.RefreshSurroundingTiles(index.row, index.column);

    }
    else if (rightButton) {
    // Ignore last painted state
    _lastPainted = new TileIndex(-1, -1);

    TileData tile = _currentSystem.GetTile(index.row, index.column);
    if (tile != null) {
    // Tile exists!
    meshBaker.AddDeleteGameObjects(tile,false);
    }

    // Erase with right mouse button
    _currentSystem.EraseTile(index.row, index.column);



    _currentSystem.RefreshSurroundingTiles(index.row, index.column);
    }
     
  27. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    I modified RtsPoolManagerObjectFactory.cs to add the gameObject to MeshBaker:


    GameObject IObjectFactory.InstantiatePrefab(GameObject prefab, IObjectFactoryContext context) {

    .......

    else {
    GameObject go = Instantiate(prefab) as GameObject;
    meshBaker.AddDeleteGameObjects(go,null);
    // This prefab is not pooled, just create it in the usual way
    return go;


    }


    It's adding the object to MeshBaker but not at the same position as the painted prefab. Is the placement of the prefab done after the return statement?

    edit: Just added log statement before the return.
    Debug.Log("x="+ go.transform.position.x + " y=" + go.transform.position.y + " z=" + go.transform.position.z);

    Always return (x=0,y=0,z=0)

    1. How then to get the position info ?


    edit: Object centre_alone_var(Clone) has an unknown material Default (UnityEngine.Material). Try baking textures UnityEngine.Debug:LogError(Object).

    2. It seems that the material on the instantiated object is also not applied.

    Meshbaker really wants a complete object that's fully instantiated with all materials and placed at the correct location. Would like to know your thoughts on how to best give MeshBaker what it needs.

    Thanks.
     
    Last edited: Apr 23, 2013
  28. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Please see RtsPoolManagerObjectFactory, an object factory which provides support for PoolManager by Path-o-logical Games.

    The prefab is the original template which is not placed into the tile system. The role of the object factory is to instantiate an instance which will then later be placed into the tile system. You can get the tile transform matrix which can then be used to transform the mesh into its correct position: Brush.GetTransformMatrix

    If you are using the material mapping functionality, then no this has not happened yet since the re-mapping process is applied after the object factory has produced an instance of the requested prefab.

    Rotorz Tile System asks the active object factory for a new instance of a specific prefab before. The returned object is then assigned to the tile data, transformed into the tile system, materials are remapped when applicable. You can manually remap materials at runtime like follows (see IMaterialMappings):
    Code (csharp):
    1.  
    2. IMaterialMappings mappings = brush as IMaterialMappings;
    3. if (mappings != null) { // not all brushes support material mappings, but oriented do :)
    4.     Material prefabMaterial = yourRenderer.sharedMaterial;
    5.     Material remappedMaterial = mappings.RemapMaterial(prefabMaterial);
    6.  
    7.     // Use `remappedMaterial` when manipulating your procedural mesh at runtime.
    8. }
    9.  
    I am afraid that I haven't used MeshBaker and do not know how it works.

    If you were using the Mesh class provided by the Unity API then you would not need to instantiate the prefab in order to merge its mesh into a another mesh. The Mesh.CombineMeshes function allows you to input a transform matrix. This allows you to position the tile mesh within the merged mesh using the tile transform matrix.

    Unity actually comes with an example mesh combine script (see Scripts.unitypackage or import via Assets|Import Package|Scripts).

    It might be worth asking the developer of MeshBaker whether it is possible to do something like described by the following pseudocode:
    Code (csharp):
    1. // void AddMesh(Mesh mesh, Material material, Matrix4x4 transform)
    2. meshBaker.AddMesh(prefabMesh, remappedMaterial, tileTransform);
     
    Last edited: Apr 23, 2013
  29. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
  30. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    I learnt some interesting news today which is relevant to a previous discussion on this thread regarding Flash. As many of you may already be aware, Unity Technologies is no longer planning to support the Flash platform:

    http://blogs.unity3d.com/2013/04/23/sunsetting-flash/
     
  31. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
  32. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    So I bought this and have been busting my brains on how to work with Orientations and Alias'...I've combed through the docs and it was no help. I'm really surprised there are no videos showing how to do basic stuff. Can I get some help please?
     
  33. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Which part are you having difficulties with?
     
  34. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    I simply create the orientation tiles but they do not 'orient' when I paint...
     
  35. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    I have just recorded and uploaded a quick video which demonstrates the creation of an oriented brush using the provided demonstration assets:


    I hope that this helps you to better understand how this works.

    Please let me know if you need further help and I will do my best to assist :)
     
  36. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Wow! What I was doing is creating separate tiles instead of just one tile then adding as much orientations as I needed. Perfect Thanks!
     
    Last edited: Apr 25, 2013
  37. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Question: So when does the material mapper come into play, because in your video, you seem to have the material on the object already?

    Is it bad to delete the brushes that came with RTS?
     
    Last edited: Apr 25, 2013
  38. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Each tile is a prefab which will thus already have materials applied.

    The material mapper allows you to get extra mileage out of a single selection of prefabs. Let's use the prefabs from the video for example. If we wanted to create a second brush which uses a different material, then we would simply create an alias (or duplicate) of the "Stone Platform" brush and then add a material mapping to re-map the existing materials with alternative ones. The source materials are automatically detected upon clicking the add mapping button (though these can be customised if needed).

    The benefit of material mappings is that you only need to define one selection of prefabs (as opposed to duplicating them for each material).

    That is absolutely fine. In fact you can delete the demonstration directory altogether. Just make sure that you delete it using the Unity project browser (as opposed to Windows Explorer or OSX Finder). Then deselect the demo folder when importing future versions of the asset.

    You may need to select RTS | Tools | Rescan Brushes after doing this.
     
    Last edited: Apr 25, 2013
  39. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Thanks.

    Sorry for the constant questions. I have a slight problem. My tile previews for oriented tile are either not showing or have old previews. Is there a way to fix this?
     
  40. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    There are two ways to fix this:

    For a single brush:
    Force regeneration of preview by clicking the "Add material mapping" button and then simply removing the mapping again.

    For all brushes (or just because it's easier :p)
    • Delete the folder "{Project Path}/Assets/TileBrushes/Editor/Preview"
    • Select RTS | Tools | Rescan Brushes.
     
  41. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Nope, still having the same problem:
    $RTS_Previewproblem1.png
     
  42. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Are you using source control (or asset server) by any chance?
     
  43. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Orientation seems to have a problem too, take a look at pic:
    $RTS_OrientationProb1.png
    I am either doing something wrong, or based on the brush cursor, the status panel shouldn't be saying all green if there are 2 empty tiles positions on the right side of the brush cursor, which means it should be using a different orientation tile...

    No.
     
    Last edited: Apr 25, 2013
  44. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    Thanks alot numbercrucher. Restarting Unity helps with the preview problem. Might be good to add to the troubleshooting docs?

    Also the orientation problem was solved by understanding more about the panel plus that it means I needed to add more orientation types (I'm going to need a lot for all the different orienation situations since I have losts of diagonal tiles).

    jrDev.
     
  45. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    The following video demonstrates how to create a brush for the BITGEM dungeon assets:

    The brush in the video is painting the floor area, so the wall corners are inverted.
     
  46. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    This asset looks great. For my usage I would need to create chunks of levels (say 50 square Unity units), save them to a prefab, and then load them as needed during runtime. Would I have any problems doing that with this setup?
     
  47. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    That should be fine, though I would recommend using a pooling system to avoid instantiating and destroying your separate 'modules' during game play. This will help to avoid the performance spikes associated with creating and destroying prefabs on a frequent basis.

    I would also recommend building optimised prefabs for your tile systems rather than simply saving them as prefabs. Whether or not you choose to do this will depend very much upon what you are aiming for though.
     
  48. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Hi NumberKruncher,

    Learning more about Rotorz and it's getting more and more amazing.

    I have some questions that relate to the Runtime API :

    1. Is it possible to create alias brush in game.
    2. Swap Brush materials
    3. Use case, I would like for the user to select from a palette of brushes and materials like inside the editor and paint on the tile system.


    Thanks.
     
  49. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Hi rocki

    Yes this is possible, take a look at the following example:
    Code (csharp):
    1.  
    2. // Create shiny new alias brush.
    3. AliasBrush newBrush = ScriptableObject.CreateInstance<AliasBrush>();
    4. // Point alias brush at another brush, though you must not target another alias brush!
    5. newBrush.target = yourOtherBrush;
    6. newBrush.RevertToTarget();
    7.  
    To remap materials you will need to specify the `from` and `to` materials using the following two properties of the alias brush:
    Yes this would work well since material mapping occurs when tiles are painted and so the mapping is not lost (unless you refresh the tiles of course).

    I hope that this helps :)
     
  50. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    Yep I use a pooling solution to avoid the issues with instantiate. What do you mean by optimized prefabs? My game's levels have interchangeable sections that change based upon a variety of conditions so when the level loads I check those conditions and then load in the appropriate sections.

    Right now the whole thing is composed of cube primitives (so no actual prefabs I just change the way I instantiate the cubes in those sections) but as we've gotten out of the prototype stage I'm ready to switch to actual 3D tiles and have some models ready to go.