Merge branch 'master' into LouDi_Quan

This commit is contained in:
shenjianxing 2024-12-31 17:06:40 +08:00
commit cf2b16d461
11 changed files with 134 additions and 36 deletions

View File

@ -529,7 +529,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2fafe2cfe61f6974895a912c3755e8f1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_AllowSwitchOff: 0
m_AllowSwitchOff: 1
--- !u!1 &5353223196711954198
GameObject:
m_ObjectHideFlags: 0

View File

@ -209,6 +209,10 @@ public class ActionHelper
var dictAction = (XMLTool.DictionaryAction)act;
return TimeTipAction.Allocate(act.Value, dictAction.args);
}
case "StrEvent":
{
return StrEventAction.Allocate(act.Name, act.Value);
}
default:
Debug.LogError($"没有找到此Action的类型{act.Type}");
break;

View File

@ -64,7 +64,6 @@ namespace QFramework
data.normalRot = Utility.GetVector3FromStrArray(datas["normalRot"]);
}
bool.TryParse(datas["isNear"], out data.isNear);
float.TryParse(datas["nearTime"], out data.nearTime);
float.TryParse(datas["normalTime"], out data.normalTime);

View File

@ -0,0 +1,77 @@
using System;
using System.Runtime.CompilerServices;
using UnityEngine;
namespace QFramework
{
internal class StrEventAction : IAction
{
public string txt;
public System.Action OnFinished { get; set; }
private StrEventAction()
{
}
private static readonly SimpleObjectPool<StrEventAction> mPool =
new SimpleObjectPool<StrEventAction>(() => new StrEventAction(), null, 10);
string key = string.Empty;
string arg = string.Empty;
public static StrEventAction Allocate(string key, string arg, System.Action OnFinished = null)
{
var retNode = mPool.Allocate();
retNode.ActionID = ActionKit.ID_GENERATOR++;
retNode.Deinited = false;
retNode.Reset();
retNode.OnFinished = OnFinished;
retNode.key = key;
retNode.arg = arg;
return retNode;
}
public ulong ActionID { get; set; }
public ActionStatus Status { get; set; }
public void OnStart()
{
StringEventSystem.Global.Send(key, arg.Split(","));
this.Finish();
}
public void OnExecute(float dt)
{
}
public void OnFinish()
{
}
public void Reset()
{
Status = ActionStatus.NotStart;
Paused = false;
}
public bool Paused { get; set; }
public void Deinit()
{
if (!Deinited)
{
OnFinished = null;
Deinited = true;
mPool.Recycle(this);
}
}
public bool Deinited { get; set; }
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7a45244e92d067b4495241480cdec7b7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -23,6 +23,8 @@ public class Global : Singleton<Global>
public static string reportDemoPath = reportPath + "Demo.docx";
public static APPSetting appSetting { get; } = new APPSetting();
public static string HighLightTrigger = "HighLightTrigger";
public enum AppType
{
UnKnow = 1 << 0,
@ -33,4 +35,6 @@ public class Global : Singleton<Global>
public static AppType appTpe = AppType.UnKnow;
}

View File

@ -1,6 +1,7 @@
using HighlightPlus;
using QFramework;
using QFramework.Example;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@ -16,6 +17,7 @@ public class DeviceItem : MonoBehaviour
var effect = gameObject.GetOrAddComponent<HighlightEffect>();
gameObject.GetOrAddComponent<HighlightTrigger>();
effect.outlineColor = Color.green;
StringEventSystem.Global.Register<string[]>(Global.HighLightTrigger, OnHighLightTriggerEvent).UnRegisterWhenGameObjectDestroyed(gameObject);
}
if (device.MeshCollider)
{
@ -40,6 +42,16 @@ public class DeviceItem : MonoBehaviour
}
}
private void OnHighLightTriggerEvent(string[] obj)
{
if (obj.Length > 0)
{
bool isActive = true;
bool.TryParse(obj[0], out isActive);
gameObject.GetComponent<HighlightTrigger>().enabled = isActive;
}
}
private void OnMouseUpAsButton()
{
var effect = gameObject.GetComponent<HighlightEffect>();

View File

@ -16,7 +16,6 @@ namespace QFramework.Example
public Vector3 normalRot;
public float nearTime;
public float normalTime;
public bool isNear = false;
}
public partial class UICameraSwitch : UIPanel
@ -59,30 +58,13 @@ namespace QFramework.Example
{
mData = uiData as UICameraSwitchData ?? new UICameraSwitchData();
if (mData.isNear)
if (Near.isOn)
{
if (Near.isOn == false)
{
Near.isOn = true;
}
else
{
SetNear();
}
SetNear();
}
else
if (Far.isOn)
{
if (Far.isOn == false)
{
Far.isOn = true;
}
else
{
SetNormal();
}
SetNormal();
}
}

View File

@ -66,7 +66,15 @@ namespace QFramework.Example
btn.transform.parent.gameObject.SetActive(true);
break;
case StepStatus.Finished:
stepLabel.color = highColor;
// TODO实现方式过于耦合 后期优化
if (Global.Instance.curModule.type=="Exam")
{
stepLabel.color = highColor;
}
else
{
stepLabel.color = Color.white;
}
break;
}
}

View File

@ -655,15 +655,6 @@ namespace XMLTool
{
act.args.Add("normalTime", "0");
}
XAttribute isNear = action.Attribute("isNear");
if (isNear != null)
{
act.args.Add("isNear", isNear.Value);
}
else
{
act.args.Add("isNear", "false");
}
newAction = act;
}
break;

View File

@ -48,8 +48,10 @@
<Action type="Var" name="变量名" value="1"></Action>
<!--设置分数 与Score配合使用 步骤名字一定要是step+name-->
<Action type="SetScore" name="步骤名字" value="1"></Action>
<!--镜头切换 近距离和默认 如果有了nearDevice就可以不用nearPos和nearRot了 按照device的坐标和旋转来处理镜头 normalDevice同理-->
<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" isNear="false"></Action>
<!--镜头切换 近距离和默认 如果有了nearDevice就可以不用nearPos和nearRot了 按照device的坐标和旋转来处理镜头 normalDevice同理
只设置坐标 不执行镜头切换 是否执行要根据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>
<!--文字弹窗 按钮可以多个 点击事件使用UIClick-->
<Action type="TextTip" value="这里是文字描述" audio="q001.mp3" btns="确定,取消"/>
<!--锁定镜头 value为是否锁定-->
@ -119,6 +121,14 @@
<Action type="TimeTip" value="这里是文字描述&lt;color=#FF00FF&gt;{0}&lt;/color&gt;-{1}" time="5" values="5,10|50,100" format="{0:F1}" finishedEvent="close" needClick="false" reverse="false" ></Action>
<!--通用事件通知
HighLightTriggervalue=false 关闭device悬浮高亮 value=true 开启
-->
<Action type="StrEvent" name="HighLightTrigger" value="false"></Action>
<!--预加载模块 要在app.xml的Data标签内-->
<PreLoad>
<Action type="Parallel">