Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - copyleft

Pages: [1]
This would be a helpful function for me.

Support / Re: [Grids 2D] Looking for function to set cell as highlighted
« on: January 29, 2021, 06:08:14 AM »
I ended up just rolling out a simple flash myself.

Support / Re: [Grids 2D] Looking for function to set cell as highlighted
« on: January 22, 2021, 09:24:37 AM »
I updated to the latest beta, and I'm seeing the same issues.

The highlight is present, but with no flashing/opacity changes. I wonder if it has to do with the Update calling it so frequently, it just redraws over and over? I have to imagine that there's a similar Update call for the mouseover, and that highlight fades according to the set duration with no problem.

This is the entirety of my Update call, pretty simple (base.Update doesn't touch Grid2D at all, so that should be safe):

    new void Update()

        _grid.highlightMode = HIGHLIGHT_MODE.None;
        _grid.HighlightCellRegion(_selectedCell.index, true);

what it looks like:

CellBlink/CellFlash still show that solid black square. I did some investigation, maybe it has something to do with the transparent material:

I opened the CanvasBackgroundClear unitypackage and tried using that instead, but had the same results, black square.

EDIT: Actually, the material is swapped to Grids 2D System/Canvas Background Transparent once I press Play.

3d view:

I figure if the highlight at least shows in the given color, those similar functions should too.


in the end, these aren't huge issues. I can live with the solid highlight and use solid cell colors instead of Flash/Blink and move on. But, the flashing highlight is very visually appealing. It would also prove useful as HUD indicators on the battle map, like an end-goal cell that you must seize.

Support / Re: [Grids 2D] Looking for function to set cell as highlighted
« on: January 22, 2021, 08:53:51 AM »
Sorry, how do I access the latest beta? Is it through the Asset Store? I'm on version 6.5, publish Jan 19th.

About CellFlash/CellBlink, still no dice after switching to Color32:

video :

        _grid.CellFlash(_selectedCell.index, new Color32(54, 99, 99, 254), 6.567f);

EDIT: I found the sub-forum! Thanks, I'll try it out.

Support / Re: [Grids 2D] Looking for function to set cell as highlighted
« on: January 22, 2021, 01:58:43 AM »
Thanks, this helped. The cell is indeed highlighted, BUT only on mouse hover. Can I somehow detach highlighting from mouse hover? The highlight also doesn't fade in/out, but remains solid. Check the video, you can see both the solid highlight and the mouse cursor's influence.

EDIT AGAIN: I am not sure why, but after a restart, the cell is now highlighted regardless of mouse interaction. The only issue now is the lack of opacity changing and the similar highlight functions only showing solid black color.

Within my Update() call:
        _grid.highlightMode = HIGHLIGHT_MODE.None;
        _grid.HighlightCellRegion(_selectedCell.index, true);

The ideal solution would be for this to work mainly with keyboard/gamepad input, and for the highlight to display indefinitely (until hidden via code).

Also curious, would it be possible to highlight at a different color at runtime? Without changing the highlight color.

I suppose I can use CellFlash(cellIndex, color, duration) or CellBlink(cellIndex, color, duration) to mimic a highlight effect.
EDIT: I tried these, I just get a solid black colored cell.

        _grid.CellBlink(_selectedCell.index, new Color(54, 99, 99), 0.567f);
        _grid.CellFadeOut(_selectedCell.index, new Color(54, 99, 99), 6.567f);
        _grid.CellFlashOut(_selectedCell.index, new Color(54, 99, 99), 6.567f);

        // Tried each one individually.

Which sucks, because I want to be able to do a blinking highlight in different colors to show movement & attack ranges. Rather than a solid color.

Another question, with tgs there was a .CellGetRectWorldSpace method that returns Bounds for a Cell.

In Grids2D, the best I can get is the center position of a given cell.

Is there a way to get Bounds for a cell with Grids2D? Otherwise, I'll have to create my own bounds by doing something like:

The cell size is 32px per cell.

            protected Dictionary<int, Bounds> _cellPositions = new Dictionary<int, Bounds>();

            foreach(Cell cell in _grid.cells) {
                Vector3 position    = _grid.CellGetPosition(cell.index);
                Vector3 boundsSize  = new Vector3(0.32f, 0.32f, 1);

                Bounds cellBounds = new Bounds(position, boundsSize);

                _cellPositions[cell.index] = cellBounds;

EDIT: The above code works fine for my purposes. You'll have to edit this if you want to do something similar, since I can't find a way to dynamically pull the bounds of a Grid2d.Cell... maybe if it had a renderer or something.

Support / Re: [Grids 2D] Looking for function to set cell as highlighted
« on: January 10, 2021, 01:28:09 AM »
One other thing, can I control what sprite layer the grid should be drawn on?

Right now, it's drawing lines over portions of my map that aren't traversable. I thought it was rendering on the Default sprite layer, but even buildings I have set on a higher sprite layer still get drawn over.

You can see it at the foot of the castle in the video.

EDIT: It seems adjusting the camera size fixed it grid rendering. Question still stands though.

Support / [Grids 2D] Looking for function to set cell as highlighted
« on: January 10, 2021, 01:16:51 AM »

I'm working on moving this cursor and highlight across my Grids2D cells.

I am working if there's a way to use the same highlight effect, but on keyboard WASD/arrow movement. Something where I can set a cellIndex as highlighted, and clear the rest.

Support / Having trouble with speed of cell selection
« on: October 19, 2020, 02:32:51 AM »
Adding the keyboard input code:

 IEnumerator UserCellSelection(int lastCellIndex) {
     int cellIndex;
     float waitTime = 20000000f;
     float vertAxis = Input.GetAxis("Vertical");
     float horiAxis = Input.GetAxis("Horizontal");
     if (vertAxis != 0) {
         if (!movingPlayer)
         int newRow;
         if (vertAxis > 0) {
             newRow = SelectedCell.row + 1;
         } else {
             newRow = SelectedCell.row - 1;
         if (newRow < 0)
             newRow = 0;
         cellIndex = tgs.CellGetIndex(newRow, SelectedCell.column);
     if (horiAxis != 0) {
         if (!movingPlayer)
         int newCol;
         if (horiAxis > 0) {
             newCol = SelectedCell.column + 1;
         } else {
             newCol = SelectedCell.column - 1;
         if (newCol < 0) {
             newCol = 0;
         cellIndex = tgs.CellGetIndex(SelectedCell.row, newCol);
         lastCellIndex = SelectedCell.index;
I call this method:

 new void Update()
     // Only check for user input during Player Phase
     if (gameManager.currentPhase == "Player") {
         int lastCellIndex = SelectedCell.index;
         StartCoroutine("UserCellSelection", lastCellIndex);
         if(actionSelect)  // Draw attack range
         if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.X)) {
I tried using WaitForSecondsRealtime, no dice. I wrote this on an older laptop, so the slow FPS was making selection more manageable. I don't want to intentionally limit my FPS, looking for a solution to move one square every 10 seconds, somewhere around there.

I am using Terrain Grid System plugin for the grid. I've basically tied to Horizontal & Vertical Axes to rows and columns in the grid.

Pages: [1]