void AnimateTexture() { float pixelSize = 1f / resolution; if (animateTexture) { currentTextureAnimT += Time.deltaTime * textureAnimSpeed; } int texI = Mathf.Min(texture.width * texture.height - 1, (int)currentTextureAnimT); if (!Application.isPlaying || !animateTexture) { texI = resolution * resolution; } if (showClosestPoint || Application.isPlaying && animateTexture) { float y = (int)(texI / (float)resolution); float x = texI % resolution; var samplePos = new Vector2(x, y) / resolution + Vector2.one * pixelSize / 2; if (!Application.isPlaying) { y = (int)(sampleIndex / (float)resolution); x = sampleIndex % resolution; samplePos = new Vector2(x, y) / resolution + Vector2.one * pixelSize / 2; } if (!makeTile) { float minSqrDst = 1; Vector2 nearestPos = Vector2.zero; for (int i = 0; i < points.Length; i++) { float s = (samplePos - points[i]).sqrMagnitude; if (s < minSqrDst) { minSqrDst = s; nearestPos = points[i]; } } Vis.DrawSphere(samplePos, sampleRadius / 20f, sampleCol, Style.Unlit); Vis.DrawLine(samplePos, nearestPos, lineWidth / 10, lineCol, Style.Unlit); } } Color[] cols = new Color[resolution * resolution]; for (int i = 0; i < texI; i++) { cols[i] = new Color(values[i], values[i], values[i]); } texture.SetPixels(cols); }