Merge branch 'master' of http://192.168.31.100:8088/framework/xosmopluginlibrary
This commit is contained in:
@@ -165,7 +165,7 @@ namespace Stary.Evo.Editor
|
||||
else if (environmentType == EnvironmentType.Release)
|
||||
{
|
||||
viewer.clearBuildCacheToggle = false;
|
||||
selectedBuildPipelines = EBuildPipeline.BuiltinBuildPipeline;
|
||||
selectedBuildPipelines = EBuildPipeline.ScriptableBuildPipeline;
|
||||
|
||||
packageVersionX = packageVersionX > 1 ? packageVersionX : 1;
|
||||
packageVersionY =
|
||||
|
||||
@@ -169,7 +169,6 @@ namespace Stary.Evo.Editor
|
||||
#endregion
|
||||
|
||||
#region Update
|
||||
|
||||
[Title("BuildAssetButton", titleAlignment: TitleAlignments.Centered)] [HideLabel]
|
||||
public BuildAssetEntity onBuildPipelineEntity;
|
||||
|
||||
@@ -185,6 +184,7 @@ namespace Stary.Evo.Editor
|
||||
|
||||
private bool _isCheckDriveExist;
|
||||
|
||||
|
||||
[TitleGroup("UpdateAssetButton", alignment: TitleAlignments.Centered)]
|
||||
[HideLabel]
|
||||
[ShowIf(
|
||||
@@ -246,12 +246,18 @@ namespace Stary.Evo.Editor
|
||||
scroll = GUILayout.BeginScrollView(scroll);
|
||||
{
|
||||
base.DrawEditor(index);
|
||||
BuildServerPath();
|
||||
}
|
||||
GUILayout.EndScrollView();
|
||||
|
||||
BuildServerPath();
|
||||
UpdateBuildPipelineButtonName();
|
||||
}
|
||||
|
||||
|
||||
public void UpdateBuildPipelineButtonName()
|
||||
{
|
||||
onBuildPipelineEntity.SetButtonName($"打包资源包【版本:{BuildAssetDataSetting.packageVersion}】");
|
||||
onUpdateBuildPipelineEntity.SetButtonName($"更新至服务器【版本:{BuildAssetDataSetting.packageVersion}】");
|
||||
}
|
||||
/// <summary>
|
||||
/// 生成服务器路径
|
||||
/// </summary>
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Stary.Evo.Editor
|
||||
}
|
||||
|
||||
sb.AppendLine("}");
|
||||
File.WriteAllText("Assets/HotUpdate/GeneratedConst.cs", sb.ToString()); //写入硬盘
|
||||
File.WriteAllText("Assets/Main/Script/Runtime/HotUpdate/GeneratedConst.cs", sb.ToString()); //写入硬盘
|
||||
UnityEditor.AssetDatabase.Refresh(); //通知Unity刷新
|
||||
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ namespace Stary.Evo.Editor
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
MarkStatus();
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.FixFile();
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.SaveFile();
|
||||
|
||||
// CreateRes();
|
||||
Debug.Log("MarkAsset Successful");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.staryevo.main",
|
||||
"version": "1.0.30",
|
||||
"version": "1.1.1",
|
||||
"displayName": "00.StaryEvo",
|
||||
"description": "This is an Framework package",
|
||||
"unity": "2021.3",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
@@ -9,16 +11,33 @@ namespace Stary.Evo.InformationSave
|
||||
{
|
||||
private CustomEditorBase _customEditorBase;
|
||||
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
serializedObject.Update();
|
||||
_customEditorBase = target as CustomEditorBase;
|
||||
|
||||
if (string.IsNullOrEmpty(_customEditorBase.mationID))
|
||||
{
|
||||
_customEditorBase.mationID = _customEditorBase.gameObject.GetInstanceID().ToString();
|
||||
}
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Box("MationID:", GUILayout.MaxWidth(500));
|
||||
GUILayout.Box(_customEditorBase.mationID, GUILayout.MaxWidth(500));
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
_customEditorBase.Draw();
|
||||
//这个函数告诉引擎,相关对象所属于的Prefab已经发生了更改。方便,当我们更改了自定义对象的属性的时候,自动更新到所属的Prefab中
|
||||
if (GUI.changed && EditorApplication.isPlaying == false)
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
var prefabType = PrefabUtility.GetPrefabInstanceStatus(_customEditorBase);
|
||||
if (prefabType != PrefabInstanceStatus.NotAPrefab)
|
||||
{
|
||||
PrefabUtility.RecordPrefabInstancePropertyModifications(_customEditorBase);
|
||||
}
|
||||
EditorUtility.SetDirty(_customEditorBase);
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
}
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public abstract class AbstractInformation<T> : CustomEditorBase where T : InformationBase, new()
|
||||
{
|
||||
|
||||
[HideInInspector] public List<T> _list = new List<T>();
|
||||
|
||||
/// <summary>
|
||||
/// 配置文件存储路径
|
||||
/// </summary>
|
||||
string path = "InformationSaveData/ScriptObjectSaveData";
|
||||
|
||||
|
||||
public virtual void Add()
|
||||
{
|
||||
@@ -27,20 +22,6 @@ namespace Stary.Evo.InformationSave
|
||||
public abstract void Save(int index);
|
||||
public abstract void Switch(int index);
|
||||
|
||||
public virtual T GetTransform(string desc)
|
||||
{
|
||||
int index = _list.FindIndex(n => n.desc == desc);
|
||||
if (index != -1)
|
||||
{
|
||||
return _list[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"UnityEvo:{typeof(T)}:不存在该信息:" + desc);
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Delete(int index)
|
||||
{
|
||||
_list.RemoveAt(index);
|
||||
@@ -55,117 +36,49 @@ namespace Stary.Evo.InformationSave
|
||||
#region Editor
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private string _path;
|
||||
private string _directoryPath;
|
||||
|
||||
private void SetPath()
|
||||
{
|
||||
_directoryPath = Application.persistentDataPath + "/Ignore";
|
||||
_path = _directoryPath + "/" + mationID;
|
||||
}
|
||||
|
||||
//更新
|
||||
public void UpdateInformation()
|
||||
{
|
||||
string guid = GetPrefabGUID(this.gameObject)+GetPrefabHierarchyPath(this.gameObject);
|
||||
if (guid == "")
|
||||
SetPath();
|
||||
if (File.Exists(_path) == false)
|
||||
{
|
||||
UnityEditor.EditorUtility.DisplayDialog("错误", "可能存在错误\n1、无法在prefab预览中修改数据\n2、新增加物体需先同步为prefab", "确定");
|
||||
return;
|
||||
}
|
||||
ScriptObjectSave scriptObjectSaveData = Resources.Load<ScriptObjectSave>(path);
|
||||
if (scriptObjectSaveData == null)
|
||||
{
|
||||
Debug.LogError("UnityEvo:ScriptObjectSaveData配置文件丢失");
|
||||
Debug.LogError("不存在更新文件:" + _path);
|
||||
return;
|
||||
}
|
||||
|
||||
if (scriptObjectSaveData.dic.ContainsKey(guid))
|
||||
var json = File.ReadAllText(_path);
|
||||
List<T> tempList = JsonConvert.DeserializeObject<List<T>>(json);
|
||||
if (tempList != null && tempList.Count > 0)
|
||||
{
|
||||
_list.Clear();
|
||||
_list = scriptObjectSaveData.dic[guid].OfType<T>().ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"UnityEvo:ScriptObjectSaveData中未存储物体名为:{this.gameObject}\n guid为:{guid}的数据!!!");
|
||||
_list.AddRange(tempList);
|
||||
Debug.Log("更新成功!");
|
||||
}
|
||||
}
|
||||
|
||||
//动态保存
|
||||
public bool PlayingSave()
|
||||
{
|
||||
//文件保存
|
||||
|
||||
string guid = GetPrefabGUID(this.gameObject)+GetPrefabHierarchyPath(this.gameObject);
|
||||
if (guid == "")
|
||||
if (UnityEditor.EditorApplication.isPlaying)
|
||||
{
|
||||
UnityEditor.EditorUtility.DisplayDialog("错误", "可能存在错误\n1、无法在prefab预览中修改数据\n2、新增加物体需先同步为prefab", "确定");
|
||||
return false;
|
||||
}
|
||||
// 加载 ScriptObjectSaveData
|
||||
ScriptObjectSave scriptObjectSaveData = Resources.Load<ScriptObjectSave>(path);
|
||||
if (scriptObjectSaveData == null)
|
||||
{
|
||||
scriptObjectSaveData = CheckAndCreateFoldersAndAsset();
|
||||
//Debug.Log("创建了ScriptObjectSaveData文件");
|
||||
SetPath();
|
||||
if (Directory.Exists(_directoryPath) == false) Directory.CreateDirectory(_directoryPath);
|
||||
var json = JsonConvert.SerializeObject(_list);
|
||||
File.WriteAllText(_path,json);
|
||||
Debug.Log("动态保存成功!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (scriptObjectSaveData.dic == null)
|
||||
{
|
||||
Debug.LogError("UnityEvo:ScriptObjectSaveData的dic为空");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查是否已经存在相同的键
|
||||
if (scriptObjectSaveData.dic.ContainsKey(guid))
|
||||
{
|
||||
// 如果存在,选择是否替换原有的 List
|
||||
if (UnityEditor.EditorUtility.DisplayDialog("提示",
|
||||
$"数据集下已有相同名称的物体数据\n是否覆盖更新!!!\n 物体名为:{this.gameObject}\n guid为:{guid}", "确定",
|
||||
"取消"))
|
||||
{
|
||||
scriptObjectSaveData.dic[guid] = new List<InformationBase>(_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果不存在,添加新的键值对
|
||||
scriptObjectSaveData.dic.Add(guid, new List<InformationBase>(_list));
|
||||
}
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
EditorUtility.SetDirty(scriptObjectSaveData);
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private ScriptObjectSave CheckAndCreateFoldersAndAsset()
|
||||
{
|
||||
string ResourcesFolderName = "Resources";
|
||||
string InformationSaveDataFolderName = "InformationSaveData";
|
||||
string ScriptObjectSaveDataFileName = "ScriptObjectSaveData";
|
||||
ScriptObjectSave scriptableObject;
|
||||
|
||||
// 判断是否创建Resources文件夹
|
||||
string resourcesPath = Path.Combine(Application.dataPath, ResourcesFolderName);
|
||||
if (!Directory.Exists(resourcesPath))
|
||||
{
|
||||
Directory.CreateDirectory(resourcesPath);
|
||||
}
|
||||
|
||||
// 判断是否创建InformationSaveData文件夹
|
||||
string informationSaveDataPath = Path.Combine(resourcesPath, InformationSaveDataFolderName);
|
||||
if (!Directory.Exists(informationSaveDataPath))
|
||||
{
|
||||
Directory.CreateDirectory(informationSaveDataPath);
|
||||
}
|
||||
|
||||
// 创建ScriptObjectSaveData.asset文件
|
||||
scriptableObject = ScriptableObject.CreateInstance<ScriptObjectSave>();
|
||||
AssetDatabase.CreateAsset(scriptableObject,
|
||||
"Assets/" + ResourcesFolderName + "/" + InformationSaveDataFolderName + "/" +
|
||||
ScriptObjectSaveDataFileName + ".asset");
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
Debug.Log("UnityEvo:创建了: " + "Assets/" + ResourcesFolderName + "/" + InformationSaveDataFolderName + "/" +
|
||||
ScriptObjectSaveDataFileName + ".asset 资产");
|
||||
return scriptableObject;
|
||||
return false;
|
||||
}
|
||||
|
||||
//绘制
|
||||
@@ -181,7 +94,7 @@ namespace Stary.Evo.InformationSave
|
||||
if (GUILayout.Button("保存"))
|
||||
{
|
||||
Save(i);
|
||||
if (PlayingSave()) Debug.Log("UnityEvo:保存成功!");
|
||||
if (PlayingSave() == false) Debug.Log("保存成功!");
|
||||
}
|
||||
|
||||
if (GUILayout.Button("上移") && i > 0)
|
||||
@@ -220,54 +133,6 @@ namespace Stary.Evo.InformationSave
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private string GetCurrentGUID()
|
||||
{
|
||||
string assetPath = AssetDatabase.GetAssetPath(this);
|
||||
if (!string.IsNullOrEmpty(assetPath))
|
||||
{
|
||||
return AssetDatabase.AssetPathToGUID(assetPath);
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private string GetPrefabGUID(GameObject obj)
|
||||
{
|
||||
string assetPath = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(obj);
|
||||
Debug.Log("UnityEvo:GetPrefabHierarchyPath:" + GetPrefabHierarchyPath(obj));
|
||||
|
||||
if (!string.IsNullOrEmpty(assetPath))
|
||||
{
|
||||
return AssetDatabase.AssetPathToGUID(assetPath);
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
||||
private string GetPrefabHierarchyPath(GameObject obj)
|
||||
{
|
||||
var path = new System.Text.StringBuilder();
|
||||
var current = obj.transform;
|
||||
//检测该预制体是否是实例
|
||||
var root = PrefabUtility.GetNearestPrefabInstanceRoot(obj);
|
||||
if (root != null)
|
||||
{
|
||||
while (current != null && current != root.transform)
|
||||
{
|
||||
path.Insert(0, current.name);
|
||||
path.Insert(0, "/");
|
||||
current = current.parent;
|
||||
}
|
||||
|
||||
|
||||
return path.ToString();
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
#else
|
||||
public override void Draw(){}
|
||||
#endif
|
||||
@@ -275,7 +140,6 @@ namespace Stary.Evo.InformationSave
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class InformationBase
|
||||
{
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using Unity.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
public abstract class CustomEditorBase : MonoBehaviour
|
||||
{
|
||||
[HideInInspector]
|
||||
public string mationID;
|
||||
public abstract void Draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6543baeed3e940268fc41b7eb6fa31a7
|
||||
timeCreated: 1735626715
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Stary.Evo.InformationSave;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Sirenix.OdinInspector;
|
||||
|
||||
namespace Stary.Evo.InformationSave
|
||||
{
|
||||
[CreateAssetMenu()]
|
||||
public class ScriptObjectSave : SerializedScriptableObject
|
||||
{
|
||||
public Dictionary<string, List<InformationBase>> dic = new Dictionary<string, List<InformationBase>>();
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a08c59ee0e6844441825e5b5427d1e4c, type: 3}
|
||||
m_Name: ScriptObjectSaveData
|
||||
m_EditorClassIdentifier:
|
||||
serializationData:
|
||||
SerializedFormat: 2
|
||||
SerializedBytes:
|
||||
ReferencedUnityObjects: []
|
||||
SerializedBytesString:
|
||||
Prefab: {fileID: 0}
|
||||
PrefabModificationsReferencedUnityObjects: []
|
||||
PrefabModifications: []
|
||||
SerializationNodes:
|
||||
- Name: dic
|
||||
Entry: 7
|
||||
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Collections.Generic.List`1[[Stary.Evo.InformationSave.InformationBase,
|
||||
Assembly-CSharp]], mscorlib]], mscorlib
|
||||
- Name: comparer
|
||||
Entry: 7
|
||||
Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String,
|
||||
mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e2aa5a2cf392c145a1055e82ed08b6f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.staryevo.informationsave",
|
||||
"displayName": "02.InformationSave",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.5",
|
||||
"description": "位置配置工具",
|
||||
"unity": "2021.3",
|
||||
"unityRelease": "30f1",
|
||||
|
||||
@@ -132,12 +132,8 @@ namespace Stary.Evo.TableTextConversion
|
||||
|
||||
messageInfo.voice = FilterTo(table.Rows[j][3].ToString());
|
||||
|
||||
messageInfo.trigger = FilterTo(table.Rows[j][4].ToString());
|
||||
messageInfo.uirelated = FilterTo(table.Rows[j][5].ToString());
|
||||
messageInfo.description = FilterTo(table.Rows[j][6].ToString());
|
||||
|
||||
messageInfo.format = FilterTo(table.Rows[j][7].ToString());
|
||||
messageInfo.notes = FilterTo(table.Rows[j][8].ToString());
|
||||
|
||||
messageInfo.uirelated = FilterTo(table.Rows[j][4].ToString());
|
||||
//添加数据
|
||||
messageInfos.Add(messageInfo);
|
||||
}
|
||||
@@ -244,15 +240,7 @@ namespace Stary.Evo.TableTextConversion
|
||||
messageInfo.subtitle.Add(subtitleInfo);
|
||||
}
|
||||
|
||||
messageInfo.nodelocation = FilterTo(table.Rows[j][7].ToString());
|
||||
|
||||
messageInfo.description = FilterTo(table.Rows[j][8].ToString());
|
||||
messageInfo.displaycondition = FilterTo(table.Rows[j][9].ToString());
|
||||
|
||||
messageInfo.animationrequirement = FilterTo(table.Rows[j][10].ToString());
|
||||
messageInfo.size = FilterTo(table.Rows[j][11].ToString());
|
||||
messageInfo.format = FilterTo(table.Rows[j][12].ToString());
|
||||
messageInfo.notes = FilterTo(table.Rows[j][13].ToString());
|
||||
|
||||
//添加数据
|
||||
messageInfos.Add(messageInfo);
|
||||
infoIndex++;
|
||||
|
||||
@@ -22,11 +22,7 @@ namespace Stary.Evo.TableTextConversion
|
||||
// 名称描述
|
||||
public string filename;
|
||||
public string voice;
|
||||
public string trigger;
|
||||
public string uirelated;
|
||||
public string description;
|
||||
public string format;
|
||||
public string notes;
|
||||
}
|
||||
|
||||
public enum AudioType
|
||||
|
||||
@@ -23,17 +23,7 @@ namespace Stary.Evo.TableTextConversion
|
||||
|
||||
public string uitype;
|
||||
public List<SubtitleInfo> subtitle;
|
||||
|
||||
public string nodelocation;
|
||||
|
||||
public string description;
|
||||
|
||||
public string displaycondition;
|
||||
public string animationrequirement;
|
||||
public string size;
|
||||
public string format;
|
||||
|
||||
public string notes;
|
||||
}
|
||||
[Serializable]
|
||||
public class SubtitleInfo
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.staryevo.tabletextconversion",
|
||||
"version": "1.0.9",
|
||||
"version": "1.1.1",
|
||||
"displayName": "05.TableTextConversion",
|
||||
"description": "表格转化工具",
|
||||
"unity": "2021.3",
|
||||
|
||||
@@ -262,6 +262,9 @@ namespace Stary.Evo.UIFarme
|
||||
public override void Dispose()
|
||||
{
|
||||
PopAll();
|
||||
stackPanel = null;
|
||||
queuePanel =null;
|
||||
dicUI = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.staryevo.uifarme",
|
||||
"displayName": "06.UIFarme",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.7",
|
||||
"description": "UI模板框架工具",
|
||||
"unity": "2021.3",
|
||||
"unityRelease": "30f1",
|
||||
|
||||
3
Assets/07.RKTools/Editor.meta
Normal file
3
Assets/07.RKTools/Editor.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48a19cb902094ecc8ceb242ada697751
|
||||
timeCreated: 1747641441
|
||||
52
Assets/07.RKTools/Editor/ARTrackedImageEvoObjEditor.cs
Normal file
52
Assets/07.RKTools/Editor/ARTrackedImageEvoObjEditor.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Stary.Evo.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.RKTools
|
||||
{
|
||||
[CustomEditor(typeof(ARTrackedImageEvoObj))]
|
||||
public class ARTrackedImageEvoObjEditor : UnityEditor.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 序列化属性,在OnEnable中获取
|
||||
/// </summary>
|
||||
private SerializedProperty domain;
|
||||
|
||||
private SerializedProperty trackedTransform;
|
||||
|
||||
/// <summary>
|
||||
private string[] domainNames;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
domain = serializedObject.FindProperty("domain");
|
||||
trackedTransform = serializedObject.FindProperty("trackedTransform");
|
||||
domainNames = CreatAssetWindow.GetCreatDomainAllName();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
// 获取当前选中的索引
|
||||
int selectedIndex = System.Array.IndexOf(domainNames, domain.stringValue);
|
||||
if (selectedIndex < 0) selectedIndex = 0; // 默认选中第一个
|
||||
|
||||
// 绘制下拉选择框
|
||||
selectedIndex = EditorGUILayout.Popup("Domain", selectedIndex, domainNames);
|
||||
|
||||
// 更新选择的域名
|
||||
domain.stringValue = domainNames[selectedIndex];
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var newTrackedTransform
|
||||
= EditorGUILayout.ObjectField(new GUIContent("Tracked Transform"), trackedTransform.objectReferenceValue, typeof(Transform), true) as Transform;
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
trackedTransform.objectReferenceValue = newTrackedTransform;
|
||||
}
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
base.OnInspectorGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72092625ebc64a538340f91e8ddedfc3
|
||||
timeCreated: 1747641457
|
||||
19
Assets/07.RKTools/Editor/RKTools.Editor.asmdef
Normal file
19
Assets/07.RKTools/Editor/RKTools.Editor.asmdef
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "RKTools.Editor",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:10c9b58b77ad42b4193e2a393b1a9899",
|
||||
"GUID:044184040b21c434b8aee6f2a3424c06"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
3
Assets/07.RKTools/Editor/RKTools.Editor.asmdef.meta
Normal file
3
Assets/07.RKTools/Editor/RKTools.Editor.asmdef.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b267fe3452f4939bf6a21810fbeab2b
|
||||
timeCreated: 1747641687
|
||||
@@ -4,151 +4,158 @@ using Rokid.UXR.Interaction;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
|
||||
public static class RKAddInteractionExtension
|
||||
namespace Stary.Evo.RKTools
|
||||
{
|
||||
#region 触摸
|
||||
/// <summary>
|
||||
/// 添加触摸事件
|
||||
/// </summary>
|
||||
/// <param name="Touchedobject">被触碰物体</param>
|
||||
/// <param name="TouchEvent">触碰后事件</param>
|
||||
public static void ObjectAddTouchEvent(this GameObject Touchedobject, System.Action<GameObject> TouchEvent, float TouchScale = 1.2f)
|
||||
public static class RKAddInteractionExtension
|
||||
{
|
||||
Collider ObjectCollider = Touchedobject.GetComponent<Collider>();
|
||||
GrabInteractable GrabInteractable = Touchedobject.GetComponent<GrabInteractable>();
|
||||
#region 触摸
|
||||
|
||||
// 原有的组件设置优先级最高
|
||||
if (ObjectCollider == null)
|
||||
/// <summary>
|
||||
/// 添加触摸事件
|
||||
/// </summary>
|
||||
/// <param name="Touchedobject">被触碰物体</param>
|
||||
/// <param name="TouchEvent">触碰后事件</param>
|
||||
public static void ObjectAddTouchEvent(this GameObject Touchedobject, System.Action<GameObject> TouchEvent,
|
||||
float TouchScale = 1.2f)
|
||||
{
|
||||
ObjectCollider = Touchedobject.AddComponent<BoxCollider>();
|
||||
ObjectCollider.isTrigger = true;
|
||||
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));
|
||||
}
|
||||
|
||||
if (GrabInteractable == null)
|
||||
/// <summary>
|
||||
/// 暂停触摸事件
|
||||
/// </summary>
|
||||
/// <param name="Touchedobject">被触碰物体</param>
|
||||
public static void ObjectPauseTouchEvent(this GameObject Touchedobject)
|
||||
{
|
||||
GrabInteractable = Touchedobject.AddComponent<GrabInteractable>();
|
||||
GrabInteractable.rate = TouchScale;
|
||||
Collider ObjectCollider = Touchedobject.GetComponent<Collider>();
|
||||
if (ObjectCollider != null)
|
||||
{
|
||||
ObjectCollider.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
GrabInteractable.OnHoverBegin.AddListener(()=>TouchEvent?.Invoke(Touchedobject));
|
||||
|
||||
/// <summary>
|
||||
/// 恢复触摸事件
|
||||
/// </summary>
|
||||
/// <param name="Touchedobject">被触碰物体</param>
|
||||
public static void ObjectResumeTouchEvent(this GameObject Touchedobject)
|
||||
{
|
||||
Collider ObjectCollider = Touchedobject.GetComponent<Collider>();
|
||||
if (ObjectCollider != null)
|
||||
{
|
||||
ObjectCollider.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除触摸事件
|
||||
/// </summary>
|
||||
/// <param name="Touchedobject">被触碰物体</param>
|
||||
|
||||
public static void ObjectRemoveTouchEvent(this GameObject Touchedobject)
|
||||
{
|
||||
GrabInteractable GrabInteractable = Touchedobject.GetComponent<GrabInteractable>();
|
||||
|
||||
if (GrabInteractable != null)
|
||||
{
|
||||
GrabInteractable.OnHoverBegin.RemoveAllListeners();
|
||||
Object.Destroy(GrabInteractable);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 拖动
|
||||
|
||||
/// <summary>
|
||||
/// 添加拖动事件
|
||||
/// </summary>
|
||||
/// <param name="Dragedobject">被拖动物体</param>
|
||||
/// <param name="DragingEvent">拖动时执行的方法</param>
|
||||
public static void objectAddDrag(this 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 static void objectPauseDrag(this GameObject Dragedobject)
|
||||
{
|
||||
Collider ObjectCollider = Dragedobject.GetComponent<Collider>();
|
||||
if (ObjectCollider != null) ObjectCollider.enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复拖动
|
||||
/// </summary>
|
||||
/// <param name="Dragedobject"></param>
|
||||
public static void objectResumeDrag(this GameObject Dragedobject)
|
||||
{
|
||||
Collider ObjectCollider = Dragedobject.GetComponent<Collider>();
|
||||
if (ObjectCollider != null) ObjectCollider.enabled = true;
|
||||
}
|
||||
|
||||
public static void objectRemoveDrag(this GameObject Dragedobject)
|
||||
{
|
||||
Throwable Throwable = Dragedobject.GetComponent<Throwable>();
|
||||
GrabInteractable GrabInteractable = Dragedobject.GetComponent<GrabInteractable>();
|
||||
if (Throwable != null) Object.Destroy(Throwable);
|
||||
if (GrabInteractable != null)
|
||||
{
|
||||
GrabInteractable.OnHeldUpdate.RemoveAllListeners();
|
||||
Object.Destroy(GrabInteractable);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 暂停触摸事件
|
||||
/// </summary>
|
||||
/// <param name="Touchedobject">被触碰物体</param>
|
||||
public static void ObjectPauseTouchEvent(this GameObject Touchedobject)
|
||||
{
|
||||
Collider ObjectCollider = Touchedobject.GetComponent<Collider>();
|
||||
if (ObjectCollider != null)
|
||||
{
|
||||
ObjectCollider.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复触摸事件
|
||||
/// </summary>
|
||||
/// <param name="Touchedobject">被触碰物体</param>
|
||||
public static void ObjectResumeTouchEvent(this GameObject Touchedobject)
|
||||
{
|
||||
Collider ObjectCollider = Touchedobject.GetComponent<Collider>();
|
||||
if (ObjectCollider != null)
|
||||
{
|
||||
ObjectCollider.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除触摸事件
|
||||
/// </summary>
|
||||
/// <param name="Touchedobject">被触碰物体</param>
|
||||
|
||||
public static void ObjectRemoveTouchEvent(this GameObject Touchedobject)
|
||||
{
|
||||
GrabInteractable GrabInteractable = Touchedobject.GetComponent<GrabInteractable>();
|
||||
|
||||
if (GrabInteractable != null)
|
||||
{
|
||||
GrabInteractable.OnHoverBegin.RemoveAllListeners();
|
||||
Object.Destroy(GrabInteractable);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 拖动
|
||||
|
||||
/// <summary>
|
||||
/// 添加拖动事件
|
||||
/// </summary>
|
||||
/// <param name="Dragedobject">被拖动物体</param>
|
||||
/// <param name="DragingEvent">拖动时执行的方法</param>
|
||||
public static void objectAddDrag(this 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 static void objectPauseDrag(this GameObject Dragedobject)
|
||||
{
|
||||
Collider ObjectCollider = Dragedobject.GetComponent<Collider>();
|
||||
if (ObjectCollider!= null) ObjectCollider.enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复拖动
|
||||
/// </summary>
|
||||
/// <param name="Dragedobject"></param>
|
||||
public static void objectResumeDrag(this GameObject Dragedobject)
|
||||
{
|
||||
Collider ObjectCollider = Dragedobject.GetComponent<Collider>();
|
||||
if (ObjectCollider!= null) ObjectCollider.enabled = true;
|
||||
}
|
||||
|
||||
public static void objectRemoveDrag(this GameObject Dragedobject)
|
||||
{
|
||||
Throwable Throwable = Dragedobject.GetComponent<Throwable>();
|
||||
GrabInteractable GrabInteractable = Dragedobject.GetComponent<GrabInteractable>();
|
||||
if (Throwable != null) Object.Destroy(Throwable);
|
||||
if (GrabInteractable != null)
|
||||
{
|
||||
GrabInteractable.OnHeldUpdate.RemoveAllListeners();
|
||||
Object.Destroy(GrabInteractable);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,126 +3,129 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Rokid.UXR.Interaction;
|
||||
|
||||
public abstract class GestureBase : MonoBehaviour
|
||||
namespace Stary.Evo.RKTools
|
||||
{
|
||||
private GestureBean leftBean = null;
|
||||
private GestureBean rightBean = null;
|
||||
|
||||
protected void OnEnable()
|
||||
public abstract class GestureBase : MonoBehaviour
|
||||
{
|
||||
GesEventInput.OnTrackedSuccess += OnTrackedSuccess;
|
||||
GesEventInput.OnTrackedFailed += OnTrackedFailed;
|
||||
GesEventInput.OnRenderHand += OnRenderHand;
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "RKVoiceCommand.RunTime",
|
||||
"name": "RKTools.RunTime",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:6447e10b87dc140ab924878c1ecef665",
|
||||
|
||||
@@ -4,61 +4,67 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Stary.Evo;
|
||||
|
||||
public interface IVoiceCommandSystem : ISystem
|
||||
namespace Stary.Evo.RKTools
|
||||
{
|
||||
public void AddVoiceCommand(string content,string spell, Action action);
|
||||
public void DeleteVoiceCommand(string content);
|
||||
public void ClearAllVoiceCommands();
|
||||
}
|
||||
|
||||
public class VoiceCommandSystem : AbstractSystem,IVoiceCommandSystem
|
||||
{
|
||||
private VoiceCommandController _voiceController;
|
||||
protected virtual string ControllerName
|
||||
public interface IVoiceCommandSystem : ISystem
|
||||
{
|
||||
get { return "VoiceCommandController"; }
|
||||
public void AddVoiceCommand(string content, string spell, Action action);
|
||||
public void DeleteVoiceCommand(string content);
|
||||
public void ClearAllVoiceCommands();
|
||||
}
|
||||
|
||||
private void createVoiceCommandContriller()
|
||||
|
||||
public class VoiceCommandSystem : AbstractSystem, IVoiceCommandSystem
|
||||
{
|
||||
GameObject VoiceControllerObject = GameObject.Find(ControllerName);
|
||||
if (VoiceControllerObject == null)
|
||||
private VoiceCommandController _voiceController;
|
||||
|
||||
protected virtual string ControllerName
|
||||
{
|
||||
VoiceControllerObject = new GameObject(ControllerName);
|
||||
get { return "VoiceCommandController"; }
|
||||
}
|
||||
_voiceController = VoiceControllerObject.GetComponent<VoiceCommandController>();
|
||||
if (_voiceController == null)
|
||||
|
||||
private void createVoiceCommandContriller()
|
||||
{
|
||||
_voiceController = VoiceControllerObject.AddComponent<VoiceCommandController>();
|
||||
GameObject VoiceControllerObject = GameObject.Find(ControllerName);
|
||||
if (VoiceControllerObject == null)
|
||||
{
|
||||
VoiceControllerObject = new GameObject(ControllerName);
|
||||
}
|
||||
|
||||
_voiceController = VoiceControllerObject.GetComponent<VoiceCommandController>();
|
||||
if (_voiceController == null)
|
||||
{
|
||||
_voiceController = VoiceControllerObject.AddComponent<VoiceCommandController>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddVoiceCommand(string content,string spell, Action action)
|
||||
{
|
||||
if (_voiceController == null) createVoiceCommandContriller();
|
||||
_voiceController.RegisteredVoiceCommand(content, spell, action);
|
||||
}
|
||||
|
||||
public void DeleteVoiceCommand(string content)
|
||||
{
|
||||
if(_voiceController!=null) _voiceController.DeleteVoiceCommand(content);
|
||||
}
|
||||
|
||||
public void ClearAllVoiceCommands()
|
||||
{
|
||||
if (_voiceController != null)
|
||||
public void AddVoiceCommand(string content, string spell, Action action)
|
||||
{
|
||||
_voiceController.ClearAllVoiceCommand();
|
||||
GameObject.Destroy(_voiceController.gameObject);
|
||||
if (_voiceController == null) createVoiceCommandContriller();
|
||||
_voiceController.RegisteredVoiceCommand(content, spell, action);
|
||||
}
|
||||
}
|
||||
public override void Dispose()
|
||||
{
|
||||
ClearAllVoiceCommands();
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
public void DeleteVoiceCommand(string content)
|
||||
{
|
||||
if (_voiceController != null) _voiceController.DeleteVoiceCommand(content);
|
||||
}
|
||||
|
||||
public void ClearAllVoiceCommands()
|
||||
{
|
||||
if (_voiceController != null)
|
||||
{
|
||||
_voiceController.ClearAllVoiceCommand();
|
||||
GameObject.Destroy(_voiceController.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
ClearAllVoiceCommands();
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,87 +6,92 @@ using Stary.Evo;
|
||||
using Rokid.UXR.Module;
|
||||
using UnityEngine.Android;
|
||||
|
||||
public class VoiceCommandController : MonoBehaviour
|
||||
namespace Stary.Evo.RKTools
|
||||
{
|
||||
public Dictionary<string, Action> VoiceCommands = new Dictionary<string, Action>();
|
||||
public bool isInit = false;
|
||||
|
||||
void Awake()
|
||||
public class VoiceCommandController : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
public Dictionary<string, Action> VoiceCommands = new Dictionary<string, Action>();
|
||||
public bool isInit = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
//if (!Permission.HasUserAuthorizedPermission("android.permission.RECORD_AUDIO")) return;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册语音指令
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="spell"></param>
|
||||
/// <param name="action"></param>
|
||||
public void RegisteredVoiceCommand(string content, string spell, Action action)
|
||||
{
|
||||
if (!isInit)
|
||||
void Awake()
|
||||
{
|
||||
if (!Permission.HasUserAuthorizedPermission("android.permission.RECORD_AUDIO"))
|
||||
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
//if (!Permission.HasUserAuthorizedPermission("android.permission.RECORD_AUDIO")) return;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册语音指令
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="spell"></param>
|
||||
/// <param name="action"></param>
|
||||
public void RegisteredVoiceCommand(string content, string spell, Action action)
|
||||
{
|
||||
if (!isInit)
|
||||
{
|
||||
Permission.RequestUserPermission("android.permission.RECORD_AUDIO");
|
||||
if (!Permission.HasUserAuthorizedPermission("android.permission.RECORD_AUDIO"))
|
||||
{
|
||||
Permission.RequestUserPermission("android.permission.RECORD_AUDIO");
|
||||
}
|
||||
|
||||
ModuleManager.Instance.RegistModule("com.rokid.voicecommand.VoiceCommandHelper", false);
|
||||
OfflineVoiceModule.Instance.ChangeVoiceCommandLanguage(LANGUAGE.CHINESE);
|
||||
isInit = true;
|
||||
}
|
||||
|
||||
ModuleManager.Instance.RegistModule("com.rokid.voicecommand.VoiceCommandHelper", false);
|
||||
OfflineVoiceModule.Instance.ChangeVoiceCommandLanguage(LANGUAGE.CHINESE);
|
||||
isInit = true;
|
||||
}
|
||||
|
||||
if (!VoiceCommands.ContainsKey(content))
|
||||
{
|
||||
VoiceCommands.Add(content, action);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"语音命令 :“'{content}' ”已经注册了!!!");
|
||||
return;
|
||||
}
|
||||
OfflineVoiceModule.Instance.AddInstruct(LANGUAGE.CHINESE, content, spell, this.gameObject.name, "OnReceive");
|
||||
OfflineVoiceModule.Instance.Commit();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除语音指令
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
public void DeleteVoiceCommand(string content)
|
||||
{
|
||||
if (VoiceCommands.ContainsKey(content))
|
||||
{
|
||||
VoiceCommands.Remove(content);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"语音命令 :“'{content}' 不存在!!!");
|
||||
}
|
||||
}
|
||||
if (!VoiceCommands.ContainsKey(content))
|
||||
{
|
||||
VoiceCommands.Add(content, action);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"语音命令 :“'{content}' ”已经注册了!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
OfflineVoiceModule.Instance.AddInstruct(LANGUAGE.CHINESE, content, spell, this.gameObject.name,
|
||||
"OnReceive");
|
||||
OfflineVoiceModule.Instance.Commit();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除语音指令
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
public void DeleteVoiceCommand(string content)
|
||||
{
|
||||
if (VoiceCommands.ContainsKey(content))
|
||||
{
|
||||
VoiceCommands.Remove(content);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"语音命令 :“'{content}' 不存在!!!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除所有语音指令
|
||||
/// </summary>
|
||||
public void ClearAllVoiceCommand()
|
||||
{
|
||||
VoiceCommands.Clear();
|
||||
OfflineVoiceModule.Instance.ClearAllInstruct();
|
||||
OfflineVoiceModule.Instance.Commit();
|
||||
}
|
||||
|
||||
void OnReceive(string msg)
|
||||
{
|
||||
if (VoiceCommands.TryGetValue(msg, out Action action))
|
||||
{
|
||||
action?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除所有语音指令
|
||||
/// </summary>
|
||||
public void ClearAllVoiceCommand()
|
||||
{
|
||||
VoiceCommands.Clear();
|
||||
OfflineVoiceModule.Instance.ClearAllInstruct();
|
||||
OfflineVoiceModule.Instance.Commit();
|
||||
}
|
||||
|
||||
void OnReceive(string msg)
|
||||
{
|
||||
if (VoiceCommands.TryGetValue(msg, out Action action))
|
||||
{
|
||||
action?.Invoke();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/07.RKTools/RunTime/TrackedImage.meta
Normal file
3
Assets/07.RKTools/RunTime/TrackedImage.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef115ccabf224be8a3f28036d2f0b488
|
||||
timeCreated: 1747635144
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Rokid.UXR.Module;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.RKTools
|
||||
{
|
||||
public class ARTrackedImageEvoObj : ARTrackedImageObj
|
||||
{
|
||||
[HideInInspector]
|
||||
public string domain;
|
||||
[HideInInspector]
|
||||
public Transform trackedTransform;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
if (trackedTransform == null)
|
||||
{
|
||||
trackedTransform=this.transform;
|
||||
Debug.Log("StaryEvo:TrackedImageEvoObj: trackedTransform 未赋值,以自动赋值为自身");
|
||||
}
|
||||
OnARTrackedImageAdded.AddListener(OnARTrackedImageAddedEvent); ;
|
||||
}
|
||||
|
||||
private void OnARTrackedImageAddedEvent(ARTrackedImageObj obj)
|
||||
{
|
||||
TrackedImageEvoManager trackedImageEvoManager = ARTrackedImageManager.Instance as TrackedImageEvoManager;
|
||||
trackedImageEvoManager.SetTrackedImageEvoData(trackedImageIndex,domain,trackedTransform);
|
||||
}
|
||||
|
||||
public void OnDestroy()
|
||||
{
|
||||
OnARTrackedImageAdded.RemoveListener(OnARTrackedImageAddedEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a08c59ee0e6844441825e5b5427d1e4c
|
||||
guid: 9cc1ca9700549444c93d7ea3d156ab5c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Rokid.UXR.Module;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.RKTools
|
||||
{
|
||||
public class TrackedImageEvoManager : ARTrackedImageManager
|
||||
{
|
||||
[TableList] public List<TarkedImageEvoData> TrackedImages;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
TrackedImages = new List<TarkedImageEvoData>();
|
||||
}
|
||||
|
||||
public TarkedImageEvoData GetTrackedImageEvoData(int imageIndex)
|
||||
{
|
||||
foreach (var imageEvoData in TrackedImages)
|
||||
{
|
||||
if (imageEvoData.imageIndex == imageIndex)
|
||||
{
|
||||
return imageEvoData;
|
||||
}
|
||||
}
|
||||
Debug.LogError($"StaryEvo:未找到对应的图片的id数据,请检查是否进行前置识别 index:{imageIndex}");
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetTrackedImageEvoData(int imageIndex,string domain, Transform transform)
|
||||
{
|
||||
foreach (var imageEvoData in TrackedImages)
|
||||
{
|
||||
if (imageEvoData.imageIndex == imageIndex)
|
||||
{
|
||||
imageEvoData.position = transform.position;
|
||||
imageEvoData.rotation = transform.eulerAngles;
|
||||
imageEvoData.scale = transform.localScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TarkedImageEvoData GetTrackedImageEvoData(string domain)
|
||||
{
|
||||
foreach (var imageEvoData in TrackedImages)
|
||||
{
|
||||
if (imageEvoData.domain == domain)
|
||||
{
|
||||
return imageEvoData;
|
||||
}
|
||||
}
|
||||
Debug.LogError($"StaryEvo:未找到对应的domain的id数据,请检查是否进行前置识别 domain:{domain}");
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetTrackedImageEvoData(string domain, Transform transform)
|
||||
{
|
||||
foreach (var imageEvoData in TrackedImages)
|
||||
{
|
||||
if (imageEvoData.domain == domain)
|
||||
{
|
||||
imageEvoData.position = transform.position;
|
||||
imageEvoData.rotation = transform.eulerAngles;
|
||||
imageEvoData.scale = transform.localScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class TarkedImageEvoData
|
||||
{
|
||||
[VerticalGroup("key")] public string domain;
|
||||
[VerticalGroup("key")] public int imageIndex;
|
||||
|
||||
[VerticalGroup("transform")] public Vector3 position;
|
||||
[VerticalGroup("transform")] public Vector3 rotation;
|
||||
[VerticalGroup("transform")] public Vector3 scale;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be33290f8aa3440cac3e24a68606958b
|
||||
timeCreated: 1747635178
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.staryevo.rktools",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.5",
|
||||
"displayName": "07.RKTools",
|
||||
"description": "Rokid工具",
|
||||
"unity": "2021.3",
|
||||
@@ -15,6 +15,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"com.rokid.xr.unity":"3.0.3",
|
||||
"com.staryevo.main":"1.x.x"
|
||||
"com.staryevo.main":"1.x.x",
|
||||
"com.rokid.xr.extension":"3.x.x"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user