コード例 #1
0
    /// <summary>
    /// Gets the sprite used for the given type
    /// </summary>
    public static Sprite GetSprite(BlockType type)
    {
        Texture2D texture = GenerateTexture.CreateRandomTexture(GenerateTexture.GetAvailableColors(GenerateTexture.GetPallete(type)), 10, 10);

        return(Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), Mathf.Max(new int[2] {
            texture.height, texture.width
        })));
    }
    // Use this for initialization
    public void Initialize()
    {
        palleteColors = GenerateTexture.GetAvailableColors(color);
        render        = gameObject.GetComponent <SpriteRenderer> ();
        Texture2D texture = GenerateTexture.CreateRandomTexture(palleteColors, textureSize, textureSize);

        render.sprite = Sprite.Create(texture, new Rect(0, 1, texture.width, texture.height), new Vector2(0.5f, 0.5f), Mathf.Max(new int[2] {
            texture.width,
            texture.height
        }));
    }
 public void SetColor(GenerateTexture.PalleteType color)
 {
     this.color    = color;
     palleteColors = GenerateTexture.GetAvailableColors(color);
     render.sprite.texture.SetPixels(GenerateTexture.CreateRandomTexture(palleteColors, textureSize, textureSize).GetPixels());
     render.sprite.texture.Apply();
     if (color == GenerateTexture.PalleteType.sand || color == GenerateTexture.PalleteType.grey)
     {
         flowingTexture = false;
     }
     else
     {
         flowingTexture = true;
     }
 }