//============================================================================================================ // public function //============================================================================================================ public Tex2DCanvas(Texture2D tex) { _tex = tex; _texRawData = _tex.GetRawTextureData(); _pixelByteCount = CanvasUtil.GetTextureFormatByteCount(_tex.format); _cells = new CanvasCell[_tex.width * _tex.height]; for (int x = 0; x < _tex.width; x++) { for (int y = 0; y < _tex.height; y++) { CanvasCell cell = CanvasCell.Create(this, x, y); _cells[y * _tex.width + x] = cell; cell.Init(); // test cell.SetDefaultData(); } } // test Flush(); }
public CanvasCell GetNeighborCell(CanvasCell centerCell, uint neighborID) { CanvasCell neighborCell = GetCellByPos(centerCell.position + CanvasUtil.GetDirByNeighborID(neighborID)); if (neighborCell == null) { return(CanvasCell.Universal); } return(neighborCell); }
public static CanvasCell Create(Tex2DCanvas owner, int x, int y) { CanvasCell cell = new CanvasCell(); cell.owner = owner; cell.x = x; cell.y = y; cell.dirty = true; return(cell); }
public void Flush() { for (int i = 0; i < _cells.Length; i++) { CanvasCell cell = _cells[i]; if (cell.dirty) { cell.UpdateData(); } } UpdateData(); }
private void DrawTextureAtPos(Vector2Int pos) { //Debug.Log("DrawTextureAtPos! pos = " + pos); CanvasCell cell = _Canvas.GetCellByPos(pos.x, pos.y); cell.data0 = 0b_1010_1010; cell.data1 = 0b_0010_0001; cell.data2 = 0b_0100_0011; cell.data3 = 0b_0000_0000; cell.dirty = true; _Canvas.Flush(); }