diff --git a/Assets/Art/UIPrefab/UITextTip.prefab b/Assets/Art/UIPrefab/UITextTip.prefab index 3d8f00a0..14d14538 100644 --- a/Assets/Art/UIPrefab/UITextTip.prefab +++ b/Assets/Art/UIPrefab/UITextTip.prefab @@ -460,6 +460,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5ed9b43aa6da2fd49af65b4ab0b85fc2, type: 3} m_Name: m_EditorClassIdentifier: + Mask: {fileID: 1168405647267019539} Title: {fileID: 3613689092755446169} Des: {fileID: 5150898215778594440} BtnContent: {fileID: 8598386973860236803} @@ -626,6 +627,7 @@ GameObject: - component: {fileID: 7621766697555444520} - component: {fileID: 5831602004918006429} - component: {fileID: 1168405647267019539} + - component: {fileID: 6844797422068731548} m_Layer: 5 m_Name: Mask m_TagString: Untagged @@ -669,13 +671,13 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 4085354983340029108} - m_Enabled: 0 + m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 0, g: 0, b: 0, a: 0.5019608} + m_Color: {r: 0, g: 0, b: 0, a: 0} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 @@ -692,6 +694,22 @@ MonoBehaviour: m_FillOrigin: 0 m_UseSpriteMesh: 0 m_PixelsPerUnitMultiplier: 1 +--- !u!114 &6844797422068731548 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4085354983340029108} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0d51f3a7c41ab0346b49ae50d456bece, type: 3} + m_Name: + m_EditorClassIdentifier: + MarkType: 0 + CustomComponentName: + CustomComment: + mComponentName: UnityEngine.UI.Image --- !u!1 &4287411951672065129 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Art/UIPrefab/UITools.prefab b/Assets/Art/UIPrefab/UITools.prefab index ff313573..382798ca 100644 --- a/Assets/Art/UIPrefab/UITools.prefab +++ b/Assets/Art/UIPrefab/UITools.prefab @@ -51,6 +51,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: answers: [] + bg: {fileID: 2575765536656914917} Scroll: {fileID: 3666318679728618663} Content: {fileID: 8229723427790603414} ItemPrefab: {fileID: 3266964766418377106} @@ -869,6 +870,7 @@ GameObject: - component: {fileID: 4604846658045866225} - component: {fileID: 7995524027316056123} - component: {fileID: 2575765536656914917} + - component: {fileID: 7995406576721174090} m_Layer: 0 m_Name: bg m_TagString: Untagged @@ -891,9 +893,9 @@ RectTransform: - {fileID: 9189599814967438796} m_Father: {fileID: 4477385101412774245} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 1, y: 0.5} - m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: -133, y: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 0, y: 0.5} + m_AnchoredPosition: {x: 111.5, y: 0} m_SizeDelta: {x: 223, y: 653} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &7995524027316056123 @@ -934,6 +936,22 @@ MonoBehaviour: m_FillOrigin: 0 m_UseSpriteMesh: 0 m_PixelsPerUnitMultiplier: 1 +--- !u!114 &7995406576721174090 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3256755621147846471} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0d51f3a7c41ab0346b49ae50d456bece, type: 3} + m_Name: + m_EditorClassIdentifier: + MarkType: 0 + CustomComponentName: bg + CustomComment: + mComponentName: UnityEngine.UI.Image --- !u!1 &3509989120642977392 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/QFramework/Toolkits/_CoreKit/ActionKit/Scripts/Utility/Utility.cs b/Assets/QFramework/Toolkits/_CoreKit/ActionKit/Scripts/Utility/Utility.cs index 6ff7d928..359c8d97 100644 --- a/Assets/QFramework/Toolkits/_CoreKit/ActionKit/Scripts/Utility/Utility.cs +++ b/Assets/QFramework/Toolkits/_CoreKit/ActionKit/Scripts/Utility/Utility.cs @@ -411,5 +411,16 @@ public class Utility } } - + // 使用Unity的Random实现洗牌 + public static void Shuffle(IList list) + { + int n = list.Count; + for (int i = n - 1; i > 0; i--) + { + int j = UnityEngine.Random.Range(0, i + 1); + T temp = list[i]; + list[i] = list[j]; + list[j] = temp; + } + } } \ No newline at end of file diff --git a/Assets/Scenes/LouDiXuMuQvan.unity b/Assets/Scenes/LouDiXuMuQvan.unity index fbd3b6da..206d1689 100644 --- a/Assets/Scenes/LouDiXuMuQvan.unity +++ b/Assets/Scenes/LouDiXuMuQvan.unity @@ -39504,6 +39504,14 @@ PrefabInstance: propertyPath: m_Materials.Array.data[2] value: objectReference: {fileID: 2100000, guid: 08b25335e6ce3bd4eacb9f61a422e5d3, type: 2} + - target: {fileID: 814728240074513508, guid: 4dde43b36ab78d04da783fc679db9abb, type: 3} + propertyPath: m_Materials.Array.data[0] + value: + objectReference: {fileID: 2100000, guid: 9afb30013efac994dbaa691b16e73d4f, type: 2} + - target: {fileID: 814728240074513508, guid: 4dde43b36ab78d04da783fc679db9abb, type: 3} + propertyPath: m_Materials.Array.data[6] + value: + objectReference: {fileID: 2100000, guid: 64987e02868b39a45b978c4e74382520, type: 2} - target: {fileID: 1063729919534690453, guid: 4dde43b36ab78d04da783fc679db9abb, type: 3} propertyPath: m_Materials.Array.data[2] value: @@ -39540,6 +39548,10 @@ PrefabInstance: propertyPath: m_IsActive value: 1 objectReference: {fileID: 0} + - target: {fileID: 3005906659638043578, guid: 4dde43b36ab78d04da783fc679db9abb, type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} - target: {fileID: 3368573076977138093, guid: 4dde43b36ab78d04da783fc679db9abb, type: 3} propertyPath: m_Materials.Array.data[0] value: diff --git a/Assets/Scripts/Actions/TextTipAction.cs b/Assets/Scripts/Actions/TextTipAction.cs index 4fb06b14..2ed2e770 100644 --- a/Assets/Scripts/Actions/TextTipAction.cs +++ b/Assets/Scripts/Actions/TextTipAction.cs @@ -53,6 +53,15 @@ public class TextTipAction : IAction data.audio = datas.ContainsKey("audio") ? datas["audio"] : string.Empty; data.title = datas.ContainsKey("title") ? datas["title"] : string.Empty; data.btns = datas.ContainsKey("btns") ? datas["btns"].Split(',').ToList() : null; + if (datas.ContainsKey("alpha")) + { + if (float.TryParse(datas["alpha"], out data.alpha) == false) + { + data.alpha = 0; + } + } + + UIKit.OpenPanelAsync(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish()); } diff --git a/Assets/Scripts/Actions/UIToolsAction.cs b/Assets/Scripts/Actions/UIToolsAction.cs index df5ebfab..b230c731 100644 --- a/Assets/Scripts/Actions/UIToolsAction.cs +++ b/Assets/Scripts/Actions/UIToolsAction.cs @@ -26,6 +26,9 @@ public class UIToolsAction : IAction string totalScore; string scoreStepName; string autoHide; + string random; + string scrollSpeed; + string position; public static UIToolsAction Allocate(Dictionary datas, System.Action onDelayFinish = null) { var retNode = mPool.Allocate(); @@ -44,6 +47,9 @@ public class UIToolsAction : IAction retNode.totalScore = datas.ContainsKey("totalScore") ? datas["totalScore"] : ""; retNode.scoreStepName = datas.ContainsKey("scoreStepName") ? datas["scoreStepName"] : ""; retNode.autoHide = datas.ContainsKey("autoHide") ? datas["autoHide"] : ""; + retNode.random = datas.ContainsKey("random") ? datas["random"] : ""; + retNode.scrollSpeed = datas.ContainsKey("scrollSpeed") ? datas["scrollSpeed"] : ""; + retNode.position = datas.ContainsKey("position") ? datas["position"] : ""; return retNode; } @@ -80,10 +86,20 @@ public class UIToolsAction : IAction float.TryParse(totalScore, out data.totalScore); data.scoreStepName = scoreStepName; bool.TryParse(setActive, out data.SetActive); + if (bool.TryParse(random, out data.random) == false) + { + data.random = false; + } + if (float.TryParse(scrollSpeed, out data.scrollSpeed) == false) + { + data.scrollSpeed = 25; + } + if (float.TryParse(autoHide, out data.autoHideResult) == false) { data.autoHideResult = -1; } + data.position = position; UIKit.OpenPanelAsync(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish()); } diff --git a/Assets/Scripts/UI/UITextTip.Designer.cs b/Assets/Scripts/UI/UITextTip.Designer.cs index f1187906..6d510cd4 100644 --- a/Assets/Scripts/UI/UITextTip.Designer.cs +++ b/Assets/Scripts/UI/UITextTip.Designer.cs @@ -5,11 +5,13 @@ using QFramework; namespace QFramework.Example { - // Generate Id:2bccd644-ac9b-4f30-8f17-4a933167afc1 + // Generate Id:81b68f1b-6a7e-4133-9c0a-5297fa12f3ca public partial class UITextTip { public const string Name = "UITextTip"; + [SerializeField] + public UnityEngine.UI.Image Mask; [SerializeField] public TMPro.TextMeshProUGUI Title; [SerializeField] @@ -23,6 +25,7 @@ namespace QFramework.Example protected override void ClearUIComponents() { + Mask = null; Title = null; Des = null; BtnContent = null; diff --git a/Assets/Scripts/UI/UITextTip.cs b/Assets/Scripts/UI/UITextTip.cs index ba70f722..56699625 100644 --- a/Assets/Scripts/UI/UITextTip.cs +++ b/Assets/Scripts/UI/UITextTip.cs @@ -14,6 +14,7 @@ namespace QFramework.Example public string text; public string audio; public string title; + public float alpha = 0; public List btns; } public partial class UITextTip : UIPanel @@ -64,6 +65,9 @@ namespace QFramework.Example loader.LoadAsync(); } Title.text = mData.title; + Color color = Mask.color; + color.a = mData.alpha; + Mask.color = color; } protected override void OnShow() diff --git a/Assets/Scripts/UI/UITools.Designer.cs b/Assets/Scripts/UI/UITools.Designer.cs index 6ecd151d..a3e25de3 100644 --- a/Assets/Scripts/UI/UITools.Designer.cs +++ b/Assets/Scripts/UI/UITools.Designer.cs @@ -5,11 +5,13 @@ using QFramework; namespace QFramework.Example { - // Generate Id:5f777d12-69d4-455d-bef6-fb39dbeda60e + // Generate Id:be7133cf-6b67-4ebc-b151-f39cadcba0d2 public partial class UITools { public const string Name = "UITools"; + [SerializeField] + public UnityEngine.UI.Image bg; [SerializeField] public UnityEngine.UI.ScrollRect Scroll; [SerializeField] @@ -21,6 +23,7 @@ namespace QFramework.Example protected override void ClearUIComponents() { + bg = null; Scroll = null; Content = null; ItemPrefab = null; diff --git a/Assets/Scripts/UI/UITools.cs b/Assets/Scripts/UI/UITools.cs index 17f4273c..ddea43ad 100644 --- a/Assets/Scripts/UI/UITools.cs +++ b/Assets/Scripts/UI/UITools.cs @@ -23,6 +23,9 @@ namespace QFramework.Example public float totalScore; public string scoreStepName; public float autoHideResult = -1; + public bool random = false; + public float scrollSpeed = 25; + public string position; } public partial class UITools : UIPanel { @@ -55,6 +58,11 @@ namespace QFramework.Example answers = mData.answer.Split(',')?.ToList(); } Content.RemoveAllChildren(); + if (mData.devices.Count > 0 && mData.random) + { + Utility.Shuffle(mData.devices); + } + Scroll.scrollSensitivity = mData.scrollSpeed; foreach (var device in mData.devices) { var item = DeviceController.Instance.GetDevice(device); @@ -133,6 +141,35 @@ namespace QFramework.Example } mResLoader.LoadAsync(); Scroll.verticalNormalizedPosition = 1; + + + switch (mData.position) + { + case "left": + // êΪҲм䣨Middle-Right + bg.rectTransform.anchorMin = new Vector2(0, 0.5f); // ê㣨Ҳࣩ + bg.rectTransform.anchorMax = new Vector2(0, 0.5f); // ê㣨Ҳࣩ + + // λƫƹ㣨ê㣩 + bg.rectTransform.anchoredPosition = Vector2.zero; + + // ѡĵΪҲе㣨Ӱ/תģ + bg.rectTransform.pivot = new Vector2(0, 0.5f); + break; + case "right": + default: + // êΪҲм䣨Middle-Right + bg.rectTransform.anchorMin = new Vector2(1, 0.5f); // ê㣨Ҳࣩ + bg.rectTransform.anchorMax = new Vector2(1, 0.5f); // ê㣨Ҳࣩ + + // λƫƹ㣨ê㣩 + bg.rectTransform.anchoredPosition = Vector2.zero; + + // ѡĵΪҲе㣨Ӱ/תģ + bg.rectTransform.pivot = new Vector2(1, 0.5f); + break; + } + } public void SetSelected(GameObject item, bool isRight) diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index 4526393c..f4a4fe95 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -570,6 +570,21 @@ namespace XMLTool { act.args.Add("autoHide", autoHide.Value); } + var random = action.Attribute("random"); + if (random != null) + { + act.args.Add("random", random.Value); + } + var scrollSpeed = action.Attribute("scrollSpeed"); + if (scrollSpeed != null) + { + act.args.Add("scrollSpeed", scrollSpeed.Value); + } + var position = action.Attribute("position"); + if (position != null) + { + act.args.Add("position", position.Value); + } newAction = act; } break; @@ -824,6 +839,11 @@ namespace XMLTool { act.args.Add("title", title.Value); } + XAttribute alpha = action.Attribute("alpha"); + if (alpha != null) + { + act.args.Add("alpha", alpha.Value); + } newAction = act; } diff --git a/Data/Xml/Study.xml b/Data/Xml/Study.xml index b748ec7e..f18227d4 100644 --- a/Data/Xml/Study.xml +++ b/Data/Xml/Study.xml @@ -951,7 +951,7 @@ - + @@ -1010,6 +1010,7 @@ + @@ -1156,7 +1157,7 @@ - + @@ -1215,7 +1216,7 @@ - + @@ -1549,7 +1550,7 @@ - + @@ -1562,6 +1563,7 @@ + @@ -1583,6 +1585,7 @@ + @@ -2816,9 +2819,8 @@ - - + diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml index 3b1b7599..9768cd64 100644 --- a/Doc/Xml配置文档.xml +++ b/Doc/Xml配置文档.xml @@ -29,7 +29,10 @@ + totalScore 是配合wrongScore的用于初始化一个分数 然后选择扣分 + random 是否打乱devices的顺序 + scrollSpeed 鼠标滚轮的滑动速度 + position left/right 可以让道具栏在左侧或者右侧--> + autoHide="-1" + random="true" + scrollSpeed="25" + position="right"> @@ -100,8 +106,10 @@ 如果不配置 nearPos或者normalPos 则自动隐藏对应的视角UI按钮 --> - - + +