Example #1
0
        private void DrawHandles(Vector3 hitPoint, Bounds targetCellBounds)
        {
            //hit point rectangle
            Handles.color = new Color(1f, 0f, 0f, 0.5f);
            Handles.DrawWireCube(hitPoint, Vector3.one * .1f);

            Handles.Label(hitPoint, TMEditorUtils.WorldToCell(hitPoint, editorSettings.cellSize).ToString());
            //
            // var yZeroPoint = hitPoint;
            // yZeroPoint.y = 0;
            //
            // float3 min = targetCellBounds.min;
            // min.y = 0;
            // float3 max = targetCellBounds.max;
            // max.y = 0;
            // var points = new Vector3[]
            // {
            //    min,
            //    new float3(min.x, 0, max.z),
            //    max,
            //    new float3(max.x, 0, min.z)
            // };
            //
            // Handles.zTest = CompareFunction.LessEqual;
            // Handles.color = new Color(1f, 1f, 1f, 0.25f);
            // Handles.DrawSolidRectangleWithOutline(points, new Color(0f, 0f, 0f, 1f), Color.red);
            //
            // Handles.zTest = CompareFunction.Always;
            // var delta = hitPoint - yZeroPoint;
            // int c = Mathf.FloorToInt(Mathf.Abs(delta.y / tmEditorSettings.cellSize.y)) + 1;
            // //height tick marks
            // for (int i = 0; i < c; i++)
            // {
            //    Handles.DrawWireCube(yZeroPoint + delta.normalized * (i * tmEditorSettings.cellSize.y),
            //       Vector3.one * .1f);
            // }
            //
            // //vertical line from hit point to zero plane
            // Handles.DrawLine(hitPoint, yZeroPoint);
            // Handles.Label(hitPoint + Vector3.up * .2f, $"{_drawHeight:f3}");
            // Handles.DrawLine(Vector3.zero, Vector3.up);
            //
            // //draw the targeted cell bounds
            // Handles.color = new Color(1f, 0f, 0f, 0.18f);
            // //Handles.DrawWireCube(targetCellBounds.center, targetCellBounds.size);
        }
Example #2
0
        private CellData GetCellData(Vector3 hitPoint)
        {
            CellData data = new CellData();

            data.cell             = TMEditorUtils.WorldToCell(hitPoint, editorSettings.cellSize);
            data.worldPosition    = hitPoint;
            data.activeTilePrefab = selectedTilePrefab;
            data.rotation         = activeRotation;
            data.lastCell         = _lastCell;
            data.overlapTiles     = GetOverlappedTiles(hitPoint);

            if (data.overlapTiles.Length > 0)
            {
                data.tile = data.overlapTiles[0];
            }
            return(data);
        }