From cbf6cde0b082ea6f28728fac90f0ee0d4d2ba7b7 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Sun, 19 Jan 2025 17:13:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=A8=E6=80=81=E6=9B=B4?= =?UTF-8?q?=E6=8D=A2=E6=9D=90=E8=B4=A8=E7=90=83=E5=92=8C=E8=B4=B4=E5=9B=BE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Actions/MatAction.cs | 19 ++++++++++++++++++- Assets/Scripts/Xml/XmlParser.cs | 5 +++++ Doc/Xml配置文档.xml | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Actions/MatAction.cs b/Assets/Scripts/Actions/MatAction.cs index 14af6ca1..0ee2c157 100644 --- a/Assets/Scripts/Actions/MatAction.cs +++ b/Assets/Scripts/Actions/MatAction.cs @@ -24,6 +24,7 @@ namespace QFramework string deviceName; string matName; string index; + string mainTexture; public static MatAction Allocate(Dictionary 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(); int matIndex = 0; int.TryParse(index, out matIndex); - mesh.materials[matIndex] = Resources.Load("Mat/" + matName); + if (string.IsNullOrEmpty(matName) == false) + { + mesh.materials[matIndex] = Resources.Load("Mat/" + matName); + } + if (mainTexture != null) + { + if (mainTexture == "") + { + mesh.materials[matIndex].mainTexture = null; + } + else + { + mesh.materials[matIndex].mainTexture = Resources.Load("Mat/" + mainTexture); + } + } + this.Finish(); } diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index ab62047c..1a0548d6 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -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; diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml index 74fe120d..381962ab 100644 --- a/Doc/Xml配置文档.xml +++ b/Doc/Xml配置文档.xml @@ -162,7 +162,8 @@ - + +