Merge branch 'master' of http://192.168.31.100:8088/framework/xosmopluginlibrary
This commit is contained in:
@@ -8,7 +8,7 @@ stages:
|
|||||||
- 04.AudioCore
|
- 04.AudioCore
|
||||||
- 05.TableTextConversion
|
- 05.TableTextConversion
|
||||||
- 06.UIFarme
|
- 06.UIFarme
|
||||||
- 07.RKVoiceCommand
|
- 07.RKTools
|
||||||
- 08.UniTask
|
- 08.UniTask
|
||||||
- 09.CodeChecker
|
- 09.CodeChecker
|
||||||
# 00.StaryEvo
|
# 00.StaryEvo
|
||||||
@@ -162,24 +162,24 @@ job_UIFarme:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 07.RKVoiceCommand
|
# 07.RKTools
|
||||||
job_RKVoiceCommand:
|
job_RKTools:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
stage: 07.RKVoiceCommand
|
stage: 07.RKTools
|
||||||
tags:
|
tags:
|
||||||
- xosmoPlugin
|
- xosmoPlugin
|
||||||
before_script:
|
before_script:
|
||||||
- echo '开始发布'
|
- echo '开始发布'
|
||||||
- node -v # 验证 Node.js 版本
|
- node -v # 验证 Node.js 版本
|
||||||
script:
|
script:
|
||||||
- cd Assets/07.RKVoiceCommand
|
- cd Assets/07.RKTools
|
||||||
# 获取当前版本
|
# 获取当前版本
|
||||||
- CURRENT_VERSION=$(node -p "require('./package.json').version")
|
- CURRENT_VERSION=$(node -p "require('./package.json').version")
|
||||||
- echo "registry=http://${SERVER_HOST}/npm" > .npmrc
|
- echo "registry=http://${SERVER_HOST}/npm" > .npmrc
|
||||||
- echo "//${SERVER_HOST}/:_authToken=${AuthToken}" >> .npmrc
|
- echo "//${SERVER_HOST}/:_authToken=${AuthToken}" >> .npmrc
|
||||||
- npm publish
|
- npm publish
|
||||||
- echo '07.RKVoiceCommand构建完成'
|
- echo '07.RKTools构建完成'
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
when: 'on_success'
|
when: 'on_success'
|
||||||
|
|
||||||
|
|||||||
8
Assets/07.RKTools/RunTime/AddInteraction.meta
Normal file
8
Assets/07.RKTools/RunTime/AddInteraction.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 198b77f2e2fe1e149bdb8e23f2c74b20
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
154
Assets/07.RKTools/RunTime/AddInteraction/RKAddInteraction.cs
Normal file
154
Assets/07.RKTools/RunTime/AddInteraction/RKAddInteraction.cs
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Rokid.UXR.Interaction;
|
||||||
|
using Stary.Evo;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public abstract class RKAddInteraction : MonoBehaviour
|
||||||
|
{
|
||||||
|
#region 触摸
|
||||||
|
/// <summary>
|
||||||
|
/// 添加触摸事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Touchedobject">被触碰物体</param>
|
||||||
|
/// <param name="TouchEvent">触碰后事件</param>
|
||||||
|
public virtual void ObjectAddTouchEvent(GameObject Touchedobject, System.Action<GameObject> TouchEvent, float TouchScale = 1.2f)
|
||||||
|
{
|
||||||
|
Collider ObjectCollider = Touchedobject.GetComponent<Collider>();
|
||||||
|
GrabInteractable GrabInteractable = Touchedobject.GetComponent<GrabInteractable>();
|
||||||
|
|
||||||
|
// 原有的组件设置优先级最高
|
||||||
|
if (ObjectCollider == null)
|
||||||
|
{
|
||||||
|
ObjectCollider = Touchedobject.AddComponent<BoxCollider>();
|
||||||
|
ObjectCollider.isTrigger = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GrabInteractable == null)
|
||||||
|
{
|
||||||
|
GrabInteractable = Touchedobject.AddComponent<GrabInteractable>();
|
||||||
|
GrabInteractable.rate = TouchScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
GrabInteractable.OnHoverBegin.AddListener(()=>TouchEvent?.Invoke(Touchedobject));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 暂停触摸事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Touchedobject">被触碰物体</param>
|
||||||
|
public virtual void ObjectPauseTouchEvent(GameObject Touchedobject)
|
||||||
|
{
|
||||||
|
Collider ObjectCollider = Touchedobject.GetComponent<Collider>();
|
||||||
|
if (ObjectCollider != null)
|
||||||
|
{
|
||||||
|
ObjectCollider.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 恢复触摸事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Touchedobject">被触碰物体</param>
|
||||||
|
public virtual void ObjectResumeTouchEvent(GameObject Touchedobject)
|
||||||
|
{
|
||||||
|
Collider ObjectCollider = Touchedobject.GetComponent<Collider>();
|
||||||
|
if (ObjectCollider != null)
|
||||||
|
{
|
||||||
|
ObjectCollider.enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 移除触摸事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Touchedobject">被触碰物体</param>
|
||||||
|
|
||||||
|
public virtual void ObjectRemoveTouchEvent(GameObject Touchedobject)
|
||||||
|
{
|
||||||
|
GrabInteractable GrabInteractable = Touchedobject.GetComponent<GrabInteractable>();
|
||||||
|
|
||||||
|
if (GrabInteractable != null)
|
||||||
|
{
|
||||||
|
GrabInteractable.OnHoverBegin.RemoveAllListeners();
|
||||||
|
Destroy(GrabInteractable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 拖动
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加拖动事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Dragedobject">被拖动物体</param>
|
||||||
|
/// <param name="DragingEvent">拖动时执行的方法</param>
|
||||||
|
public virtual void objectAddDrag(GameObject Dragedobject, System.Action<GameObject> DragingEvent = null, float DragScale = 1.2f)
|
||||||
|
{
|
||||||
|
Collider ObjectCollider = Dragedobject.GetComponent<Collider>();
|
||||||
|
GrabInteractable GrabInteractable = Dragedobject.GetComponent<GrabInteractable>();
|
||||||
|
Rigidbody Rigidbody = Dragedobject.GetComponent<Rigidbody>();
|
||||||
|
Throwable Throwable = Dragedobject.GetComponent<Throwable>();
|
||||||
|
|
||||||
|
// 原有的组件设置优先级最高
|
||||||
|
if (ObjectCollider == null)
|
||||||
|
{
|
||||||
|
ObjectCollider = Dragedobject.AddComponent<BoxCollider>();
|
||||||
|
ObjectCollider.isTrigger = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GrabInteractable == null)
|
||||||
|
{
|
||||||
|
GrabInteractable = Dragedobject.AddComponent<GrabInteractable>();
|
||||||
|
GrabInteractable.rate = DragScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Rigidbody == null)
|
||||||
|
{
|
||||||
|
Rigidbody = Dragedobject.AddComponent<Rigidbody>();
|
||||||
|
Rigidbody.useGravity = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Throwable == null)
|
||||||
|
{
|
||||||
|
Throwable = Dragedobject.AddComponent<Throwable>();
|
||||||
|
}
|
||||||
|
|
||||||
|
GrabInteractable.OnHeldUpdate.AddListener(()=>DragingEvent?.Invoke(Dragedobject));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 暂停拖动
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Dragedobject"></param>
|
||||||
|
public virtual void objectPauseDrag(GameObject Dragedobject)
|
||||||
|
{
|
||||||
|
Collider ObjectCollider = Dragedobject.GetComponent<Collider>();
|
||||||
|
if (ObjectCollider!= null) ObjectCollider.enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 恢复拖动
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Dragedobject"></param>
|
||||||
|
public virtual void objectResumeDrag(GameObject Dragedobject)
|
||||||
|
{
|
||||||
|
Collider ObjectCollider = Dragedobject.GetComponent<Collider>();
|
||||||
|
if (ObjectCollider!= null) ObjectCollider.enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void objectRemoveDrag(GameObject Dragedobject)
|
||||||
|
{
|
||||||
|
Throwable Throwable = Dragedobject.GetComponent<Throwable>();
|
||||||
|
GrabInteractable GrabInteractable = Dragedobject.GetComponent<GrabInteractable>();
|
||||||
|
if (Throwable != null) Destroy(Throwable);
|
||||||
|
if (GrabInteractable != null)
|
||||||
|
{
|
||||||
|
GrabInteractable.OnHeldUpdate.RemoveAllListeners();
|
||||||
|
Destroy(GrabInteractable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e5cbdc9e864eefd4fba9661707859b6e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/07.RKTools/RunTime/GestureRecognition.meta
Normal file
8
Assets/07.RKTools/RunTime/GestureRecognition.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cba726e4bef03144c99f9e7ef6fa0de8
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
128
Assets/07.RKTools/RunTime/GestureRecognition/GestureBase.cs
Normal file
128
Assets/07.RKTools/RunTime/GestureRecognition/GestureBase.cs
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using Rokid.UXR.Interaction;
|
||||||
|
|
||||||
|
public abstract class GestureBase : MonoBehaviour
|
||||||
|
{
|
||||||
|
private GestureBean leftBean = null;
|
||||||
|
private GestureBean rightBean = null;
|
||||||
|
|
||||||
|
protected void OnEnable()
|
||||||
|
{
|
||||||
|
GesEventInput.OnTrackedSuccess += OnTrackedSuccess;
|
||||||
|
GesEventInput.OnTrackedFailed += OnTrackedFailed;
|
||||||
|
GesEventInput.OnRenderHand += OnRenderHand;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void OnDisable()
|
||||||
|
{
|
||||||
|
GesEventInput.OnTrackedSuccess -= OnTrackedSuccess;
|
||||||
|
GesEventInput.OnTrackedFailed -= OnTrackedFailed;
|
||||||
|
GesEventInput.OnRenderHand -= OnRenderHand;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void FixedUpdate()
|
||||||
|
{
|
||||||
|
if (leftBean!=null)
|
||||||
|
{
|
||||||
|
GestureType type= GesEventInput.Instance.GetGestureType(HandType.LeftHand);
|
||||||
|
Vector3 handForward = GetSkeletonPose(SkeletonIndexFlag.PALM, HandType.LeftHand).forward;
|
||||||
|
GestureLeftSuccess(type,handForward);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GestureLeftFail();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rightBean != null)
|
||||||
|
{
|
||||||
|
GestureType type= GesEventInput.Instance.GetGestureType(HandType.RightHand);
|
||||||
|
Vector3 handForward = GetSkeletonPose(SkeletonIndexFlag.PALM, HandType.RightHand).forward;
|
||||||
|
GestureRightSuccess(type,handForward);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GestureRightFail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTrackedSuccess(HandType handType)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTrackedFailed(HandType handType)
|
||||||
|
{
|
||||||
|
if (handType == HandType.None)
|
||||||
|
{
|
||||||
|
leftBean = null;
|
||||||
|
rightBean = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handType == HandType.RightHand)
|
||||||
|
{
|
||||||
|
rightBean = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handType == HandType.LeftHand)
|
||||||
|
{
|
||||||
|
leftBean = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRenderHand(HandType handType, GestureBean gestureBean)
|
||||||
|
{
|
||||||
|
if (handType == HandType.RightHand)
|
||||||
|
{
|
||||||
|
rightBean = gestureBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handType == HandType.LeftHand)
|
||||||
|
{
|
||||||
|
leftBean = gestureBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handType == HandType.None)
|
||||||
|
{
|
||||||
|
rightBean = null;
|
||||||
|
leftBean = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取骨架点位置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index">骨架序号</param>
|
||||||
|
/// <param name="hand">哪只手</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Pose GetSkeletonPose(SkeletonIndexFlag index, HandType hand)
|
||||||
|
{
|
||||||
|
return GesEventInput.Instance.GetSkeletonPose(index, hand);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取手地朝向
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="handType">哪只手</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Vector3 GetHandForward(HandType handType)
|
||||||
|
{
|
||||||
|
Vector3 handForward = (GetSkeletonPose(SkeletonIndexFlag.MIDDLE_FINGER_MCP, handType).position -
|
||||||
|
GetSkeletonPose(SkeletonIndexFlag.WRIST, handType).position);
|
||||||
|
return handForward;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region 需要被重写的方法
|
||||||
|
|
||||||
|
public abstract void GestureLeftSuccess(GestureType gestureType, Vector3 handForward);
|
||||||
|
public abstract void GestureRightSuccess(GestureType gestureType, Vector3 handForward);
|
||||||
|
public abstract void GestureLeftFail();
|
||||||
|
public abstract void GestureRightFail();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d59c6f28c5e793c43a03e7ba7be931d8
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/07.RKTools/RunTime/RKVoiceCommand.meta
Normal file
8
Assets/07.RKTools/RunTime/RKVoiceCommand.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 97334fe27b1e8f2488496b4eebec0377
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "com.staryevo.rkvoicecommand",
|
"name": "com.staryevo.rktools",
|
||||||
"version": "1.0.3",
|
"version": "1.0.0",
|
||||||
"displayName": "07.RKVoiceCommand",
|
"displayName": "07.RKTools",
|
||||||
"description": "Rokid语音命令工具",
|
"description": "Rokid工具",
|
||||||
"unity": "2021.3",
|
"unity": "2021.3",
|
||||||
"unityRelease": "23f1",
|
"unityRelease": "23f1",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
Reference in New Issue
Block a user