public static ToVector4 ( string str ) : Vector4 | ||
str | string | |
return | Vector4 |
//test 23B62EB29EF1468D0FFFE8711B46391B866CA4F4 public Material ReadFromJson(IResMgr resmgr, MyJson.JsonNode_Object json) { Material mat = new Material(Shader.Find(shaderName)); if (jsonConfig.ContainsKey("params")) { var _param = jsonConfig["params"] as MyJson.JsonNode_Object; foreach (var jsonitem in json) { if (jsonitem.Key == "shaderName") { continue; } if (_param.ContainsKey(jsonitem.Key)) { var item = _param[jsonitem.Key]; string type = item.asDict()["type"].AsString(); string flag = item.asDict()["flags"].AsString(); string name = item.asDict()["name"].AsString(); if (type == "Float" || type == "Range") { mat.SetFloat(name, (float)jsonitem.Value.AsDouble()); //json[name] = new MyJson.JsonNode_ValueNumber(mat.GetFloat(name)); } else if (type == "Vector") { mat.SetVector(name, StringHelper.ToVector4(jsonitem.Value.AsString())); //json[name] = new MyJson.JsonNode_ValueString(StringHelper.ToString(mat.GetVector(name))); } else if (type == "Color") { mat.SetColor(name, StringHelper.ToColor32(jsonitem.Value.AsString())); //json[name] = new MyJson.JsonNode_ValueString(StringHelper.ToString(mat.GetColor(name))); } else if (type == "Texture") { string texdim = item.asDict()["texdim"].AsString(); if (texdim == "Tex2D") { var tex = resmgr.GetTexture(jsonitem.Value.AsString()); mat.SetTexture(name, tex); //json["mainTexture"] = new MyJson.JsonNode_ValueString(texname); } else { throw new Exception("not support texdim:" + texdim); } } else { throw new Exception("not support type:" + type); } } else { throw new Exception("not have param:" + jsonitem.Key); } //Debug.Log(item.Value); } } return(mat); }