public static Material getSharedMaterial(string key, Roga2dBlendType blendType)
    {
        int index = (int)blendType;
        if (!materialDictionary[index].ContainsKey(key))
        {
            Material material = null;

            switch (blendType) {
            case Roga2dBlendType.Alpha:
                material = new Material(Roga2dResourceManager.getShader("Custom/TintAlphaBlended"));
                break;
            case Roga2dBlendType.Add:
                material = new Material(Roga2dResourceManager.getShader("Custom/AlphaAdditive"));
                break;
            default:
                Debug.LogError("Invalid BlendType is passed");
                break;
            }

            Texture texture = getTexture(key);
            material.mainTexture = texture;
            materialDictionary[index].Add(key, material);
        }

        return materialDictionary[index][key];
    }
    public void SetBlend(Roga2dBlendType blendType, float alpha, Roga2dHue hue)
    {
        // If nothing has changed, don't do anything
        if (this.blendType == blendType && this.alpha == alpha && this.hue == hue) {
            return;
        }
        this.blendType = blendType;
        this.alpha = alpha;
        this.hue = hue;

        if (this.material != null) {
            Object.Destroy(this.material);
        }

        if (!hue.IsZero() || alpha != 1.0f || this.material != null) {
            this.renderer.material =  Roga2dResourceManager.getSharedMaterial(this.textureID, blendType);
            if (blendType == Roga2dBlendType.Alpha) {
                this.renderer.material.SetColor("_EmisColor", new Color(hue.r / 255.0f + 0.5f, hue.g / 255.0f + 0.5f, hue.b / 255.0f + 0.5f, alpha));
            } else {
                this.renderer.material.SetColor("_Color", new Color(1.0f, 1.0f, 1.0f, alpha));
            }
            this.material = this.renderer.material;
        } else {
            this.renderer.sharedMaterial =  Roga2dResourceManager.getSharedMaterial(this.textureID, blendType);
        }
    }