Show和CameraSwitch 两个Action支持以Device为目标
This commit is contained in:
parent
cee4f3b3b6
commit
efb2195571
@ -18,6 +18,12 @@ namespace XMLTool
|
||||
}
|
||||
|
||||
|
||||
public class DictionaryAction : Action
|
||||
{
|
||||
public Dictionary<string, string> args = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ public class ActionHelper
|
||||
case "Show":
|
||||
{
|
||||
var strAction = (XMLTool.StringListAction)act;
|
||||
return ShowAction.Allocate(act.Value, strAction.args[0]);
|
||||
return ShowAction.Allocate(act.Value, strAction.args[0], strAction.args[1]);
|
||||
}
|
||||
case "TextTip":
|
||||
{
|
||||
@ -144,8 +144,8 @@ public class ActionHelper
|
||||
return SetScoreAction.Allocate(act.Name, act.Value);
|
||||
case "CameraSwitch":
|
||||
{
|
||||
var strAction = (XMLTool.StringListAction)act;
|
||||
return CameraSwitchAction.Allocate(strAction.args[0], strAction.args[1], strAction.args[2], strAction.args[3], strAction.args[4], strAction.args[5], strAction.args[6]);
|
||||
var dictAction = (XMLTool.DictionaryAction)act;
|
||||
return CameraSwitchAction.Allocate(dictAction.args);
|
||||
}
|
||||
case "CameraLock":
|
||||
{
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using QFramework.Example;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
@ -17,27 +18,16 @@ namespace QFramework
|
||||
private static readonly SimpleObjectPool<CameraSwitchAction> mPool =
|
||||
new SimpleObjectPool<CameraSwitchAction>(() => new CameraSwitchAction(), null, 10);
|
||||
|
||||
string nearPos;
|
||||
string nearRot;
|
||||
string normalPos;
|
||||
string normalRot;
|
||||
string isNear;
|
||||
string nearTime;
|
||||
string farTime;
|
||||
public static CameraSwitchAction Allocate(string nearPos, string nearRot, string nearTime, string normalPos, string normalRot, string farTime, string isNear, System.Action OnFinished = null)
|
||||
|
||||
Dictionary<string, string> datas;
|
||||
public static CameraSwitchAction Allocate(Dictionary<string, string> dict, System.Action OnFinished = null)
|
||||
{
|
||||
var retNode = mPool.Allocate();
|
||||
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
||||
retNode.Deinited = false;
|
||||
retNode.Reset();
|
||||
retNode.OnFinished = OnFinished;
|
||||
retNode.nearPos = nearPos;
|
||||
retNode.nearRot = nearRot;
|
||||
retNode.nearTime = nearTime;
|
||||
retNode.normalPos = normalPos;
|
||||
retNode.normalRot = normalRot;
|
||||
retNode.farTime = farTime;
|
||||
retNode.isNear = isNear;
|
||||
retNode.datas = dict;
|
||||
return retNode;
|
||||
}
|
||||
|
||||
@ -48,11 +38,37 @@ namespace QFramework
|
||||
public void OnStart()
|
||||
{
|
||||
UICameraSwitchData data = new UICameraSwitchData();
|
||||
data.nearPos = Utility.GetVector3FromStrArray(nearPos);
|
||||
data.nearRot = Utility.GetVector3FromStrArray(nearRot);
|
||||
data.normalPos = Utility.GetVector3FromStrArray(normalPos);
|
||||
data.normalRot = Utility.GetVector3FromStrArray(normalRot);
|
||||
bool.TryParse(isNear, out data.isNear);
|
||||
|
||||
if (datas.ContainsKey("nearDevice"))
|
||||
{
|
||||
GameObject obj = DeviceController.Instance.GetDeviceObj(datas["nearDevice"]);
|
||||
data.nearPos = obj.Position();
|
||||
data.nearRot = obj.EulerAngles();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
data.nearPos = Utility.GetVector3FromStrArray(datas["nearPos"]);
|
||||
data.nearRot = Utility.GetVector3FromStrArray(datas["nearRot"]);
|
||||
|
||||
}
|
||||
|
||||
if (datas.ContainsKey("normalDevice"))
|
||||
{
|
||||
GameObject obj = DeviceController.Instance.GetDeviceObj(datas["normalDevice"]);
|
||||
data.normalPos = obj.Position();
|
||||
data.normalRot = obj.EulerAngles();
|
||||
}
|
||||
else
|
||||
{
|
||||
data.normalPos = Utility.GetVector3FromStrArray(datas["normalPos"]);
|
||||
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);
|
||||
|
||||
UIKit.OpenPanelAsync<UICameraSwitch>(uiData: data, canvasLevel: UILevel.RightBottom).ToAction().StartGlobal(() => this.Finish());
|
||||
}
|
||||
|
||||
|
||||
@ -18,7 +18,8 @@ public class ShowAction : IAction
|
||||
new SimpleObjectPool<ShowAction>(() => new ShowAction(), null, 10);
|
||||
string path;
|
||||
bool isShow = true;
|
||||
public static ShowAction Allocate(string path, string isShow, System.Action onDelayFinish = null)
|
||||
bool isDevice = false;
|
||||
public static ShowAction Allocate(string path, string isShow, string isDevice, System.Action onDelayFinish = null)
|
||||
{
|
||||
var retNode = mPool.Allocate();
|
||||
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
||||
@ -26,6 +27,7 @@ public class ShowAction : IAction
|
||||
retNode.Reset();
|
||||
retNode.path = path;
|
||||
bool.TryParse(isShow, out retNode.isShow);
|
||||
bool.TryParse(isDevice, out retNode.isDevice);
|
||||
return retNode;
|
||||
}
|
||||
|
||||
@ -50,8 +52,16 @@ public class ShowAction : IAction
|
||||
|
||||
public void OnStart()
|
||||
{
|
||||
GameObject obj = null;
|
||||
if (isDevice)
|
||||
{
|
||||
obj = DeviceController.Instance.GetDeviceObj(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
GameObject obj = Utility.FindObj(path);
|
||||
obj = Utility.FindObj(path);
|
||||
}
|
||||
if (obj == null)
|
||||
{
|
||||
Debug.LogError("没有找到物体 :" + path);
|
||||
|
||||
@ -2,16 +2,20 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using QFramework;
|
||||
using DG.Tweening;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QFramework.Example
|
||||
{
|
||||
public class UICameraSwitchData : UIPanelData
|
||||
{
|
||||
public string nearDevice;
|
||||
public string normalDevice;
|
||||
public Vector3 nearPos;
|
||||
public Vector3 nearRot;
|
||||
public Vector3 normalPos;
|
||||
public Vector3 normalRot;
|
||||
|
||||
public float nearTime;
|
||||
public float normalTime;
|
||||
public bool isNear = false;
|
||||
|
||||
}
|
||||
@ -25,25 +29,39 @@ namespace QFramework.Example
|
||||
{
|
||||
if (isOn)
|
||||
{
|
||||
Camera.main.transform.DOMove(mData.nearPos, 0);
|
||||
Camera.main.transform.DORotate(mData.nearRot, 0);
|
||||
SetNear();
|
||||
}
|
||||
Near.transform.Find("Bg/Line").gameObject.SetActive(isOn);
|
||||
});
|
||||
Far.onValueChanged.AddListener(isOn =>
|
||||
{
|
||||
{
|
||||
if (isOn)
|
||||
{
|
||||
Camera.main.transform.DOMove(mData.normalPos, 0);
|
||||
Camera.main.transform.DORotate(mData.normalRot, 0);
|
||||
SetNormal();
|
||||
}
|
||||
Far.transform.Find("Bg/Line").gameObject.SetActive(isOn);
|
||||
});
|
||||
}
|
||||
|
||||
public void SetNear()
|
||||
{
|
||||
Camera.main.transform.DOMove(mData.nearPos, mData.nearTime);
|
||||
Camera.main.transform.DORotate(mData.nearRot, mData.nearTime);
|
||||
}
|
||||
|
||||
public void SetNormal()
|
||||
{
|
||||
|
||||
Camera.main.transform.DOMove(mData.normalPos, mData.normalTime);
|
||||
Camera.main.transform.DORotate(mData.normalRot, mData.normalTime);
|
||||
}
|
||||
protected override void OnOpen(IUIData uiData = null)
|
||||
{
|
||||
mData = uiData as UICameraSwitchData ?? new UICameraSwitchData();
|
||||
|
||||
|
||||
|
||||
|
||||
if (mData.isNear)
|
||||
{
|
||||
if (Near.isOn == false)
|
||||
@ -52,8 +70,7 @@ namespace QFramework.Example
|
||||
}
|
||||
else
|
||||
{
|
||||
Camera.main.transform.DOMove(mData.nearPos, 0);
|
||||
Camera.main.transform.DORotate(mData.nearRot, 0);
|
||||
SetNear();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -64,8 +81,7 @@ namespace QFramework.Example
|
||||
}
|
||||
else
|
||||
{
|
||||
Camera.main.transform.DOMove(mData.normalPos, 0);
|
||||
Camera.main.transform.DORotate(mData.normalRot, 0);
|
||||
SetNormal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -534,74 +534,87 @@ namespace XMLTool
|
||||
{
|
||||
act.args.Add("true");
|
||||
}
|
||||
|
||||
XAttribute isDevice = action.Attribute("isDevice");
|
||||
if (isDevice != null)
|
||||
{
|
||||
act.args.Add(isDevice.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.args.Add("false");
|
||||
}
|
||||
newAction = act;
|
||||
}
|
||||
break;
|
||||
case "CameraSwitch":
|
||||
{
|
||||
var act = new StringListAction();
|
||||
XAttribute isShow = action.Attribute("nearPos");
|
||||
if (isShow != null)
|
||||
var act = new DictionaryAction();
|
||||
XAttribute nearDevice = action.Attribute("nearDevice");
|
||||
if (nearDevice != null)
|
||||
{
|
||||
act.args.Add(isShow.Value);
|
||||
act.args.Add("nearDevice", nearDevice.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.args.Add("0,0,0");
|
||||
XAttribute nearPos = action.Attribute("nearPos");
|
||||
if (nearPos != null)
|
||||
{
|
||||
act.args.Add("nearPos", nearPos.Value);
|
||||
}
|
||||
XAttribute nearRot = action.Attribute("nearRot");
|
||||
if (nearRot != null)
|
||||
{
|
||||
act.args.Add("nearRot", nearRot.Value);
|
||||
}
|
||||
}
|
||||
XAttribute nearRot = action.Attribute("nearRot");
|
||||
if (nearRot != null)
|
||||
|
||||
XAttribute normalDevice = action.Attribute("normalDevice");
|
||||
if (normalDevice != null)
|
||||
{
|
||||
act.args.Add(nearRot.Value);
|
||||
act.args.Add("normalDevice", normalDevice.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.args.Add("0,0,0");
|
||||
XAttribute normalPos = action.Attribute("normalPos");
|
||||
if (normalPos != null)
|
||||
{
|
||||
act.args.Add("normalPos", normalPos.Value);
|
||||
}
|
||||
XAttribute normalRot = action.Attribute("normalRot");
|
||||
if (normalRot != null)
|
||||
{
|
||||
act.args.Add("normalRot", normalRot.Value);
|
||||
}
|
||||
}
|
||||
|
||||
XAttribute nearTime = action.Attribute("nearTime");
|
||||
if (nearTime != null)
|
||||
{
|
||||
act.args.Add(nearTime.Value);
|
||||
act.args.Add("nearTime", nearTime.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.args.Add("0");
|
||||
act.args.Add("nearTime","0");
|
||||
}
|
||||
XAttribute normalPos = action.Attribute("normalPos");
|
||||
if (normalPos != null)
|
||||
|
||||
XAttribute normalTime = action.Attribute("farTinormalTimeme");
|
||||
if (normalTime != null)
|
||||
{
|
||||
act.args.Add(normalPos.Value);
|
||||
act.args.Add("normalTime", normalTime.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.args.Add("0,0,0");
|
||||
}
|
||||
XAttribute normalRot = action.Attribute("normalRot");
|
||||
if (normalRot != null)
|
||||
{
|
||||
act.args.Add(normalRot.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.args.Add("0,0,0");
|
||||
}
|
||||
XAttribute farTime = action.Attribute("farTime");
|
||||
if (farTime != null)
|
||||
{
|
||||
act.args.Add(farTime.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.args.Add("0");
|
||||
act.args.Add("normalTime","0");
|
||||
}
|
||||
XAttribute isNear = action.Attribute("isNear");
|
||||
if (isNear != null)
|
||||
{
|
||||
act.args.Add(isNear.Value);
|
||||
act.args.Add("isNear", isNear.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.args.Add("false");
|
||||
act.args.Add("isNear", "false");
|
||||
}
|
||||
newAction = act;
|
||||
}
|
||||
|
||||
@ -639,6 +639,10 @@
|
||||
</Reset>
|
||||
<Start>
|
||||
<Action type="Sequence">
|
||||
<!--<Action type="CameraSwitch" nearDevice="肠钳" normalDevice="组织钳" isNear="false"></Action>-->
|
||||
<Action type="CameraSwitch" nearPos="-3.543,3.007,-1.463" nearRot="27.9597,270,2.899792E-06" normalPos="-3.206,3.24,-1.425" normalRot="27.9597,270,2.899792E-06" isNear="false"></Action>
|
||||
|
||||
<Condition type="StrEvent" value="close"></Condition>
|
||||
<!--string audioType, string loop, string waitFinished, string volume, string isPlay,-->
|
||||
<Action type="Audio" audioType="Voice" value="q001.mp3" loop="false" waitFinished="true" volumen="1" isPlay="true"></Action>
|
||||
<Action type="Log" value="0000"></Action>
|
||||
@ -758,7 +762,7 @@
|
||||
</Reset>
|
||||
<Start>
|
||||
<Action type="Sequence">
|
||||
<Action type="LockCamera" value="true" />
|
||||
<Action type="CameraLock" value="true" />
|
||||
<Action type="TextTip" value="这里是文字描述\n11111\n22222\n333333" audio="q001.mp3" btns="确定,取消"/>
|
||||
<Action type="Move" value="FlyCamera" to="-3.206,3.24,-1.425" time="0"></Action>
|
||||
<Action type="Rotate" value="FlyCamera" to="27.9597,270,2.899792E-06" time="0"></Action>
|
||||
|
||||
@ -39,18 +39,18 @@
|
||||
<Action type="Var" name="变量名" value="1"></Action>
|
||||
<!--设置分数 与Score配合使用 步骤名字一定要是step+name-->
|
||||
<Action type="SetScore" name="步骤名字" value="1"></Action>
|
||||
<!--镜头切换 近距离和默认-->
|
||||
<Action type="CameraSwitch" 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" farTime="1" isNear="false"></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>
|
||||
<!--文字弹窗 按钮可以多个 点击事件使用UIClick-->
|
||||
<Action type="TextTip" value="这里是文字描述" audio="q001.mp3" btns="确定,取消"/>
|
||||
<!--锁定镜头 value为是否锁定-->
|
||||
<Action type="LockCamera" value="true"></Action>
|
||||
<Action type="CameraLock" value="true"></Action>
|
||||
<!--播放视频 size为视频窗口大小 offset为窗口中心点偏移 播放完成事件和关闭事件 通常使用关闭事件即可
|
||||
宽度不要小于500 否则进度条看不太清楚-->
|
||||
<Action type="Video" value="test.mp4" size="500,500" offset="10,10" finishedEvent="finished" closeEvent="close"></Action>
|
||||
|
||||
<!--物体显隐 用于3D物体 isShow=true为显示 false为隐藏 UI的显隐使用UIShow-->
|
||||
<Action type="Show" value="SM_QvanChangJing/sence/pPlane1" isShow="false"></Action>
|
||||
<!--物体显隐 用于3D物体 isShow=true为显示 false为隐藏 UI的显隐使用UIShow isDevice为true的话 value就要写device配置的Name-->
|
||||
<Action type="Show" value="SM_QvanChangJing/sence/pPlane1" isShow="false" isDevice="false"></Action>
|
||||
<!--设置物体高亮 value是物体路径 color是rgba isHigh设置是否显示高亮-->
|
||||
<Action type="HighLight" value="路径" isHigh="true" color="0,255,0,255"></Action>
|
||||
<!--延迟 value是秒-->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user