// Update is called once per frame void Update() { if (!m_spawned) // TODO there is probably a better way to do init { m_visibility = m_tileMap.EnableVisibility(); UpdateVision(); m_spawned = true; } }
// Update is called once per frame void Update() { if (!m_spawned) // TODO there is probably a better way to do init { m_visibility = m_tileMap.EnableVisibility(); UpdateVision(); m_spawned = true; } }
// TODO this method can currently only be called from code, would be nice with gui checkbox // TODO returning the behiaviour like this doesnt feel pretty public TileMapVisibilityBehaviour EnableVisibility() { //if (m_visibility != null) // throw new InvalidOperationException("Visibility already enabled"); if (m_visibility == null) { var gameObject = new GameObject("TileMapVisibility", typeof(TileMapVisibilityBehaviour)); gameObject.transform.parent = transform; gameObject.transform.localRotation = Quaternion.identity; gameObject.transform.localPosition = new Vector3(0, -2f, transform.position.z - 1f); // place above tilemap gameObject.transform.localScale = Vector3.one; m_visibility = gameObject.GetComponent <TileMapVisibilityBehaviour>(); } return(m_visibility); }