protected virtual void SetupTexture() { if (GetComponent <SpriteRenderer>().sprite != null) { Texture2D.DestroyImmediate(GetComponent <SpriteRenderer>().sprite.texture); Sprite.DestroyImmediate(GetComponent <SpriteRenderer>().sprite); } texture = PixelToolRP.SetupTexture(texDimensions, texDimensions); offset = texture.width / 2; }
public override void Draw() { int centerX = texture.width / 2; int centerY = texture.height / 2; PixelToolRP.DrawFilledCircle(texture, shadeColor, new Vector2(centerX, centerY), radius); for (int y = -radius; y <= radius; y++) { int x1 = (int)Mathf.Sqrt(radius * radius - y * y); for (int x = -x1; x <= x1; x++) { float n = Random.Range(0, x1) * (2.01f - shadeWidth); if (n > x1 + x) { texture.SetPixel(x + centerX, y + centerY, highlightColor); } } } }
protected void GenerateSprite() { texture = PixelToolRP.ClampTexture(texture); texture.Apply(); GetComponent <SpriteRenderer>().sprite = Sprite.Create(texture, new Rect(new Vector2(0f, 0f), new Vector2(texture.width, texture.height)), new Vector2(0.5f, 0.0f)); }