void UpdateRemote() { if (this.messageQueue.Has) { DrawingSyncUpData data = this.messageQueue.Get(); Drwaing.SetPixelsInArea(data.x, data.y, data.lengthX, data.lengthY, this.TextureCanvas, data.pixels); } }
void PrepareToSync(Vector3 currentPosition) { int[] pos = this.GetUpdatedArea(currentPosition); Color[] pixels = Drwaing.GetPixelsInArea(pos [0], pos [1], pos [2], pos [3], this.TextureCanvas); DrawingSyncUpData data = new DrawingSyncUpData(); data.x = pos [0]; data.y = pos [1]; data.lengthX = pos [2]; data.lengthY = pos [3]; data.pixels = pixels; //Todo: sync up data with remote }
void PenMove(Vector3 touchPoint) { this.dragPoint = touchPoint; Vector3 diff = this.dragPoint - this.dragPrePoint; if (Mathf.Abs(diff.x) > 1 || Mathf.Abs(diff.y) > 1) { if (this.CurrentTool == Tool.Brush) { Debug.LogWarning("use the pen"); Drwaing.DrawLine(this.dragPoint, this.dragPrePoint, BrushSetting.Width, CurrentColor, BrushSetting.Hardness, this.TextureCanvas); } else { Debug.LogWarning("use the erase"); Drwaing.DrawLine(this.dragPoint, this.dragPrePoint, EraserSetting.Width, Color.white, EraserSetting.Hardness, this.TextureCanvas); } this.dragPrePoint = this.dragPoint; this.PrepareToSync(this.dragPoint); } }