Merge remote-tracking branch 'origin/master' into LouDi_Pig
This commit is contained in:
commit
6e4dda78bb
@ -196,6 +196,11 @@ public class ActionHelper
|
||||
var strAction = (XMLTool.StringListAction)act;
|
||||
return ScriptAction.Allocate(act.Name, act.Value, strAction.args[0]);
|
||||
}
|
||||
case "Collider":
|
||||
{
|
||||
var strAction = (XMLTool.StringListAction)act;
|
||||
return ColliderAction.Allocate(act.Value, strAction.args[0], strAction.args[1], strAction.args[2]);
|
||||
}
|
||||
default:
|
||||
Debug.LogError($"没有找到此Action的类型{act.Type}");
|
||||
break;
|
||||
|
||||
121
Assets/Scripts/Actions/ColliderAction.cs
Normal file
121
Assets/Scripts/Actions/ColliderAction.cs
Normal file
@ -0,0 +1,121 @@
|
||||
using QFramework.Example;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFramework
|
||||
{
|
||||
internal class ColliderAction : IAction
|
||||
{
|
||||
|
||||
public System.Action OnFinished { get; set; }
|
||||
|
||||
|
||||
private ColliderAction()
|
||||
{
|
||||
}
|
||||
|
||||
private static readonly SimpleObjectPool<ColliderAction> mPool =
|
||||
new SimpleObjectPool<ColliderAction>(() => new ColliderAction(), null, 10);
|
||||
string type;
|
||||
string path;
|
||||
string args;
|
||||
string deviceName;
|
||||
public static ColliderAction Allocate(string path, string deviceName, string type, string args, System.Action OnFinished = null)
|
||||
{
|
||||
var retNode = mPool.Allocate();
|
||||
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
||||
retNode.Deinited = false;
|
||||
retNode.Reset();
|
||||
retNode.type = type;
|
||||
retNode.path = path;
|
||||
retNode.args = args;
|
||||
retNode.deviceName = deviceName;
|
||||
return retNode;
|
||||
}
|
||||
|
||||
|
||||
public ulong ActionID { get; set; }
|
||||
public ActionStatus Status { get; set; }
|
||||
|
||||
public void OnStart()
|
||||
{
|
||||
GameObject obj = null;
|
||||
if (string.IsNullOrEmpty(deviceName))
|
||||
{
|
||||
obj = Utility.FindObj(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = DeviceController.Instance.GetDeviceObj(deviceName);
|
||||
}
|
||||
|
||||
if (obj != null)
|
||||
{
|
||||
Collider[] colliders = obj.GetComponents<Collider>();
|
||||
switch (type)
|
||||
{
|
||||
case "AddBox":
|
||||
string[] args = this.args.Split('|');
|
||||
Vector3 center = Utility.GetVector3FromStrArray(args[0]);
|
||||
Vector3 size = Utility.GetVector3FromStrArray(args[1]);
|
||||
BoxCollider box = obj.AddComponent<BoxCollider>();
|
||||
box.center = center;
|
||||
box.size = size;
|
||||
break;
|
||||
case "AddMesh":
|
||||
obj.AddComponent<MeshCollider>();
|
||||
break;
|
||||
case "Remove":
|
||||
foreach (var item in colliders)
|
||||
{
|
||||
GameObject.Destroy(item);
|
||||
}
|
||||
break;
|
||||
case "Active":
|
||||
bool active = true;
|
||||
bool.TryParse(this.args, out active);
|
||||
foreach (var item in colliders)
|
||||
{
|
||||
item.enabled = active;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Debug.LogError("ÕÒ²»µ½ÀàÐÍ£º" + type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
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; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Actions/ColliderAction.cs.meta
Normal file
11
Assets/Scripts/Actions/ColliderAction.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b900729b5bb03b4db0c4b085843ffe4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -897,6 +897,39 @@ namespace XMLTool
|
||||
newAction = act;
|
||||
}
|
||||
break;
|
||||
case "Collider":
|
||||
{
|
||||
var act = new StringListAction();
|
||||
XAttribute deviceName = action.Attribute("deviceName");
|
||||
if (deviceName != null)
|
||||
{
|
||||
act.args.Add(deviceName.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.args.Add("");
|
||||
}
|
||||
XAttribute colliderType = action.Attribute("colliderType");
|
||||
if (colliderType != null)
|
||||
{
|
||||
act.args.Add(colliderType.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.args.Add("¿Õ");
|
||||
}
|
||||
XAttribute arg = action.Attribute("args");
|
||||
if (arg != null)
|
||||
{
|
||||
act.args.Add(arg.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.args.Add("");
|
||||
}
|
||||
newAction = act;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
newAction = new Action();
|
||||
break;
|
||||
|
||||
@ -89,6 +89,14 @@
|
||||
<!--给程序使用的:自定义脚本 挂空预制体上 预制体放在Resources/CustomAction目录下 执行完毕后记得使用StringEventSystem.Global.Send(finishedEvent)-->
|
||||
<Action type="Script" value="MyAction" finishedEvent="111"/>
|
||||
|
||||
<!--
|
||||
给物体设置Collider path是物体路径 DeviceName是Device名字 与path二选一 colliderType:AddBox AddMesh Remove Active
|
||||
当colliderType为AddBox的时候 args用|分割后 第一个参数是 中心点 第二个参数是box碰撞的大小
|
||||
当colliderType为Active的时候 args为false或者是true
|
||||
当colliderType为AddMesh和Remove的时候 args不需要
|
||||
-->
|
||||
<Action type="Collider" path="路径和DeviceName二选一" deviceName="肠钳" colliderType="AddBox" args="0,0,0|1,1,1"></Action>
|
||||
|
||||
<!--预加载模块 要在app.xml的Data标签内-->
|
||||
<PreLoad>
|
||||
<Action type="Parallel">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user