新增动态更换材质球和贴图功能
This commit is contained in:
parent
4799acc1ed
commit
cbf6cde0b0
@ -24,6 +24,7 @@ namespace QFramework
|
||||
string deviceName;
|
||||
string matName;
|
||||
string index;
|
||||
string mainTexture;
|
||||
public static MatAction Allocate(Dictionary<string, string> datas, System.Action OnFinished = null)
|
||||
{
|
||||
var retNode = mPool.Allocate();
|
||||
@ -34,6 +35,7 @@ namespace QFramework
|
||||
retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : "";
|
||||
retNode.matName = datas.ContainsKey("matName") ? datas["matName"] : "";
|
||||
retNode.index = datas.ContainsKey("index") ? datas["index"] : "0";
|
||||
retNode.mainTexture = datas.ContainsKey("mainTexture") ? datas["mainTexture"] : null;
|
||||
retNode.OnFinished = OnFinished;
|
||||
return retNode;
|
||||
}
|
||||
@ -56,7 +58,22 @@ namespace QFramework
|
||||
var mesh = obj.GetComponent<Renderer>();
|
||||
int matIndex = 0;
|
||||
int.TryParse(index, out matIndex);
|
||||
mesh.materials[matIndex] = Resources.Load<Material>("Mat/" + matName);
|
||||
if (string.IsNullOrEmpty(matName) == false)
|
||||
{
|
||||
mesh.materials[matIndex] = Resources.Load<Material>("Mat/" + matName);
|
||||
}
|
||||
if (mainTexture != null)
|
||||
{
|
||||
if (mainTexture == "")
|
||||
{
|
||||
mesh.materials[matIndex].mainTexture = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.materials[matIndex].mainTexture = Resources.Load<Texture>("Mat/" + mainTexture);
|
||||
}
|
||||
}
|
||||
|
||||
this.Finish();
|
||||
}
|
||||
|
||||
|
||||
@ -1122,6 +1122,11 @@ namespace XMLTool
|
||||
{
|
||||
act.args.Add("index", index.Value);
|
||||
}
|
||||
XAttribute mainTexture = action.Attribute("mainTexture");
|
||||
if (mainTexture != null)
|
||||
{
|
||||
act.args.Add("mainTexture", mainTexture.Value);
|
||||
}
|
||||
newAction = act;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -162,7 +162,8 @@
|
||||
<!--弹窗 btns可支持多个按钮-->
|
||||
<Action type="TipWindow" value="恭喜你完成当前模块" btns="确定,取消" audio=""></Action>
|
||||
|
||||
|
||||
<!--动态更换材质球和主贴图 材质球优先级高于贴图 同时写的情况下 先换材质球再换贴图-->
|
||||
<Action type="Mat" value="Models/zhudao/nan_shoushufu.012" matName="yiyongshoutao_yellow1" index="1" mainTexture="贴图名字"></Action>
|
||||
|
||||
<!--预加载模块 要在app.xml的Data标签内-->
|
||||
<PreLoad>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user