From 297b9fac226a219bb77b75f7dd2e6755a313caa4 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Thu, 26 Dec 2024 15:44:04 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=87=E5=AD=97?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=A2=98=E8=AF=84=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Actions/ActionHelper.cs | 4 +- Assets/Scripts/Actions/TextQuestionAction.cs | 30 ++++++-- Assets/Scripts/UI/UITextQuestion.cs | 78 ++++++++++++++++++++ Assets/Scripts/Xml/XmlParser.cs | 69 ++++++++++++++--- Doc/Xml配置文档.xml | 15 +++- 5 files changed, 174 insertions(+), 22 deletions(-) diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index b75e54c6..c6a99514 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -115,8 +115,8 @@ public class ActionHelper case "TextQuestion": { - var strAction = (XMLTool.StringListAction)act; - return TextQuestionAction.Allocate(strAction.args[0], strAction.args[1], strAction.args[2], strAction.args[3], strAction.args[4], strAction.args[5]); + var strAction = (XMLTool.DictionaryAction)act; + return TextQuestionAction.Allocate(strAction.args); } case "Hint": { diff --git a/Assets/Scripts/Actions/TextQuestionAction.cs b/Assets/Scripts/Actions/TextQuestionAction.cs index 666632c9..7f1d1f17 100644 --- a/Assets/Scripts/Actions/TextQuestionAction.cs +++ b/Assets/Scripts/Actions/TextQuestionAction.cs @@ -20,18 +20,27 @@ public class TextQuestionAction : IAction string btns = string.Empty; string wait = string.Empty; string showAnswer = string.Empty; - public static TextQuestionAction Allocate(string title, string options, string answers, string btns, string wait, string showAnswer, System.Action onDelayFinish = null) + string rightScore = string.Empty; + string errorScore = string.Empty; + string scoreName = string.Empty; + string absolutely = string.Empty; + + public static TextQuestionAction Allocate(Dictionary datas, System.Action onDelayFinish = null) { var retNode = mPool.Allocate(); retNode.ActionID = ActionKit.ID_GENERATOR++; retNode.Deinited = false; retNode.Reset(); - retNode.title = title; - retNode.options = options; - retNode.btns = btns; - retNode.answers = answers; - retNode.wait = wait; - retNode.showAnswer = showAnswer; + retNode.title = datas.ContainsKey("title") ? datas["title"] : string.Empty; + retNode.options = datas.ContainsKey("options") ? datas["options"] : string.Empty; + retNode.btns = datas.ContainsKey("btns") ? datas["btns"] : string.Empty; + retNode.answers = datas.ContainsKey("answers") ? datas["answers"] : string.Empty; + retNode.wait = datas.ContainsKey("wait") ? datas["wait"] : string.Empty; + retNode.showAnswer = datas.ContainsKey("showAnswer") ? datas["showAnswer"] : string.Empty; + retNode.rightScore = datas.ContainsKey("rightScore") ? datas["rightScore"] : string.Empty; + retNode.errorScore = datas.ContainsKey("errorScore") ? datas["errorScore"] : string.Empty; + retNode.scoreName = datas.ContainsKey("scoreName") ? datas["scoreName"] : string.Empty; + retNode.absolutely = datas.ContainsKey("absolutely") ? datas["absolutely"] : string.Empty; return retNode; } @@ -66,6 +75,13 @@ public class TextQuestionAction : IAction data.btns = btns.Split(',').ToList(); float.TryParse(wait, out data.waitCloseTime); bool.TryParse(showAnswer, out data.showAnswer); + if (string.IsNullOrEmpty(scoreName)==false) + { + data.scoreName = scoreName; + float.TryParse(rightScore, out data.rightScore); + float.TryParse(errorScore, out data.errorScore); + bool.TryParse(absolutely, out data.absolutely); + } UIKit.OpenPanelAsync(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish()); } diff --git a/Assets/Scripts/UI/UITextQuestion.cs b/Assets/Scripts/UI/UITextQuestion.cs index e6af6366..3f8fc014 100644 --- a/Assets/Scripts/UI/UITextQuestion.cs +++ b/Assets/Scripts/UI/UITextQuestion.cs @@ -3,6 +3,9 @@ using UnityEngine.UI; using QFramework; using System.Collections.Generic; using TMPro; +using System; +using Microsoft.SqlServer.Server; +using XMLTool; namespace QFramework.Example { @@ -14,6 +17,14 @@ namespace QFramework.Example public List btns = new List(); public float waitCloseTime = -1; public bool showAnswer = false; + public float rightScore = 0; + public float errorScore = 0; + public string scoreName = string.Empty; + public string format; + /// + /// Ե ÷ Ծ͵÷ Ͳ÷ + /// + public bool absolutely = true; } public partial class UITextQuestion : UIPanel { @@ -56,6 +67,35 @@ namespace QFramework.Example } } } + + if (string.IsNullOrEmpty(mData.scoreName) == false) + { + if (mData.rightScore != 0) + { + Check(true, count => + { + if (count > 0) + { + float score = mData.rightScore / mData.answers.Count * count; + string scoreStr = score.ToString(mData.format); + ScoreController.Instance.Add(mData.scoreName, float.Parse(scoreStr)); + } + }); + } + else if(mData.errorScore != 0) + { + Check(false, count => + { + if (count > 0) + { + float score = mData.errorScore / mData.answers.Count * count; + string scoreStr = score.ToString(mData.format); + ScoreController.Instance.Add(mData.scoreName, float.Parse(scoreStr)); + } + }); + } + } + if (mData.waitCloseTime != -1) { @@ -63,12 +103,50 @@ namespace QFramework.Example return; } + Hide(); }); } } + public void Check(bool isRight, Action callback) + { + int count = 0; + if (isRight) + { + for (int i = 0; i < OptionContent.transform.childCount; i++) + { + Toggle toggle = OptionContent.transform.GetChild(i).GetComponent(); + if (mData.answers.Contains(toggle.name) && toggle.isOn) + { + count++; + } + } + if (mData.absolutely == true && count != mData.answers.Count) + { + count = 0; + } + callback?.Invoke(count); + } + else + { + for (int i = 0; i < OptionContent.transform.childCount; i++) + { + Toggle toggle = OptionContent.transform.GetChild(i).GetComponent(); + if (mData.answers.Contains(toggle.name) && toggle.isOn == false) + { + count++; + } + } + if (mData.absolutely == true && count > 0) + { + count = mData.answers.Count; + } + callback?.Invoke(count); + } + } + protected override void OnShow() { } diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index b1ab911e..51db6872 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -1,3 +1,4 @@ +using Microsoft.SqlServer.Server; using QFramework; using System.Collections.Generic; using System.Linq; @@ -463,13 +464,63 @@ namespace XMLTool break; case "TextQuestion": { - var act = new StringListAction(); - act.args.Add(action.Attribute("title").Value); - act.args.Add(action.Attribute("options").Value); - act.args.Add(action.Attribute("answers").Value); - act.args.Add(action.Attribute("btns").Value); - act.args.Add(action.Attribute("wait").Value); - act.args.Add(action.Attribute("showAnswer").Value); + var act = new DictionaryAction(); + XAttribute title = action.Attribute("title"); + if (title != null) + { + act.args.Add("title", title.Value); + } + XAttribute options = action.Attribute("options"); + if (options != null) + { + act.args.Add("options", options.Value); + } + XAttribute answers = action.Attribute("answers"); + if (answers != null) + { + act.args.Add("answers", answers.Value); + } + XAttribute btns = action.Attribute("btns"); + if (btns != null) + { + act.args.Add("btns", btns.Value); + } + XAttribute wait = action.Attribute("wait"); + if (wait != null) + { + act.args.Add("wait", wait.Value); + } + XAttribute showAnswer = action.Attribute("showAnswer"); + if (showAnswer != null) + { + act.args.Add("showAnswer", showAnswer.Value); + } + XAttribute rightScore = action.Attribute("rightScore"); + if (rightScore != null) + { + act.args.Add("rightScore", rightScore.Value); + } + XAttribute errorScore = action.Attribute("wrongScore"); + if (errorScore != null) + { + act.args.Add("errorScore", errorScore.Value); + } + XAttribute scoreName = action.Attribute("scoreName"); + if (scoreName != null) + { + act.args.Add("scoreName", scoreName.Value); + } + XAttribute absolutely = action.Attribute("absolutely"); + if (absolutely != null) + { + act.args.Add("absolutely", absolutely.Value); + } + + XAttribute format = action.Attribute("format"); + if (format != null) + { + act.args.Add("format", format.Value); + } newAction = act; } break; @@ -595,7 +646,7 @@ namespace XMLTool } else { - act.args.Add("nearTime","0"); + act.args.Add("nearTime", "0"); } XAttribute normalTime = action.Attribute("normalTime"); @@ -605,7 +656,7 @@ namespace XMLTool } else { - act.args.Add("normalTime","0"); + act.args.Add("normalTime", "0"); } XAttribute isNear = action.Attribute("isNear"); if (isNear != null) diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml index fee1a0fe..79bdef6d 100644 --- a/Doc/Xml配置文档.xml +++ b/Doc/Xml配置文档.xml @@ -31,8 +31,14 @@ - - + + @@ -91,12 +97,12 @@ - + From 050c23b7decd7a7bff51abc455ecf42eb2419a4d Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Thu, 26 Dec 2024 16:00:02 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scenes/Main.unity | 280 +++++++++++++++++++++++++++++++-------- 1 file changed, 225 insertions(+), 55 deletions(-) diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index f550e046..cee8204b 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.20749143, g: 0.21147497, b: 0.14576834, a: 1} + m_IndirectSpecularColor: {r: 0.2846214, g: 0.37120992, b: 0.498806, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -123,7 +123,7 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1 &537733966 +--- !u!1 &547432235 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -131,28 +131,46 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 537733974} - - component: {fileID: 537733973} - - component: {fileID: 537733972} - - component: {fileID: 537733971} - - component: {fileID: 537733970} - - component: {fileID: 537733968} - - component: {fileID: 537733967} - - component: {fileID: 537733975} + - component: {fileID: 547432243} + - component: {fileID: 547432242} + - component: {fileID: 547432241} + - component: {fileID: 547432240} + - component: {fileID: 547432239} + - component: {fileID: 547432238} + - component: {fileID: 547432237} + - component: {fileID: 547432236} m_Layer: 0 - m_Name: FlyCamera + m_Name: FlyCamera (1) m_TagString: MainCamera m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!54 &537733967 +--- !u!114 &547432236 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 547432235} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0a0782d2b4482d547ad00c06c17202a4, type: 3} + m_Name: + m_EditorClassIdentifier: + moveSpeed: 5 + rotateSpeed: 1 + xRotationLimit: 60 + enableCollision: 1 + isMov: 1 + isRot: 1 +--- !u!54 &547432237 Rigidbody: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 537733966} + m_GameObject: {fileID: 547432235} serializedVersion: 4 m_Mass: 1 m_Drag: 0 @@ -173,13 +191,13 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 0 m_CollisionDetection: 0 ---- !u!136 &537733968 +--- !u!136 &547432238 CapsuleCollider: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 537733966} + m_GameObject: {fileID: 547432235} m_Material: {fileID: 0} m_IncludeLayers: serializedVersion: 2 @@ -196,13 +214,13 @@ CapsuleCollider: m_Height: 2.045719 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} ---- !u!114 &537733970 +--- !u!114 &547432239 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 537733966} + m_GameObject: {fileID: 547432235} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} @@ -240,29 +258,29 @@ MonoBehaviour: mipBias: 0 varianceClampScale: 0.9 contrastAdaptiveSharpening: 0 ---- !u!81 &537733971 +--- !u!81 &547432240 AudioListener: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 537733966} + m_GameObject: {fileID: 547432235} m_Enabled: 1 ---- !u!124 &537733972 +--- !u!124 &547432241 Behaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 537733966} + m_GameObject: {fileID: 547432235} m_Enabled: 1 ---- !u!20 &537733973 +--- !u!20 &547432242 Camera: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 537733966} + m_GameObject: {fileID: 547432235} m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 1 @@ -307,39 +325,22 @@ Camera: m_OcclusionCulling: 1 m_StereoConvergence: 10 m_StereoSeparation: 0.022 ---- !u!4 &537733974 +--- !u!4 &547432243 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 537733966} + m_GameObject: {fileID: 547432235} serializedVersion: 2 - m_LocalRotation: {x: 0.17254329, y: 0.100123234, z: -0.017632809, w: 0.97974145} - m_LocalPosition: {x: -53.9, y: 37.52, z: -78.1} + m_LocalRotation: {x: 0.059811153, y: 0.9234663, z: -0.16098467, w: 0.34309843} + m_LocalPosition: {x: -4.2800546, y: 3.0786743, z: 3.6917665} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 19.976, y: 11.67, z: 0} ---- !u!114 &537733975 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 537733966} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0a0782d2b4482d547ad00c06c17202a4, type: 3} - m_Name: - m_EditorClassIdentifier: - moveSpeed: 5 - rotateSpeed: 1 - xRotationLimit: 60 - enableCollision: 1 - isLock: 0 ---- !u!1 &1513158594 +--- !u!1 &1089184132 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -347,22 +348,34 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 1513158595} - - component: {fileID: 1513158596} + - component: {fileID: 1089184134} + - component: {fileID: 1089184133} m_Layer: 0 - m_Name: Launch + m_Name: Launch (1) m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &1513158595 +--- !u!114 &1089184133 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1089184132} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: df1da35b6adc57842b2ef6b620e87390, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1089184134 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1513158594} + m_GameObject: {fileID: 1089184132} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} @@ -371,21 +384,178 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1513158596 +--- !u!1 &1548041028 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1548041030} + - component: {fileID: 1548041029} + m_Layer: 0 + m_Name: Global Volume + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1548041029 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1513158594} + m_GameObject: {fileID: 1548041028} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: df1da35b6adc57842b2ef6b620e87390, type: 3} + m_Script: {fileID: 11500000, guid: 172515602e62fb746b5d573b38a5fe58, type: 3} m_Name: m_EditorClassIdentifier: + m_IsGlobal: 1 + priority: 0 + blendDistance: 0 + weight: 1 + sharedProfile: {fileID: 11400000, guid: cc15d5c774ad0e9439ba4753a231849c, type: 2} +--- !u!4 &1548041030 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1548041028} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1655025498 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1655025501} + - component: {fileID: 1655025500} + - component: {fileID: 1655025499} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1655025499 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1655025498} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Version: 3 + m_UsePipelineSettings: 1 + m_AdditionalLightsShadowResolutionTier: 2 + m_LightLayerMask: 1 + m_RenderingLayers: 1 + m_CustomShadowLayers: 0 + m_ShadowLayerMask: 1 + m_ShadowRenderingLayers: 1 + m_LightCookieSize: {x: 1, y: 1} + m_LightCookieOffset: {x: 0, y: 0} + m_SoftShadowQuality: 1 +--- !u!108 &1655025500 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1655025498} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &1655025501 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1655025498} + serializedVersion: 2 + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 m_Roots: - - {fileID: 1513158595} - - {fileID: 537733974} + - {fileID: 1548041030} + - {fileID: 1655025501} + - {fileID: 547432243} + - {fileID: 1089184134} From 6bceb42936a670ec11d34ffbcdbff5911588faa7 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Thu, 26 Dec 2024 16:03:47 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scenes/Main.unity | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index cee8204b..f69b36e7 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -140,7 +140,7 @@ GameObject: - component: {fileID: 547432237} - component: {fileID: 547432236} m_Layer: 0 - m_Name: FlyCamera (1) + m_Name: FlyCamera m_TagString: MainCamera m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -351,7 +351,7 @@ GameObject: - component: {fileID: 1089184134} - component: {fileID: 1089184133} m_Layer: 0 - m_Name: Launch (1) + m_Name: Launch m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 From d65de1e6c2085876e1c9c7d7f6ff2305a672dd09 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Thu, 26 Dec 2024 19:35:31 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=96=B0=E5=A2=9Eobjclick=E9=80=82?= =?UTF-8?q?=E9=85=8DdeviceName?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Actions/ActionBase.cs | 5 +++- Assets/Scripts/Actions/ActionHelper.cs | 3 +- .../Scripts/Conditions/ObjClickCondition.cs | 28 +++++++++++++------ Assets/Scripts/Xml/XmlParser.cs | 28 +++++++++++++++---- Doc/Xml配置文档.xml | 4 +-- 5 files changed, 49 insertions(+), 19 deletions(-) diff --git a/Assets/Scripts/Actions/ActionBase.cs b/Assets/Scripts/Actions/ActionBase.cs index dd46b2ba..dc832519 100644 --- a/Assets/Scripts/Actions/ActionBase.cs +++ b/Assets/Scripts/Actions/ActionBase.cs @@ -24,6 +24,9 @@ namespace XMLTool } - + public class DictionaryCondition : Condition + { + public Dictionary args = new Dictionary(); + } } diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index c6a99514..029a5ec5 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -237,7 +237,8 @@ public class ActionHelper case "UIClick": return UIClickCondition.Allocate(condition.Value); case "ObjClick": - return ObjClickCondition.Allocate(condition.Value); + var dict = (XMLTool.DictionaryCondition)condition; + return ObjClickCondition.Allocate(dict.Value, dict.args); case "Input": return InputCondition.Allocate(condition.Value); case "Var": diff --git a/Assets/Scripts/Conditions/ObjClickCondition.cs b/Assets/Scripts/Conditions/ObjClickCondition.cs index dd1b43d5..2bcfdad4 100644 --- a/Assets/Scripts/Conditions/ObjClickCondition.cs +++ b/Assets/Scripts/Conditions/ObjClickCondition.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.EventSystems; @@ -14,20 +15,29 @@ namespace QFramework private ObjClickCondition() { } public GameObject obj = null; string path; - public static ObjClickCondition Allocate(string path) + string deviceName; + public static ObjClickCondition Allocate(string path, Dictionary datas) { var conditionAction = mSimpleObjectPool.Allocate(); conditionAction.ActionID = ActionKit.ID_GENERATOR++; conditionAction.Deinited = false; conditionAction.Reset(); conditionAction.path = path; + conditionAction.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : null; return conditionAction; } public bool Check() { if (obj == null) { - obj = Utility.FindObj(path); + if (string.IsNullOrEmpty(deviceName)) + { + obj = Utility.FindObj(path); + } + else + { + obj = DeviceController.Instance.GetDeviceObj(deviceName); + } } if (obj != null && Input.GetMouseButtonUp(0)) { @@ -79,11 +89,11 @@ namespace QFramework } } - public static class ObjClickConditionExtension - { - public static ISequence ObjClickCondition(this ISequence self, string uipath) - { - return self.Append(QFramework.ObjClickCondition.Allocate(uipath)); - } - } + //public static class ObjClickConditionExtension + //{ + // public static ISequence ObjClickCondition(this ISequence self, string uipath) + // { + // return self.Append(QFramework.ObjClickCondition.Allocate(uipath)); + // } + //} } \ No newline at end of file diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index 51db6872..5e112adf 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -1040,13 +1040,29 @@ namespace XMLTool public static Condition ParseCondition(XElement action) { - Condition newAction = new Condition + Condition newAction = null; + string type = action.Attribute("type")?.Value; + switch (type) { - Type = action.Attribute("type")?.Value, - Name = action.Attribute("name")?.Value, - Value = action.Attribute("value")?.Value, - SubActions = ParseActions(action) - }; + case "ObjClick": + var act = new DictionaryCondition(); + + XAttribute deviceName = action.Attribute("deviceName"); + if (deviceName != null) + { + act.args.Add("deviceName", deviceName.Value); + } + newAction = act; + break; + default: + newAction = new Condition(); + break; + } + newAction.Type = type; + newAction.Name = action.Attribute("name")?.Value; + newAction.Value = action.Attribute("value")?.Value; + newAction.SubActions = ParseActions(action); + return newAction; } diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml index 79bdef6d..03669536 100644 --- a/Doc/Xml配置文档.xml +++ b/Doc/Xml配置文档.xml @@ -72,8 +72,8 @@ - - + +