示例#1
0
    public Material GetNewMaterial(EShareMatType type = EShareMatType.Normal, string shaderName = "")
    {
        shaderName = string.IsNullOrEmpty(shaderName) ? TypeToShaderName[(int)type] : shaderName;
        Shader shader = Shader.Find(shaderName);

        return(new Material(shader));
    }
示例#2
0
 public string GetShader(EShareMatType type)
 {
     if (TypeToShaderName.ContainsKey((int)type))
     {
         return(TypeToShaderName[(int)type]);
     }
     return("");
 }
    public void SetShaodwShader(ISFSprite sprite, EShareMatType t)
    {
        EShareMatType type = t;

        SFMisc.blackColor.a = type == EShareMatType.Transparent ? 0.3f : 0.5f;
        SFMisc.greyColor.r  = SFMisc.greyColor.g = SFMisc.greyColor.b = SFMisc.greyColor.a = 1;
        EShareMatType blackType = type == EShareMatType.Transparent ? EShareMatType.Balck_Transparent : EShareMatType.Balck;

        sprite.SetShader(SFOut.IGame.getShareMaterial(sprite.getAtlas, blackType), SFMisc.blackColor, SFMisc.greyColor);
    }
示例#4
0
    public Material GetShareMat(UnityEngine.Object obj, EShareMatType type = EShareMatType.Normal, string shaderName = "")
    {
        //return null;
        //if (type == EShareMatType.Balck)
        //{
        //    if (mBlackMat != null) return mBlackMat;
        //    shaderName = !string.IsNullOrEmpty(shaderName) ? shaderName : TypeToShaderName[type];
        //    //Debug.LogError(shaderName);
        //    Shader shader = Shader.Find(shaderName);
        //    mBlackMat = new Material(shader);
        //    mBlackMat.name = "Black";
        //    return mBlackMat;
        //}
        if (type == EShareMatType.Normal)
        {
            SFAtlas atlas = obj as SFAtlas;
            if (atlas != null)
            {
                return(atlas.spriteMaterial);
            }
        }
        if (obj == null)
        {
            return(null);
        }
        int id = obj.GetInstanceID();

        if (!InstanceIDToShareMat.ContainsKey(id))
        {
            InstanceIDToShareMat.Add(id, new List <Material>());
        }
        if ((int)type >= InstanceIDToShareMat[id].Count)
        {
            int count = InstanceIDToShareMat[id].Count;
            for (int i = 0; i <= (int)type - count; i++)
            {
                InstanceIDToShareMat[id].Add(null);
            }
        }
        if (InstanceIDToShareMat[id][(int)type] == null)
        {
            shaderName = !string.IsNullOrEmpty(shaderName) ? shaderName : TypeToShaderName[(int)type];
            //Debug.LogError(shaderName);
            Shader   shader = Shader.Find(shaderName);
            Material mat    = new Material(shader);
            mat.name = TypeToShaderName[(int)type] /*+ "_" + id*/;
            InstanceIDToShareMat[id][(int)type] = mat;
        }
        return(InstanceIDToShareMat[id][(int)type]);
    }
示例#5
0
 public void SetShareMat(EShareMatType type, Material mat, Vector4 color, Vector4 greyColor)
 {
     if (Animation == null)
     {
         return;
     }
     if (type == EShareMatType.Balck || type == EShareMatType.Balck_Transparent)
     {
         if (Animation.ShadowData != null)
         {
             Animation.ShadowData.ShadowSprite.SetShader(mat, color, greyColor);
         }
     }
     else
     {
         Animation.getSprite.SetShader(mat, color, greyColor);
     }
 }