/// <summary> /// Get the grid parent. /// Use the transform hierarchy to get the parent. /// </summary> /// <returns>The grid parent if the parent transform exist and have Grid3D component, otherwise null.</returns> public Grid3D GetGridParent() { Transform parent = transform.parent; if (_parent == null && parent != null) { _parent = parent.GetComponent <Grid3D>(); } return(_parent); }
/// <summary> /// Init the cell position, rotation and the index of the cell. /// Use only in inspector or grid, otherwise it can cause undesirable behaviour. /// </summary> /// <param name="gridIndex">The index of the cell set.</param> /// <param name="parent">The Grid3d it belongs.</param> public void Initialize(Vector3Int gridIndex, Grid3D parent) { _parent = parent; _grid_index = gridIndex; }