The recent adding of the Tilemap in Unity has made me very happy and I’m trying to use it. It seems that they also added a new thing called Vector3Int. Basically the same as Vector3, but it uses integers. Now the only way to get a tilemap into a script is by using Vector3Int name; And I kinda need floats. There is the Vector3Int.Vector3 operator, which should convert the Vector3Int into a normal Vector3, but I’m not sure what to do to make it work. It says it’s an operator so it needs to be used in an if statement for example, right? Doing this doesn’t work:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
public class tryOutTileMap : MonoBehaviour {
public Tilemap Test;
public Vector3Int.Vector3 tileMapSize;
public Vector3 cellSize;
void Start () {
tileMapSize.x = 10f;
tileMapSize.y = 10f;
cellSize.x = 1;
cellSize.y = 1;
}
Thanks for your suggestion, although it seems, yet again not to be working:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
public class tryOutTileMap : MonoBehaviour {
public Tilemap Test;
Vector3Int vi = Vector3Int.one;
Vector3 tileMapSize = vi;
public Vector3 cellSize;
void Start () {
tileMapSize.x = 10f;
tileMapSize.y = 10f;
cellSize.x = 1;
cellSize.y = 1;
}
// Update is called once per frame
void Update () {
Debug.Log (cellSize.y + cellSize.x);
}
}
Error: Assets/tryOutTileMap.cs(11,24): error CS0236: A field initializer cannot reference the nonstatic field, method, or property `tryOutTileMap.vi’