Merge remote-tracking branch 'origin/master' into LouDi_Pig

This commit is contained in:
李浩 2024-12-30 10:57:36 +08:00
commit 872a4779c7
11 changed files with 245 additions and 74 deletions

View File

@ -100,8 +100,8 @@ public class ActionHelper
return BtnsAction.Allocate(act.Value); return BtnsAction.Allocate(act.Value);
case "Anim": case "Anim":
{ {
var strAction = (XMLTool.StringListAction)act; var strAction = (XMLTool.DictionaryAction)act;
return QFramework.AnimationAction.Allocate(act.Value, strAction.args[0], strAction.args[1]); return QFramework.AnimationAction.Allocate(act.Value, strAction.args);
} }
case "UITools": case "UITools":
{ {
@ -159,8 +159,8 @@ public class ActionHelper
} }
case "HighLight": case "HighLight":
{ {
var strAction = (XMLTool.StringListAction)act; var strAction = (XMLTool.DictionaryAction)act;
return HighLightAction.Allocate(act.Value, strAction.args[0], strAction.args[1]); return HighLightAction.Allocate(act.Value, strAction.args);
} }
case "LoadRes": case "LoadRes":
{ {

View File

@ -1,5 +1,7 @@
using System; using System;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.Rendering.Universal;
namespace QFramework namespace QFramework
{ {
@ -20,17 +22,19 @@ namespace QFramework
string path; string path;
string animName; string animName;
bool reset = false;
Animation anim; Animation anim;
public static AnimationAction Allocate(string path, string animName, string reset, System.Action OnFinished = null) string frame;
string speed;
public static AnimationAction Allocate(string path, Dictionary<string, string> datas, System.Action OnFinished = null)
{ {
var retNode = mPool.Allocate(); var retNode = mPool.Allocate();
retNode.ActionID = ActionKit.ID_GENERATOR++; retNode.ActionID = ActionKit.ID_GENERATOR++;
retNode.Deinited = false; retNode.Deinited = false;
retNode.Reset(); retNode.Reset();
retNode.path = path; retNode.path = path;
retNode.animName = animName; retNode.animName = datas.ContainsKey("animName") ? datas["animName"] : "";
bool.TryParse(reset, out retNode.reset); retNode.frame = datas.ContainsKey("frame") ? datas["frame"] : "";
retNode.speed = datas.ContainsKey("speed") ? datas["speed"] : "";
retNode.OnFinished = OnFinished; retNode.OnFinished = OnFinished;
return retNode; return retNode;
} }
@ -45,10 +49,25 @@ namespace QFramework
if (obj != null) if (obj != null)
{ {
anim = obj.GetComponent<Animation>(); anim = obj.GetComponent<Animation>();
anim.Play(animName);
if (reset) if (string.IsNullOrEmpty(frame) == false && frame != "-1")
{ {
ActionKit.DelayFrame(1, () => anim.Stop()); int curFrame = 0;
int.TryParse(frame, out curFrame);
anim[animName].time = curFrame / anim.clip.frameRate;
anim[animName].speed = 0;
anim.Play(animName);
this.Finish();
}
else
{
float curSpeed = 1;
if (string.IsNullOrEmpty(speed)==false)
{
float.TryParse(speed, out curSpeed);
}
anim[animName].speed = curSpeed;
anim.Play(animName);
} }
} }
else else

View File

@ -1,5 +1,6 @@
using HighlightPlus; using HighlightPlus;
using System; using System;
using System.Collections.Generic;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@ -22,18 +23,26 @@ namespace QFramework
string path; string path;
Color color = Color.green; Color color = Color.green;
bool isHigh = true; bool isHigh = true;
public static HighLightAction Allocate(string path, string isHigh, string color, System.Action OnFinished = null) string deviceName = string.Empty;
public static HighLightAction Allocate(string path, Dictionary<string, string> datas, System.Action OnFinished = null)
{ {
var retNode = mPool.Allocate(); var retNode = mPool.Allocate();
retNode.ActionID = ActionKit.ID_GENERATOR++; retNode.ActionID = ActionKit.ID_GENERATOR++;
retNode.Deinited = false; retNode.Deinited = false;
retNode.Reset(); retNode.Reset();
retNode.path = path; retNode.path = path;
if (string.IsNullOrEmpty(color) == false)
if (datas.ContainsKey("color"))
{ {
retNode.color = Utility.ToColor(color);
retNode.color = Utility.ToColor(datas["color"]);
} }
bool.TryParse(isHigh, out retNode.isHigh); if (datas.ContainsKey("isHigh"))
{
bool.TryParse(datas["isHigh"], out retNode.isHigh);
}
retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : string.Empty;
retNode.OnFinished = OnFinished; retNode.OnFinished = OnFinished;
return retNode; return retNode;
} }
@ -44,7 +53,16 @@ namespace QFramework
public void OnStart() public void OnStart()
{ {
GameObject obj = Utility.FindObj(path); GameObject obj = null;
if (string.IsNullOrEmpty(deviceName) == false)
{
obj = DeviceController.Instance.GetDeviceObj(deviceName);
}
else
{
obj = Utility.FindObj(path);
}
if (obj != null) if (obj != null)
{ {
if (isHigh) if (isHigh)

View File

@ -124,55 +124,72 @@ public class OperationController : MonoSingleton<OperationController>
{ {
if (this.index < targetIndex) if (this.index < targetIndex)
{ {
for (int i = this.index + 1; i < targetIndex; i++) var seq = ActionKit.Sequence();
if (this.index >= 0)
{ {
// Íê³É¶¯×÷ Ö±½ÓÖ´ÐÐ for (int i = this.index; i < targetIndex; i++)
IAction finishAction = ActionHelper.GetActionAndSub(steps[i].Finished);
if (finishAction != null)
{ {
finishAction.Start(this); // Íê³É¶¯×÷ Ö±½ÓÖ´ÐÐ
IAction finishAction = ActionHelper.GetActionAndSub(steps[i].Finished);
TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.Finished });
if (finishAction != null)
{
seq.Append(finishAction);
}
} }
TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.Finished });
} }
curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start); seq.Start(this, () =>
{
curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start);
RunCurAction(curAction, targetIndex);
});
} }
else if (this.index > targetIndex) else if (this.index > targetIndex)
{ {
var seq = ActionKit.Sequence();
for (int i = this.index; i > targetIndex; i--) for (int i = this.index; i > targetIndex; i--)
{ {
// ÖØÖö¯×÷ Ö±½ÓÖØÖà // ÖØÖö¯×÷ Ö±½ÓÖØÖÃ
IAction resetAction = ActionHelper.GetActionAndSub(steps[i].Reset); IAction resetAction = ActionHelper.GetActionAndSub(steps[i].Reset);
if (resetAction != null) if (resetAction != null)
{ {
resetAction.Start(this); seq.Append(resetAction);
} }
TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.NoStart }); TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.NoStart });
} }
curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start); seq.Start(this, () =>
}
else
{
curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start);
}
if (curAction != null)
{
this.index = targetIndex;
isStepRun = true;
TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = targetIndex, status = StepStatus.Start });
curAction.Start(this, () =>
{ {
isStepRun = false; curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start);
TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = targetIndex, status = StepStatus.Finished }); RunCurAction(curAction, targetIndex);
}); });
} }
else else
{ {
this.index = targetIndex; curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start);
TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = targetIndex, status = StepStatus.Finished }); RunCurAction(curAction, targetIndex);
Execute(this.index + 1);
} }
}
}
public void RunCurAction(IAction curAction, int targetIndex)
{
if (curAction != null)
{
this.index = targetIndex;
isStepRun = true;
TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = targetIndex, status = StepStatus.Start });
curAction.Start(this, () =>
{
isStepRun = false;
TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = targetIndex, status = StepStatus.Finished });
});
}
else
{
this.index = targetIndex;
TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = targetIndex, status = StepStatus.Finished });
Execute(this.index + 1);
} }
} }
} }

View File

@ -0,0 +1,84 @@

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
using System.Text.RegularExpressions;
using System;
using System.IO;
public class FbxAnimListPostprocessor : MonoBehaviour
{
[MenuItem("Assets/SplitAnimNew")]
public static void SplitAnim()
{
UnityEngine.Object obj = Selection.activeObject;
if( null != obj )
{
string assetPath = AssetDatabase.GetAssetPath(obj);
try
{
string fileAnim;
fileAnim = assetPath;
string ClipText = Path.ChangeExtension(fileAnim, ".txt");
StreamReader file = new StreamReader(ClipText);
string sAnimList = file.ReadToEnd();
file.Close();
//
if (EditorUtility.DisplayDialog("FBX Animation Import from file",
fileAnim, "Import", "Cancel"))
{
System.Collections.ArrayList List = new ArrayList();
ParseAnimFile(sAnimList, ref List);
ModelImporter modelImporter = ModelImporter.GetAtPath(assetPath) as ModelImporter;
modelImporter.animationType = ModelImporterAnimationType.Legacy;
//modelImporter.clipAnimations. = true;
modelImporter.clipAnimations = (ModelImporterClipAnimation[])
List.ToArray(typeof(ModelImporterClipAnimation));
AssetDatabase.ImportAsset(assetPath);
EditorUtility.DisplayDialog("导入成功",
"Number of imported clips: "
+ modelImporter.clipAnimations.GetLength(0).ToString(), "OK");
}
}
catch { }
// (Exception e) { EditorUtility.DisplayDialog("Imported animations", e.Message, "OK"); }
}
}
static void ParseAnimFile(string sAnimList, ref System.Collections.ArrayList List)
{
Regex regexString = new Regex(" *(?<firstFrame>[0-9]+) *- *(?<lastFrame>[0-9]+) *(?<loop>(loop|noloop| )) *(?<name>[^\r^\n]*[^\r^\n^ ])",
RegexOptions.Compiled | RegexOptions.ExplicitCapture);
Match match = regexString.Match(sAnimList, 0);
while (match.Success)
{
ModelImporterClipAnimation clip = new ModelImporterClipAnimation();
if (match.Groups["firstFrame"].Success)
{
clip.firstFrame = System.Convert.ToInt32(match.Groups["firstFrame"].Value, 10);
}
if (match.Groups["lastFrame"].Success)
{
clip.lastFrame = System.Convert.ToInt32(match.Groups["lastFrame"].Value, 10);
}
if (match.Groups["loop"].Success)
{
clip.loop = match.Groups["loop"].Value == "loop";
}
if (match.Groups["name"].Success)
{
clip.name = match.Groups["name"].Value;
}
List.Add(clip);
match = regexString.Match(sAnimList, match.Index + match.Length);
}
}
}

View File

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

View File

@ -56,9 +56,8 @@ public class Launch : MonoBehaviour
} }
IEnumerator PreLoad()
{
yield return null;
}
} }

View File

@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TimeScaleController : MonoBehaviour
{
[Range(0, 10)]
public float animSpeed = 1.0f;
#if UNITY_EDITOR
private void Update()
{
Time.timeScale = animSpeed;
}
#endif
}

View File

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

View File

@ -358,24 +358,21 @@ namespace XMLTool
break; break;
case "Anim": case "Anim":
{ {
var act = new StringListAction(); var act = new DictionaryAction();
var animName = action.Attribute("animName"); var animName = action.Attribute("animName");
if (animName != null) if (animName != null)
{ {
act.args.Add(animName.Value); act.args.Add("animName",animName.Value);
} }
else var frame = action.Attribute("frame");
if (frame != null)
{ {
act.args.Add(""); act.args.Add("frame", frame.Value);
} }
var reset = action.Attribute("reset"); var speed = action.Attribute("speed");
if (reset != null) if (speed != null)
{ {
act.args.Add(reset.Value); act.args.Add("speed", speed.Value);
}
else
{
act.args.Add("false");
} }
newAction = act; newAction = act;
@ -763,24 +760,21 @@ namespace XMLTool
break; break;
case "HighLight": case "HighLight":
{ {
var act = new StringListAction(); var act = new DictionaryAction();
XAttribute isHigh = action.Attribute("isHigh"); XAttribute isHigh = action.Attribute("isHigh");
if (isHigh != null) if (isHigh != null)
{ {
act.args.Add(isHigh.Value); act.args.Add("isHigh", isHigh.Value);
}
else
{
act.args.Add("true");
} }
XAttribute color = action.Attribute("color"); XAttribute color = action.Attribute("color");
if (color != null) if (color != null)
{ {
act.args.Add(color.Value); act.args.Add("color", color.Value);
} }
else XAttribute deviceName = action.Attribute("deviceName");
if (deviceName != null)
{ {
act.args.Add(""); act.args.Add("deviceName", deviceName.Value);
} }
newAction = act; newAction = act;
} }

View File

@ -17,8 +17,8 @@
<Action type="Scale" value="Main Camera" to="0,180,0" time="0"></Action> <Action type="Scale" value="Main Camera" to="0,180,0" time="0"></Action>
<!--执行下一步左侧步骤列表 默认开始的时候为-1步 要主动调用一次才到第1步--> <!--执行下一步左侧步骤列表 默认开始的时候为-1步 要主动调用一次才到第1步-->
<Action type="NextOperation"></Action> <Action type="NextOperation"></Action>
<!--播放动画 reset=true则动画停在第一帧--> <!--播放动画 reset=true则动画停在第一帧 frame是指定格在动画的某一帧 如果为-1 正常播放动画 speed 动画播放速度 默认为1 -->
<Action type="Anim" value="物体路径" animName="动画名字" reset="false"></Action> <Action type="Anim" value="物体路径" animName="动画名字" frame="-1" speed="1"></Action>
<!--右下角生成按钮 可生成多个 用逗号分开--> <!--右下角生成按钮 可生成多个 用逗号分开-->
<Action type="Btns" value="按钮1,按钮2,按钮3"></Action> <Action type="Btns" value="按钮1,按钮2,按钮3"></Action>
<!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测 --> <!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测 -->
@ -57,8 +57,8 @@
<!--物体显隐 用于3D物体 isShow=true为显示 false为隐藏 UI的显隐使用UIShow isDevice为true的话 value就要写device配置的Name--> <!--物体显隐 用于3D物体 isShow=true为显示 false为隐藏 UI的显隐使用UIShow isDevice为true的话 value就要写device配置的Name-->
<Action type="Show" value="SM_QvanChangJing/sence/pPlane1" isShow="false" isDevice="false"></Action> <Action type="Show" value="SM_QvanChangJing/sence/pPlane1" isShow="false" isDevice="false"></Action>
<!--设置物体高亮 value是物体路径 color是rgba isHigh设置是否显示高亮--> <!--设置物体高亮 deviceName可以用于设备名字 value是物体路径 color是rgba isHigh设置是否显示高亮-->
<Action type="HighLight" value="路径" isHigh="true" color="0,255,0,255"></Action> <Action type="HighLight" deviceName="设备名字" value="路径" isHigh="true" color="0,255,0,255"></Action>
<!--延迟 value是秒--> <!--延迟 value是秒-->
<Action type="Delay" value="2"></Action> <Action type="Delay" value="2"></Action>
<!-- <!--
@ -71,8 +71,8 @@
<Action type="Audio" audioType="Voice" value="q001.mp3" loop="false" waitFinished="true" volumen="1" isPlay="true"></Action> <Action type="Audio" audioType="Voice" value="q001.mp3" loop="false" waitFinished="true" volumen="1" isPlay="true"></Action>
<!--判断UI点击--> <!--判断UI点击-->
<Condition type="UIClick" value="UI路径 可以使用快捷键Ctrl+Q获取"></Condition> <Condition type="UIClick" value="UI路径 可以使用快捷键Ctrl+Q获取"></Condition>
<!--判断物体点击 deviceName支持设备点击判断 有deviceName的情况下忽略value--> <!--判断物体点击-->
<Condition type="ObjClick" deviceName="" value="物体路径 可以使用快捷键Ctrl+Q获取" ></Condition> <Condition type="ObjClick" value="物体路径 可以使用快捷键Ctrl+Q获取"></Condition>
<!--判断键盘输入--> <!--判断键盘输入-->
<Condition type="Input" value="A"></Condition> <Condition type="Input" value="A"></Condition>
<!--判断变量名i是否等于1--> <!--判断变量名i是否等于1-->
@ -111,7 +111,7 @@
needClick如果为true 动画结束后不会自动小时 需要点击空白处 needClick如果为true 动画结束后不会自动小时 需要点击空白处
reverse 是时钟倒计时动画是否倒序播放 reverse 是时钟倒计时动画是否倒序播放
format="{0:F1}" F1代表保留1位小数 F2代表2位 F0代表不保留小数 format="{0:F1}" F1代表保留1位小数 F2代表2位 F0代表不保留小数
--> -->
<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> <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>