Search Unity

Grids Pro: A library for hex, tri, polar and rect grids [New Dcoumentation for Grids 2]

Discussion in 'Assets and Asset Store' started by Herman-Tulleken, Jul 10, 2013.

  1. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    Cool great thanks!

    It's an interesting problem. Does the changes you made make the algorithm fast enough for your desired size? If not, another scheme may be more efficient.
     
  2. Unib0t

    Unib0t

    Joined:
    Jan 4, 2013
    Posts:
    15
    Hi Herman,

    It's probably easier to visualize with images.

    This is the default rectangle:
    rectangle.png

    This is what I need:
    mine.png

    The fat and thin rectangles aren't suitable as they vary the number of cells in the alternating columns:
    fat.png
    thin.png
     
  3. delinx32

    delinx32

    Joined:
    Apr 20, 2012
    Posts:
    417
    Yes, its quite fast now.
     
  4. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    OK I see. In code, you could use a Union of a thin and slightly smaller fat rectangle, something like this:

    Code (csharp):
    1.  
    2. var grid = FlatHexGrid<SpriteCell>
    3.    .BeginShape()
    4.       .ThinRectangle(width, height)
    5.       .Union()
    6.       .FatRectangle(width, height - 1)
    7.    .EndShape();
    8.  
    If you use the grid builders, you can still use that as explained here:

    http://gamelogic.co.za/grids/docume...k-start-tutorial/making-your-own-grid-shapes/

    Let me know if this does the trick.
     
  5. Unib0t

    Unib0t

    Joined:
    Jan 4, 2013
    Posts:
    15
    Thanks Herman; just to be clear, when I create a composite via a union, is the resulting grid then treated essentially the same as a standard grid (i.e. no duplicate cells or unnecessary extra allocations etc.)?
     
  6. barjed

    barjed

    Joined:
    May 9, 2013
    Posts:
    70
    Sorry Herman, but we tried really hard to implement this and I think we're missing something.

    Let's say, a character moves from cell A to cell B. Along this line of movement we want him to respect the perspective he's in. I am not sure how to raycast situation like this to preserve the correct path of movement.

    I asked a question on this matter some time ago on gamedev and got no conclusive answers. It's here - http://gamedev.stackexchange.com/questions/91898/3d-models-on-2d-background-perspective-mismatch It might, perhaps, help to illustrate the situation we're in.

    Thanks!
     
  7. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    Yup indeed, it's just a grid with a slightly more complicated Contains test. So no duplicated cells (or redundant memory usage).
     
  8. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    Hmmm this is tricky.

    I guess you are having problems with correctly placing objects rendered by the other camera. Is this correct?

    So let's see... the map will convert a grid coordinate to 3D coordinate, which will be in the same plane as your grid. So somehow, you need to convert this information to a 3D coordinate that keeps it in the same screenposition as viewed from the other camera, but with the correct depth so that you can have perspective taken into account. Does this sound right so far?

    So to be clear, the visual effect will be that objects are smaller when further away, but there are actually no real perspective lines, as the grid is not rendered in perspective. Is this correct?

    Then, all you have to do is calculate how far the cell is "supposed to be" from the camera, and use this to adjust the depth as seen from the other camera. Does this make sense?
     
    Last edited: Feb 10, 2015
  9. barjed

    barjed

    Joined:
    May 9, 2013
    Posts:
    70
    Both cameras are orthographic, so there is no perspective at all. The general problem is that the position mismatch differs depending on the position of the 3D characters on the screen. This is because, I guess, the coordinate systems of those two cameras are not parallel to each other (if a characters moves in it's own XY, in the grid's camera it's moving in all three axes, because of the camera's rotation).

    So, I think, you are correct. When character A moves to a cell, he's moving towards or away from the camera, in addition to the XY movement, which leads to some odd behaviour.

    But yes, the general idea is correct - 3D objects viewed by the other camera have incorrect positions (they do not stay on the grid).
     
  10. wx3labs

    wx3labs

    Joined:
    Apr 5, 2014
    Posts:
    77
    I'm trying to get the cells that are X distance neighbors of a PointyHexPoint on a Hex Grid (similar to GetNeighbors, but with a distance).

    Here's what I'm trying:

    PointyHexGrid<TileCell> grid = (PointyHexGrid<TileCell>) Grid;
    foreach (PointyHexPoint neighborPoint in grid.GetSpiralIterator(cell.gridCoord, dist))
    { ... some code to add the points to a list..}

    But it seems to be returning cells about 0,0 regardless of the supplied cell. Am I doing something wrong?
     
  11. Polywick-Studio

    Polywick-Studio

    Joined:
    Aug 13, 2014
    Posts:
    307
  12. Polywick-Studio

    Polywick-Studio

    Joined:
    Aug 13, 2014
    Posts:
    307
    Try doing a foreach loop and for each PointyHexGrid do a GetNeightbour(...) to get the cells around it.
     
  13. Polywick-Studio

    Polywick-Studio

    Joined:
    Aug 13, 2014
    Posts:
    307
    Vendor replied - How to tell if two points are on a straight line:

    Code (CSharp):
    1.  
    2.         private List<FlatHexPoint> GetLine(FlatHexPoint p1, FlatHexPoint p2) {
    3.             int distance = p1.DistanceFrom(p2);
    4.  
    5.             var line = new List<FlatHexPoint>();
    6.  
    7.             if (distance == 0) {
    8.                 line.Add(p1);
    9.  
    10.                 return line;
    11.             }
    12.  
    13.             for (int i = 0; i <= distance; i++) {
    14.                 var t = i/(float) distance;
    15.                 var point = gridBuilder.Map[gridBuilder.Map[p1]*(1 - t) + gridBuilder.Map[p2]*t];
    16.                     //It's almost surely possible to optimize this line if necessary
    17.                 line.Add(point);
    18.             }
    19.             return line;
    20.         }
    21.  
    22.         public void CheckStraght(FlatHexPoint startNode, FlatHexPoint endNode) {
    23.             var line = GetLine(startNode, endNode);
    24.  
    25.             foreach (var point in gridBuilder.Grid) {
    26.                 gridBuilder.Grid[point].Color = line.Contains(point)
    27.                     ? GridBuilderUtils.DefaultColors[2]
    28.                     : GridBuilderUtils.DefaultColors[0];
    29.  
    30.                 int iStraight = 0;
    31.                 if (startNode.X == endNode.X) iStraight++;
    32.                 if (startNode.Y == endNode.Y) iStraight++; //
    33.                  if (startNode.Z == endNode.Z) iStraight++; // (equivalent to p1.X + p1.Y == p2.X + p2.Y)
    34. //
    35.  
    36.                  if (iStraight >= 2) {
    37.                      // Is a straight line
    38.                  }
    39.  
    40.  
    41.                 /*
    42.                     This part is necessary because SpriteCells
    43.                     highlight by default when clicked.
    44.                 */
    45.                 var cell = gridBuilder.Grid[point] as SpriteCell;
    46.                 if (cell != null) {
    47.                     cell.HighlightOn = false;
    48.                 }
    49.             }
    50.         }
    51.  
    Two points p1, p2 are in an axis-aligened straight line if any of the following is true:

    p1.X == p2.X
    p1.Y == p2.Y
    p1.Z == p2.Z (equivalent to p1.X + p1.Y == p2.X + p2.Y)


    You can also check out this for more such:
    http://devmag.org.za/2013/08/31/geometry-with-hex-coordinates/
     
  14. wx3labs

    wx3labs

    Joined:
    Apr 5, 2014
    Posts:
    77
    Thanks for the response but that's going to be inefficient (especially at distances larger than 2), because most cells will be added several times so I'd need to keep track of every cell added and check that it isn't re-added.

    Also it seems like GetSpiralIterator should be doing what I'm looking for and I'm curious as to why it isn't.
     
  15. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    What you do seems correct. (Just to eliminate as a potential issue) did you confirm that cell.gridCoord is always correct?

    Another way to get points a distance d away from some cell is to use the following:

    Code (csharp):
    1. var ringOfPoints = grid.Select(p=>p.distanceFrom(center) == d);
    2. var diskOfPoints = grid.Select(p=>p.distanceFrom(center) <= d);
    Also, another shortcut to get all points from the iterator into a list:
    Code (csharp):
    1. var points = grid.GetSpiralIterator(center, ringCount).ToList();
     
  16. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    Why don't you simply use the other camera for conversion then? Will this not solve the problem?
     
  17. wx3labs

    wx3labs

    Joined:
    Apr 5, 2014
    Posts:
    77
    Yes, the gridCoord seems correct. I looked at the source for GetSpiralIterator and it looks like the origin is getting overwritten with 0,0 after the first yield.

    Regarding your suggestion, Unity complains that PointyHexGrid doesn't have definition for Select (I'm calling it on the grid object cast from Grid as in my example). Am I calling it on the wrong object?

    public IEnumerable<PointyHexPoint> GetSpiralIterator(PointyHexPoint origin, int ringCount)
    {
    var hexPoint = origin;
    yield return hexPoint;

    for (var k = 1; k < ringCount; k++)
    {
    hexPoint = new PointyHexPoint(0, 0);
    hexPoint = hexPoint + HexDirections[4] * (k);

    for (var i = 0; i < 6; i++)
    {
    for (var j = 0; j < k; j++)
    {
    if (Contains(hexPoint))
    {
    yield return hexPoint;
    }

    hexPoint = hexPoint + HexDirections;
    }
    }
    }
    }
     
    Last edited: Feb 19, 2015
  18. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    Hmmm strange; I will see if I can replicate the issue.

    As for Select, its defined as extensions in the System.Linq namespace, so just add

    Code (csharp):
    1. using System.Linq;
    to the other using statements.
     
  19. wx3labs

    wx3labs

    Joined:
    Apr 5, 2014
    Posts:
    77
    After some further investigation, I think there's a bug in the GetSpiralIterator method of HexPoint:

    Line 59 is:

    hexPoint =new PointyHexPoint(0, 0);

    but it should be:

    hexPoint = origin;

    It looks like that line is left over from a previous version that just handled the 0,0 case.
     
  20. wx3labs

    wx3labs

    Joined:
    Apr 5, 2014
    Posts:
    77
    How would I go about creating a custom grid from data? E.g., I want a custom grid maker that can take an array of points and turn it into a grid.
     
  21. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    Thanks for spotting this; we will submit a fix in the next update!
     
  22. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    For code, there are a few ways you can go about this, and the best way depends on a few things. Probably the easiest way would be to use a fixed grid (such as a grid in a rectangle shape), and use cell properties (defined in your own cell type) to manage whether cells "exist" or not. This is a fair approach if the grid is relatively dense, and the size is typically in a constant range. Here is more in defining your own cells: http://gamelogic.co.za/grids/documentation-contents/quick-start-tutorial/making-your-own-cells/

    (This method is not so useful if you need to write a lot of code involving neighbors).

    Grids support constructors that can take storage dimensions, an offset, and a test function. When your grid is relatively sparse, you may want to use this constructors to get a grid. Calculating storage dimensions and an offset is a little bit tricky (you should calculate the smallest parallelogram that will contain the list of points. The dimensions is from this parallelogram, and the offset is the bottom left corner). The test function is any function that gives true of the point is in this grid. You may load your points into a HashSet to use for this function to make it efficient (for small grids, a list should be fine).

    You can use both these methods with editor grids too. In the first case, you will define a GridBehaviour that will switch cells on / off in the OnInit method. See here for more on using GridBehaviours here: http://gamelogic.co.za/grids/docume...k-start-tutorial/working-with-gridbehaviours/

    For the second method, you can define your own shape as explained above and then use that shape as explained here: http://gamelogic.co.za/grids/docume...k-start-tutorial/making-your-own-grid-shapes/


    Let me know if either of these suits your needs.
     
  23. Unib0t

    Unib0t

    Joined:
    Jan 4, 2013
    Posts:
    15
    I'm encountering a Tile Grid Builder error in a brand new test project with Grids Basic 1.10.1, Unity 4.6.3f1

    To replicate:

    1) Add a Rect Tile Grid Builder to the scene
    2) Add a Rect Sprite Cell prefab to the scene (from Gamelogic prefab directory)
    3) Add the Rect Sprite Cell as the Cell Prefab for the Rect Grid Builder
    4) Press Build Grid

    Result:
    NullReferenceException: Object reference not set to an instance of an object
    Gamelogic.Grids.TileGridBuilder`1[Gamelogic.Grids.RectPoint].SetupGrid () (at Assets/Gamelogic/Plugins/Grids/Unity/EditorSupport/GridBuilders/TileGridBuilder.cs:332)
    Gamelogic.Grids.TileGridBuilder`1[Gamelogic.Grids.RectPoint].__UpdatePresentation (Boolean forceUpdate) (at Assets/Gamelogic/Plugins/Grids/Unity/EditorSupport/GridBuilders/TileGridBuilder.cs:290)
    Gamelogic.Grids.Editor.Internal.SimpleGridEditor`2[Gamelogic.Grids.RectTileGridBuilder,Gamelogic.Grids.RectPoint].OnInspectorGUI () (at Assets/Gamelogic/Plugins/Grids/Unity/Editor/Editors/SimpleGridEditor.cs:96)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean forceDirty, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect, Boolean eyeDropperDirty)
    UnityEditor.DockArea:OnGUI()
     
  24. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    Thanks for reporting this.

    You can fix this by adding the prefab straight as the Cell Prefab for the grid builder, instead of adding an instance.

    Do you require the ability to use scene objects as cells instead of prefabs? I ask this out of interest, we will fix the problem regardless.

    If you do, and need the fix urgently, find the Instantiate method at the bottom of the GridBuilderUtils file, and replace it with this:

    Code (csharp):
    1.  
    2.         public static T Instantiate<T>(T prefab)
    3.             where T : MonoBehaviour
    4.         {
    5.             T instance = null;
    6.             if (Application.isPlaying)
    7.             {
    8.                 instance = (T) Object.Instantiate(prefab);
    9.             }
    10. #if UNITY_EDITOR
    11.             else
    12.             {
    13.                 var prefabType = PrefabUtility.GetPrefabType(prefab);
    14.  
    15.                 if (prefabType == PrefabType.Prefab)
    16.                 {
    17.                     instance = (T) PrefabUtility.InstantiatePrefab(prefab);
    18.                 }
    19.                 else
    20.                 {
    21.                     instance = (T) Object.Instantiate(prefab);
    22.                 }
    23.             }
    24. #endif
    25.             return instance;
    26.         }
    27.  
     
    Last edited: Feb 24, 2015
  25. Polywick-Studio

    Polywick-Studio

    Joined:
    Aug 13, 2014
    Posts:
    307
    Can I make request.

    How do you select 1 line of the spiral iterator?

    i.e., GetSpiralIterator(PointyHexPoint origin, int ringCount, int point)

    // where point = 1..6

    example:

    for (var k = 1; k < 6; k++)
    {
    GetSpiralIteratorLine(PointyHexPoint origin, int ringCount, k)
    }
     
  26. barjed

    barjed

    Joined:
    May 9, 2013
    Posts:
    70
    The grid is seen by a different camera than the characters. Unless there is some magical Unity method that converts a point position based on a camera location, I am unsure about how to do this.

    I mean, if I understand what you're saying - if a grid indicates a cell is at (4,5,0), but in the eye of the 3D camera it's misaligned, then the position of the character standing on that cell should be transformed (to something random like (5,6,1)) so that it matches?

    Moreover, how would this work when a character is moving? Should this transformation be performed on each frame?

    Our current clunky solution is to place the 3D characters flat on the grid's plane and handle the rotation's by ourselves. This is really annoying because there are issues like depth handling, where we have to move the character along Z and etc.
     
    Last edited: Mar 1, 2015
  27. DanW

    DanW

    Joined:
    Nov 4, 2013
    Posts:
    7
    Hi guys... working on a flat hex grid and trying to find a way to find cone shapes from an origin (think spell range of effect) and also include line of sight.
    Do you have any suggestions for determining a cone shape and if so, would I need to iterate all of the cells found to then determine line of sight from the origin or would there be a better way for performance?
     
  28. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    The line of sight is simply the intersection of two half-planes that intersect at the vertex of the cone.

    Let's say the first half-plane is all points that satisfy
    Ax + By + C >= 0

    and the second is all points that satisfy
    Dx + Ey + F <= 0

    Then your cone is

    Code (csharp):
    1. var cone = Grid.Where(p => A * p.X + B * y + C >= 0 && D*p.X + E*p.Y + F <= 0);
    This does iterate over all points, but it should be quite fast enough for reasonably-sized grids.

    You can calculate the coefficients the same way as you do for lines in an ordinary coordinate system. (If you need help with this, please let me know).

    If your grids are very big and the above method is too slow, you will need to either use a more direct method (there is an algorithm described here: http://www.redblobgames.com/grids/hexagons/#field-of-view).

    Let me know if this is enough; otherwise I can give more details.
     
  29. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    Your problem is certainly more complex than the average case. I think I may have lost the plot somewhere, so let me start from scratch.

    There are four basic conversions here
    • (A) grid to world (as seen from grid camera) and (B) back
    • (C) grid to world (as seen from the objects camera) (D) and back.
    A is necessary for pacing the grid in the scene.
    C is necessary to place the characters in the scene.

    B is necessary to handle input (for example, when the player clicks on the grid)
    D is necessary to handle input (for example, when the player clicks on a character)

    So we need two maps for these conversions, map1 for A and B, and map2 for C and D.

    Note that we do not need any more conversions - when a character moves, for example, from one grid point p to another q, we can simply lerp (or whatever) between map2[p] and map2[q].

    As far as I understand, map1 is working fine; we need map2.

    To get it, the simplest way is to setup up a square grid in the editor in the XZ plane (make sure the squares are facing the Y+ direction, they are not by default). You have to align this visually (or if you prefer and are able, mathematically) with the other grid by transforming the grid root of the second grid. You can scale, move or rotate the grid. Once you have the grids neatly aligned, the map of the second grid builder should be useable as map2, provided you interpret all world points relative to the root.

    (To position a game object using map2, you should parent the game object to the second grid root, and then set it's local position.)

    Does this all make sense? If so, try it and let me know if it works.
     
  30. barjed

    barjed

    Joined:
    May 9, 2013
    Posts:
    70
    Okay, so to clarify:

    - one map is of diamondpoint type, in the XY plane (in 2D, it's parallel to the screen)
    - now I need to add a second map of squarepoint type, in the XZ plane (perpendicular to the screen and in horizontal position) with the squares facing Y+ (so up in terms of screen). This grid is seen by the 3D object camera. I add a simple sprite and align this grid visually with the other grid. Once aligned, visuals of this grid can be hidden
    - now for the placement. So far we have placed by simple X,Y coordinates - characters where placed in the cell's center
    - now for the new placement. A 3d character should be parented to the second grid. I want him to be placed on cell (1,2) when looked at the first grid. What should happen here?

    Thanks!
     
  31. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    OK, so you can either simply position the 3D character with it's feet at the cell of the second grid, or directly with the map from that grid builder. (I did not think of the first way yesterday - that is possibly the better way to go).

    So for the first method, something like this (in a GridBehaviour on the second grid):

    Code (csharp):
    1. public void PlaceObject(... obj, RectPoint point)
    2. {
    3.    obj.transform.parent = transform; //remember, this is grid2
    4.    obj.transform.localPosition = Map[point]; //and this is map2
    5. }
    OR the second method
    Code (csharp):
    1. public void PlaceObject(... obj, RectPoint point)
    2. {
    3.    obj.transform.parent = transform; //remember, this is grid2
    4.    obj.transform.localPosition = Grid[point].localPosition; //and this is map2
    5. }
    You will of course need a conversion function from DiamondPoint to RectPoint (just use the same X and Y for both).

    Code (csharp):
    1. public static RectPoint ToRect(this DiamondPoint point)
    2. {
    3.    return new RectPoint(point.X, point.Y);
    4. }
    5.  
    The only slightly tricky thing is getting the right shape. I would say use parallelogram shape for both first to get the system going. After that you can figure out the exact shapes.
     
  32. robertwahler

    robertwahler

    Joined:
    Mar 6, 2013
    Posts:
    43
    Replying to my own post since I have not seen anyone else mention a solution. This issue is now resolved for me by turning off the coordinate Gizmo in the editor.
     
  33. Bravo_cr

    Bravo_cr

    Joined:
    Jul 19, 2012
    Posts:
    148
    Hi there,

    In the latest version there are still JIT/AOT compiler problems on iOS, even the included examples doesn't work. Are there any news when this will be fixed?
     
  34. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    Hi Robert, thanks for letting us know!
     
  35. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    The JIT / AOT compiler errors are not problems we an solve globally for all; it has to be solved for each project. If you let me know what you have a problem with, I can post a fix.

    As for the examples, which ones did you try?
     
  36. Bravo_cr

    Bravo_cr

    Joined:
    Jul 19, 2012
    Posts:
    148
    Hi Herman,

    I have tested HexWorld and had AOT errors. But, and this is a really big but, it doesn't even compile when making a build with IL2CPP enable (neither in mono with stripping) which its mandatory. I'm not trying to be rude, but I have the impression that this package hasn't been tested on iOS and it should state in the asset store description that it doesn't work on iOS, or at least that you have to make some really deep changes to make it work.

    Many thanks
     
  37. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    You are not being rude, don't worry :)

    The package does work on iOS; we have tested it and many users have build games on iOS using Grids. It's true, you have to add a few lines of obscure code for it to work, and for us to work around the compiler issues will require some deep changes, including reducing the level of generics used. We have been writing a lot of experimental code to explore these deep changes (for example, we have a version of Grids where all the grid points are the same class, instead of having a point type for each type of Grid).

    I will check out the HexWorld example, thank for letting me know.

    (For your own projects, it is usually a matter of adding a few lines of code to force the compiler to produce the necessary code. If you end up using Grids for a project, we can supply you with the lines very easily).

    I also apologize if you bought Grids and it does not live up to your expectations. We are very happy to provide refunds.
     
  38. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    Now I'm confused. Does Grids Pro require this as well for iOS deployment?
     
  39. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Hi Herman

    I just picked this up in the sale as it looks like a really cool framework and I liked some of the articles on your blog.

    When I import it into a project where I also have uFrame I see this error:

    Assets/uFrameComplete/uFrame/Base/GameManager.cs(18,14): error CS0101: The namespace `global::' already contains a definition for `GameManager'

    ...as uFrame has its own GameManager class.

    So I wondered whether it might be possible to fix it in the future?

    I also wondered that given you have Playmaker support whether you have considered supporting uFrame at all in the future?


    cheers

    Nalin
     
  40. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    Thank you for alerting us. Yes, we will put all the example code in a separate namespace (we did not think anyone will keep the example code in their project, but you are not the only one that asked us this.)
     
  41. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    Yup, unfortunately, it does. It's basically a dummy call that explicitly calls code to force the compiler to create it - the compiler cannot create the right code from a generic call. It's a problem with the compiler. More information:

    http://developer.xamarin.com/guides/ios/advanced_topics/limitations/

    http://gamelogic.co.za/grids/docume...r-generates-code-to-instantiate-grids-on-ios/

    The main reason we cannot put it in by default is that it needs to be done for the specific class that you put in the grid. So if it is your own class, we cannot do it.
     
    OnePxl likes this.
  42. Jonathan-Bailey

    Jonathan-Bailey

    Joined:
    Aug 12, 2013
    Posts:
    79
    DMeville, c-Row and Braza like this.
  43. Braza

    Braza

    Joined:
    Oct 11, 2013
    Posts:
    136
    Hi!
    I've imported the asset and from the very beginning have:
    Assets/Gamelogic/Examples/Grids/Scripts/AdvancedSetup/PolarFlatBrickGridMain.cs(47,35): error CS0117: `MeshUtils' does not contain a definition for `MakeBandedSector'

    and

    Assets/Gamelogic/Plugins/Common/Extensions/GLMonoBehaviour.cs(178,49): error CS1061: Type `Action' does not contain a definition for `Method' and no extension method `Method' of type `Action' could be found (are you missing a using directive or an assembly reference?)

    and

    Assets/Gamelogic/Plugins/Common/Extensions/GLMonoBehaviour.cs(178,35): error CS1928: Type `UnityEngine.MonoBehaviour' does not contain a member `Invoke' and the best extension method overload `Gamelogic.MonoBehaviourExtensions.Invoke(this UnityEngine.MonoBehaviour, Action, float)' has some invalid arguments

    and

    Assets/Gamelogic/Plugins/Common/Extensions/GLMonoBehaviour.cs(178,35): error CS1503: Argument `#2' cannot convert `object' expression to type `Action'
     
  44. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    In the examples it looks like this can generate a Voronoi map from a set of points; is that correct? If so, do you use Fortune's algorithm?
     
  45. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Hi Herman

    When I set the XZ Orientation I see the attached picture. I would have expected the orientation of the cells to change as well to align the old Y axis with the new Z axis but it does not seem to.

    Is this possible at all as it looks a bit odd?

    thanks

    Nalin

    XZ Orientation Grid.png
     
  46. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    Hmmm I cannot replicate the error on our side.
    • What version of Unity are you using? We have ben testing with Unity 4 (latest) and Unity 5 a few weeks old (trying to download the newest Unity today after their big announcement seems impossible where we are at - it may be a small issue with the very latest Unity 5).
    • Did you try importing Grids into a clean project? If that works, then there is possibly a name collision with existing code.
     
  47. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    We do not create a Voronoi map in the traditional sense (a vertex graph, essentially). We use the Voronoi map to split space so that we can access the right cell, so we don't need all the extra information. So under the hood we have a different algorithm and data structure. Is this something you are interested in using?
     
  48. Braza

    Braza

    Joined:
    Oct 11, 2013
    Posts:
    136
    Un
    Huh, works for clear project. Thanks!
     
  49. Herman-Tulleken

    Herman-Tulleken

    Joined:
    Nov 20, 2009
    Posts:
    358
    The thing is, Grids are not "aware" of the orientation of cells, so you have to sort that out. (This is so to allow more flexibility in what things you can put in a grid). Simply rotate the child object on the cell prefab to face the right way, and it will work as expected.
     
  50. Jimww

    Jimww

    Joined:
    May 14, 2013
    Posts:
    63
    Are there any readymade uGui prefab examples? I'm trying to convert an existing RectCell prefab to use the UIImageTextCell script and it keeps crashing Unity every time I try to build the grid. I just bought this, so I'll probably figure it out.., but it seems an existing demo scene showing off uGui integration would be useful.