修复UITools bug

This commit is contained in:
shenjianxing 2025-01-14 18:48:46 +08:00
parent 632966423e
commit c258d1eab1
9 changed files with 40 additions and 6 deletions

View File

@ -853,7 +853,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2fafe2cfe61f6974895a912c3755e8f1, type: 3} m_Script: {fileID: 11500000, guid: 2fafe2cfe61f6974895a912c3755e8f1, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_AllowSwitchOff: 0 m_AllowSwitchOff: 1
--- !u!114 &1622034218903515943 --- !u!114 &1622034218903515943
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -987,7 +987,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
MarkType: 0 MarkType: 0
CustomComponentName: CustomComponentName: BtnContent
CustomComment: CustomComment:
mComponentName: RectTransform mComponentName: RectTransform
--- !u!1 &7473196182865972638 --- !u!1 &7473196182865972638

View File

@ -25,6 +25,7 @@ public class TextQuestionAction : IAction
string scoreName = string.Empty; string scoreName = string.Empty;
string absolutely = string.Empty; string absolutely = string.Empty;
string finishedEvent = string.Empty; string finishedEvent = string.Empty;
string optionType = null;
public static TextQuestionAction Allocate(Dictionary<string, string> datas, System.Action onDelayFinish = null) public static TextQuestionAction Allocate(Dictionary<string, string> datas, System.Action onDelayFinish = null)
{ {
var retNode = mPool.Allocate(); var retNode = mPool.Allocate();
@ -42,6 +43,7 @@ public class TextQuestionAction : IAction
retNode.scoreName = datas.ContainsKey("scoreName") ? datas["scoreName"] : string.Empty; retNode.scoreName = datas.ContainsKey("scoreName") ? datas["scoreName"] : string.Empty;
retNode.absolutely = datas.ContainsKey("absolutely") ? datas["absolutely"] : string.Empty; retNode.absolutely = datas.ContainsKey("absolutely") ? datas["absolutely"] : string.Empty;
retNode.finishedEvent = datas.ContainsKey("finishedEvent") ? datas["finishedEvent"] : string.Empty; retNode.finishedEvent = datas.ContainsKey("finishedEvent") ? datas["finishedEvent"] : string.Empty;
retNode.optionType = datas.ContainsKey("optionType") ? datas["optionType"] : "0";
return retNode; return retNode;
} }
@ -84,6 +86,7 @@ public class TextQuestionAction : IAction
float.TryParse(errorScore, out data.errorScore); float.TryParse(errorScore, out data.errorScore);
bool.TryParse(absolutely, out data.absolutely); bool.TryParse(absolutely, out data.absolutely);
} }
int.TryParse(optionType, out data.OptionType);
UIKit.OpenPanelAsync<UITextQuestion>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish()); UIKit.OpenPanelAsync<UITextQuestion>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish());
} }

View File

@ -77,7 +77,10 @@ public class UIToolsAction : IAction
float.TryParse(wrongScore, out data.wrongScore); float.TryParse(wrongScore, out data.wrongScore);
data.scoreStepName = scoreStepName; data.scoreStepName = scoreStepName;
bool.TryParse(setActive, out data.SetActive); bool.TryParse(setActive, out data.SetActive);
float.TryParse(autoHide, out data.autoHideResult); if (float.TryParse(autoHide, out data.autoHideResult) == false)
{
data.autoHideResult = -1;
}
UIKit.OpenPanelAsync<UITools>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish()); UIKit.OpenPanelAsync<UITools>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish());
} }

View File

@ -18,7 +18,6 @@ public class DeviceItem : MonoBehaviour
var effect = gameObject.GetOrAddComponent<HighlightEffect>(); var effect = gameObject.GetOrAddComponent<HighlightEffect>();
gameObject.GetOrAddComponent<HighlightTrigger>(); gameObject.GetOrAddComponent<HighlightTrigger>();
effect.outlineColor = Color.green; effect.outlineColor = Color.green;
Debug.LogError("Regitser " + gameObject.name);
StringEventSystem.Global.Register<string[]>(Global.HighLightTrigger, OnHighLightTriggerEvent); StringEventSystem.Global.Register<string[]>(Global.HighLightTrigger, OnHighLightTriggerEvent);
} }
if (device.MeshCollider) if (device.MeshCollider)

View File

@ -59,7 +59,7 @@ namespace QFramework.Example
ActionKit.Delay(mData.autoHideTime, () => ActionKit.Delay(mData.autoHideTime, () =>
{ {
SetHide(); SetHide();
}); }).Start(this);
} }
} }

View File

@ -24,6 +24,10 @@ namespace QFramework.Example
public string format; public string format;
public string finishedEvent; public string finishedEvent;
/// <summary> /// <summary>
/// 0:×Ô¶¯ÅÐ¶Ï 1:µ¥Ñ¡ 2:¶àÑ¡
/// </summary>
public int OptionType = 0;
/// <summary>
/// 绝对的 不计算分项得分 对就得分 错就不得分 /// 绝对的 不计算分项得分 对就得分 错就不得分
/// </summary> /// </summary>
public bool absolutely = true; public bool absolutely = true;
@ -53,6 +57,23 @@ namespace QFramework.Example
GameObject obj = GameObject.Instantiate(OptionPrefab.gameObject, OptionContent.transform); GameObject obj = GameObject.Instantiate(OptionPrefab.gameObject, OptionContent.transform);
obj.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = item; obj.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = item;
obj.name = (i + 1).ToString(); obj.name = (i + 1).ToString();
bool isGroup = false;
switch (mData.OptionType)
{
case 0:
isGroup = mData.answers.Count == 1;
break;
case 1:
isGroup = true;
break;
case 2:
isGroup = false;
break;
}
if (isGroup)
{
obj.GetComponent<Toggle>().group = OptionContent.GetComponent<ToggleGroup>();
}
} }
BtnContent.RemoveAllChildren(); BtnContent.RemoveAllChildren();

View File

@ -96,6 +96,7 @@ namespace QFramework.Example
{ {
StringEventSystem.Global.Send(mData.rightEvent); StringEventSystem.Global.Send(mData.rightEvent);
}; };
data.autoHideTime = mData.autoHideResult;
UIKit.OpenPanelAsync<UIResultTip>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(); UIKit.OpenPanelAsync<UIResultTip>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal();
} }
} }
@ -110,6 +111,7 @@ namespace QFramework.Example
StringEventSystem.Global.Send(mData.wrongEvent); StringEventSystem.Global.Send(mData.wrongEvent);
SetSelected(obj, false); SetSelected(obj, false);
}; };
data.autoHideTime = mData.autoHideResult;
UIKit.OpenPanelAsync<UIResultTip>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().Start(this); UIKit.OpenPanelAsync<UIResultTip>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().Start(this);
} }

View File

@ -517,6 +517,11 @@ namespace XMLTool
{ {
act.args.Add("finishedEvent", finishedEvent.Value); act.args.Add("finishedEvent", finishedEvent.Value);
} }
XAttribute optionType = action.Attribute("optionType");
if (optionType != null)
{
act.args.Add("optionType", optionType.Value);
}
newAction = act; newAction = act;
} }
break; break;

View File

@ -61,8 +61,9 @@
format="{0:F1}" F1代表保留1位小数 F2代表2位 F0代表不保留小数 format="{0:F1}" F1代表保留1位小数 F2代表2位 F0代表不保留小数
注意rightScore与wrongScore不能同时存在 同时存在则只生效rightScore 注意rightScore与wrongScore不能同时存在 同时存在则只生效rightScore
finishedEvent 用于监听选择题UI消失 finishedEvent 用于监听选择题UI消失
optionType 0 根据答案数量自动判断单选还是多选 1 单选 2多选
--> -->
<Action type="TextQuestion" title="这里是标题" options="A.111|B.222|C.333|D.4444" answers="2" btns="确定" wait="1" showAnswer="true" scoreName="分数名" rightScore="5" wrongScore="-5" absolutely="false" format="{0:F1}" finishedEvent="事件名"></Action> <Action type="TextQuestion" title="这里是标题" options="A.111|B.222|C.333|D.4444" answers="2" btns="确定" wait="1" showAnswer="true" scoreName="分数名" rightScore="5" wrongScore="-5" absolutely="false" format="{0:F1}" finishedEvent="事件名" optionType="0"></Action>
<!--提示 time为显示的时间 -1则一直显示 icon是前面的绿色图标是否显示 audio是音频 位于data文件夹下的Audio--> <!--提示 time为显示的时间 -1则一直显示 icon是前面的绿色图标是否显示 audio是音频 位于data文件夹下的Audio-->
<Action type="Hint" value="这里是文字描述" time="5" icon="false" audio="音频.mp3"></Action> <Action type="Hint" value="这里是文字描述" time="5" icon="false" audio="音频.mp3"></Action>
<!--设置变量 value只能是数字可以是小数--> <!--设置变量 value只能是数字可以是小数-->