Пример #1
0
    public Material this[UIDrawCall.Clipping clipping]
    {
        get
        {
            ClippingFlags flags = (ClippingFlags)(((int)1) << clipping);
            if ((flags & this.madeMats) != flags)
            {
                return(this.MakeMaterial(clipping));
            }
            switch (clipping)
            {
            case UIDrawCall.Clipping.None:
                return(this.matNone);

            case UIDrawCall.Clipping.HardClip:
                return(this.matHardClip);

            case UIDrawCall.Clipping.AlphaClip:
                return(this.matAlphaClip);

            case UIDrawCall.Clipping.SoftClip:
                return(this.matSoftClip);
            }
            throw new NotImplementedException();
        }
    }
Пример #2
0
    private Material MakeMaterial(UIDrawCall.Clipping clipping)
    {
        Material material;
        Material matNone;
        Shader   clippingShader;
        bool     flag = this.madeMats == ((ClippingFlags)0);

        switch (clipping)
        {
        case UIDrawCall.Clipping.None:
            clippingShader = this.key.shader;
            matNone        = this.matNone;
            material       = this.matNone = CreateMaterial(clippingShader);
            this.madeMats |= ClippingFlags.None;
            break;

        case UIDrawCall.Clipping.HardClip:
            clippingShader = GetClippingShader(this.key.shader, UIDrawCall.Clipping.HardClip);
            matNone        = this.matHardClip;
            material       = this.matHardClip = CreateMaterial(clippingShader);
            this.madeMats |= ClippingFlags.HardClip;
            break;

        case UIDrawCall.Clipping.AlphaClip:
            clippingShader = GetClippingShader(this.key.shader, UIDrawCall.Clipping.AlphaClip);
            matNone        = this.matAlphaClip;
            material       = this.matAlphaClip = CreateMaterial(clippingShader);
            this.madeMats |= ClippingFlags.AlphaClip;
            break;

        case UIDrawCall.Clipping.SoftClip:
            clippingShader = GetClippingShader(this.key.shader, UIDrawCall.Clipping.SoftClip);
            matNone        = this.matSoftClip;
            material       = this.matSoftClip = CreateMaterial(clippingShader);
            this.madeMats |= ClippingFlags.SoftClip;
            break;

        default:
            throw new NotImplementedException();
        }
        g.generatedMaterials.Add(material, this);
        if (flag)
        {
            this.matFirst = material;
            material.CopyPropertiesFromMaterial(this.key);
        }
        else
        {
            material.CopyPropertiesFromMaterial(this.matFirst);
        }
        if (matNone != null)
        {
            Object.DestroyImmediate(matNone);
        }
        return(material);
    }