Merge branch 'master' into LouDi_Quan

This commit is contained in:
shenjianxing 2025-03-07 15:19:14 +08:00
commit ba7656b001
9 changed files with 94 additions and 8 deletions

View File

@ -460,6 +460,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5ed9b43aa6da2fd49af65b4ab0b85fc2, type: 3} m_Script: {fileID: 11500000, guid: 5ed9b43aa6da2fd49af65b4ab0b85fc2, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
Mask: {fileID: 1168405647267019539}
Title: {fileID: 3613689092755446169} Title: {fileID: 3613689092755446169}
Des: {fileID: 5150898215778594440} Des: {fileID: 5150898215778594440}
BtnContent: {fileID: 8598386973860236803} BtnContent: {fileID: 8598386973860236803}
@ -626,6 +627,7 @@ GameObject:
- component: {fileID: 7621766697555444520} - component: {fileID: 7621766697555444520}
- component: {fileID: 5831602004918006429} - component: {fileID: 5831602004918006429}
- component: {fileID: 1168405647267019539} - component: {fileID: 1168405647267019539}
- component: {fileID: 6844797422068731548}
m_Layer: 5 m_Layer: 5
m_Name: Mask m_Name: Mask
m_TagString: Untagged m_TagString: Untagged
@ -669,13 +671,13 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4085354983340029108} m_GameObject: {fileID: 4085354983340029108}
m_Enabled: 0 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} 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_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
@ -692,6 +694,22 @@ MonoBehaviour:
m_FillOrigin: 0 m_FillOrigin: 0
m_UseSpriteMesh: 0 m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1 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 --- !u!1 &4287411951672065129
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -411,5 +411,16 @@ public class Utility
} }
} }
// 使用Unity的Random实现洗牌
public static void Shuffle<T>(IList<T> 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;
}
}
} }

View File

@ -53,6 +53,15 @@ public class TextTipAction : IAction
data.audio = datas.ContainsKey("audio") ? datas["audio"] : string.Empty; data.audio = datas.ContainsKey("audio") ? datas["audio"] : string.Empty;
data.title = datas.ContainsKey("title") ? datas["title"] : string.Empty; data.title = datas.ContainsKey("title") ? datas["title"] : string.Empty;
data.btns = datas.ContainsKey("btns") ? datas["btns"].Split(',').ToList() : null; 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<UITextTip>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish()); UIKit.OpenPanelAsync<UITextTip>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish());
} }

View File

@ -26,6 +26,8 @@ public class UIToolsAction : IAction
string totalScore; string totalScore;
string scoreStepName; string scoreStepName;
string autoHide; string autoHide;
string random;
string scrollSpeed;
public static UIToolsAction Allocate(Dictionary<string, string> datas, System.Action onDelayFinish = null) public static UIToolsAction Allocate(Dictionary<string, string> datas, System.Action onDelayFinish = null)
{ {
var retNode = mPool.Allocate(); var retNode = mPool.Allocate();
@ -44,6 +46,8 @@ public class UIToolsAction : IAction
retNode.totalScore = datas.ContainsKey("totalScore") ? datas["totalScore"] : ""; retNode.totalScore = datas.ContainsKey("totalScore") ? datas["totalScore"] : "";
retNode.scoreStepName = datas.ContainsKey("scoreStepName") ? datas["scoreStepName"] : ""; retNode.scoreStepName = datas.ContainsKey("scoreStepName") ? datas["scoreStepName"] : "";
retNode.autoHide = datas.ContainsKey("autoHide") ? datas["autoHide"] : ""; retNode.autoHide = datas.ContainsKey("autoHide") ? datas["autoHide"] : "";
retNode.random = datas.ContainsKey("random") ? datas["random"] : "";
retNode.scrollSpeed = datas.ContainsKey("scrollSpeed") ? datas["scrollSpeed"] : "";
return retNode; return retNode;
} }
@ -80,6 +84,15 @@ public class UIToolsAction : IAction
float.TryParse(totalScore, out data.totalScore); float.TryParse(totalScore, out data.totalScore);
data.scoreStepName = scoreStepName; data.scoreStepName = scoreStepName;
bool.TryParse(setActive, out data.SetActive); 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) if (float.TryParse(autoHide, out data.autoHideResult) == false)
{ {
data.autoHideResult = -1; data.autoHideResult = -1;

View File

@ -5,11 +5,13 @@ using QFramework;
namespace QFramework.Example namespace QFramework.Example
{ {
// Generate Id:2bccd644-ac9b-4f30-8f17-4a933167afc1 // Generate Id:81b68f1b-6a7e-4133-9c0a-5297fa12f3ca
public partial class UITextTip public partial class UITextTip
{ {
public const string Name = "UITextTip"; public const string Name = "UITextTip";
[SerializeField]
public UnityEngine.UI.Image Mask;
[SerializeField] [SerializeField]
public TMPro.TextMeshProUGUI Title; public TMPro.TextMeshProUGUI Title;
[SerializeField] [SerializeField]
@ -23,6 +25,7 @@ namespace QFramework.Example
protected override void ClearUIComponents() protected override void ClearUIComponents()
{ {
Mask = null;
Title = null; Title = null;
Des = null; Des = null;
BtnContent = null; BtnContent = null;

View File

@ -14,6 +14,7 @@ namespace QFramework.Example
public string text; public string text;
public string audio; public string audio;
public string title; public string title;
public float alpha = 0;
public List<string> btns; public List<string> btns;
} }
public partial class UITextTip : UIPanel public partial class UITextTip : UIPanel
@ -64,6 +65,9 @@ namespace QFramework.Example
loader.LoadAsync(); loader.LoadAsync();
} }
Title.text = mData.title; Title.text = mData.title;
Color color = Mask.color;
color.a = mData.alpha;
Mask.color = color;
} }
protected override void OnShow() protected override void OnShow()

View File

@ -23,6 +23,8 @@ namespace QFramework.Example
public float totalScore; public float totalScore;
public string scoreStepName; public string scoreStepName;
public float autoHideResult = -1; public float autoHideResult = -1;
public bool random = false;
public float scrollSpeed = 25;
} }
public partial class UITools : UIPanel public partial class UITools : UIPanel
{ {
@ -55,6 +57,11 @@ namespace QFramework.Example
answers = mData.answer.Split(',')?.ToList(); answers = mData.answer.Split(',')?.ToList();
} }
Content.RemoveAllChildren(); Content.RemoveAllChildren();
if (mData.devices.Count > 0 && mData.random)
{
Utility.Shuffle(mData.devices);
}
Scroll.scrollSensitivity = mData.scrollSpeed;
foreach (var device in mData.devices) foreach (var device in mData.devices)
{ {
var item = DeviceController.Instance.GetDevice(device); var item = DeviceController.Instance.GetDevice(device);

View File

@ -570,6 +570,16 @@ namespace XMLTool
{ {
act.args.Add("autoHide", autoHide.Value); 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);
}
newAction = act; newAction = act;
} }
break; break;
@ -824,6 +834,11 @@ namespace XMLTool
{ {
act.args.Add("title", title.Value); act.args.Add("title", title.Value);
} }
XAttribute alpha = action.Attribute("alpha");
if (alpha != null)
{
act.args.Add("alpha", alpha.Value);
}
newAction = act; newAction = act;
} }

View File

@ -29,7 +29,9 @@
<!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测 <!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测
rightScore 正确选择一个 得分 wrongScore 错误一个 得分 scoreStepName是评分的key rightScore 正确选择一个 得分 wrongScore 错误一个 得分 scoreStepName是评分的key
autoHide =-1 则点击结束 否则 等待对应时间后自动结束 autoHide =-1 则点击结束 否则 等待对应时间后自动结束
totalScore 是配合wrongScore的用于初始化一个分数 然后选择扣分--> totalScore 是配合wrongScore的用于初始化一个分数 然后选择扣分
random 是否打乱devices的顺序
scrollSpeed 鼠标滚轮的滑动速度-->
<Action type="UITools" devices="道具名字1" answers="正确道具" <Action type="UITools" devices="道具名字1" answers="正确道具"
setActive="true" setActive="true"
rightLabel="提示:器械选择正确。" rightLabel="提示:器械选择正确。"
@ -40,7 +42,9 @@
wrongScore="" wrongScore=""
totalScore="" totalScore=""
scoreStepName="手术准备器械选择" scoreStepName="手术准备器械选择"
autoHide="-1"></Action> autoHide="-1"
random="true"
scrollSpeed="25"></Action>
<!--物体点位选择 物体的中心点--> <!--物体点位选择 物体的中心点-->
<Action type="PointQuestion" value="路径1,路径2"></Action> <Action type="PointQuestion" value="路径1,路径2"></Action>
@ -100,8 +104,10 @@
如果不配置 nearPos或者normalPos 则自动隐藏对应的视角UI按钮 如果不配置 nearPos或者normalPos 则自动隐藏对应的视角UI按钮
--> -->
<Action type="CameraSwitch" nearDevice="肠钳" normalDevice="组织钳" nearPos="-3.942,3.24,-4.319" nearRot="16.42331,180,0" nearTime="1" normalPos="-3.942,3.24,-3.946" normalRot="16.42331,180,-5.305351E-14" normalTime="1"></Action> <Action type="CameraSwitch" nearDevice="肠钳" normalDevice="组织钳" nearPos="-3.942,3.24,-4.319" nearRot="16.42331,180,0" nearTime="1" normalPos="-3.942,3.24,-3.946" normalRot="16.42331,180,-5.305351E-14" normalTime="1"></Action>
<!--文字弹窗 按钮可以多个 点击事件使用UIClick--> <!--文字弹窗 按钮可以多个 点击事件使用UIClick
<Action type="TextTip" title="这里是标题" value="这里是文字描述" audio="q001.mp3" btns="确定,取消"/> alpha 0-1 背景的透明度
-->
<Action type="TextTip" title="这里是标题" value="这里是文字描述" audio="q001.mp3" btns="确定,取消" alpha="0.5"/>
<!--锁定镜头 true为开启 false为锁定 isMove是移动镜头 isRotate是旋转镜头--> <!--锁定镜头 true为开启 false为锁定 isMove是移动镜头 isRotate是旋转镜头-->
<Action type="CameraLock" isMove="true" isRotate="true"></Action> <Action type="CameraLock" isMove="true" isRotate="true"></Action>
<!--播放视频 size为视频窗口大小 offset为窗口中心点偏移 播放完成事件和关闭事件 通常使用关闭事件即可 <!--播放视频 size为视频窗口大小 offset为窗口中心点偏移 播放完成事件和关闭事件 通常使用关闭事件即可