Пример #1
0
        public static void SetHairTypeParam(Material material, SkinParam param)
        {
            if (material.HasProperty("_Color"))
            {
                material.SetColor("_Color", param.MainColor);
            }
            else
            {
                Logger.ErrorFormat("type:{0}, do not has property:{1}", (ShaderType)param.Type, "_MainColor");
            }

            if (material.HasProperty("_SpecularColor"))
            {
                material.SetColor("_SpecularColor", param.SpecularColor);
            }
            else
            {
                Logger.ErrorFormat("type:{0}, do not has property:{1}", (ShaderType)param.Type, "_SpecularColor");
            }

            if (material.HasProperty("_SpecularColor2"))
            {
                material.SetColor("_SpecularColor2", param.SecondarySpecularColor);
            }
            else
            {
                Logger.ErrorFormat("type:{0}, do not has property:{1}", (ShaderType)param.Type, "_SecondarySpecularColor");
            }
        }
Пример #2
0
        public static void SetParam(Material material, SkinParam param)
        {
            switch ((ShaderType)param.Type)
            {
            case ShaderType.HairType:
                SetHairTypeParam(material, param);
                break;

            case ShaderType.EndOfWorld:
                Logger.ErrorFormat("un support type");
                break;

            default:
                Logger.ErrorFormat("un support type");
                break;
            }
        }
        public override void ParseConfig(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                Logger.Error("AvatarSkinConfig config xml is empty !");
                return;
            }
            _configs.Clear();
            var cfg = XmlConfigParser <AvatarSkinConfig> .Load(xml);

            if (null == cfg)
            {
                Logger.ErrorFormat("AvatarSkinConfig config is illegal content : {0}", xml);
                return;
            }

            foreach (var item in cfg.Items)
            {
                if (!_configs.ContainsKey(item.TintId))
                {
                    _configs.Add(item.TintId, new Dictionary <int, SkinParam>());
                }

                var dict = _configs[item.TintId];

                if (!dict.ContainsKey(item.SourceId))
                {
                    var skinParam = new SkinParam()
                    {
                        Type                   = item.Type,
                        MainColor              = ArrayToColor32(item.MainColor),
                        SpecularColor          = ArrayToColor32(item.SpecularColor),
                        SecondarySpecularColor = ArrayToColor32(item.SecondarySpecularColor)
                    };
                    dict.Add(item.SourceId, skinParam);
                }
                else
                {
                    Logger.ErrorFormat("SourceId:{0} is already exist", item.SourceId);
                }
            }
        }
        public SkinParam GetSkinConfigById(int skindId, int sourceId)
        {
            SkinParam ret = null;
            Dictionary <int, SkinParam> data;

            _configs.TryGetValue(skindId, out data);
            if (data == null)
            {
                Logger.WarnFormat("skindId:{0} is not exist in AvatarSkinConfig", skindId);
            }
            else
            {
                data.TryGetValue(sourceId, out ret);
                if (ret == null)
                {
                    Logger.WarnFormat("skindId:{0}, sourceId:{1} is not exist in AvatarSkinConfig", skindId, sourceId);
                }
            }

            return(ret);
        }