报错修改
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public static class BezierCurve
|
||||
{
|
||||
// 新增路径生成方法
|
||||
public static Vector3[] GenerateBezierPath(Vector3[] controlPoints, int segments = 20)
|
||||
{
|
||||
Vector3[] path = new Vector3[segments + 1];
|
||||
|
||||
for (int i = 0; i <= segments; i++)
|
||||
{
|
||||
float t = i / (float)segments;
|
||||
switch (controlPoints.Length)
|
||||
{
|
||||
case 2:
|
||||
path[i] = LineBezier(controlPoints[0], controlPoints[1], t);
|
||||
break;
|
||||
case 3:
|
||||
path[i] = QuadraticBezier(controlPoints, t);
|
||||
break;
|
||||
case 4:
|
||||
path[i] = CubicBezier(controlPoints, t);
|
||||
break;
|
||||
default: // 处理n阶情况
|
||||
path[i] = BezierInterpolation(controlPoints, t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
// 一阶贝塞尔(线性插值)
|
||||
public static Vector3 LineBezier(Vector3 p0, Vector3 p1, float t)
|
||||
{
|
||||
return Vector3.Lerp(p0, p1, t);
|
||||
}
|
||||
|
||||
// 二阶贝塞尔曲线
|
||||
public static Vector3 QuadraticBezier(Vector3[] points, float t)
|
||||
{
|
||||
if (points.Length != 3) Debug.LogError("需要3个控制点");
|
||||
|
||||
float u = 1 - t;
|
||||
return
|
||||
u * u * points[0] +
|
||||
2 * u * t * points[1] +
|
||||
t * t * points[2];
|
||||
}
|
||||
|
||||
// 三阶贝塞尔曲线
|
||||
public static Vector3 CubicBezier(Vector3[] points, float t)
|
||||
{
|
||||
if (points.Length != 4) Debug.LogError("需要4个控制点");
|
||||
|
||||
float u = 1 - t;
|
||||
return
|
||||
u * u * u * points[0] +
|
||||
3 * u * u * t * points[1] +
|
||||
3 * u * t * t * points[2] +
|
||||
t * t * t * points[3];
|
||||
}
|
||||
|
||||
// n阶贝塞尔曲线(通用实现)
|
||||
public static Vector3 BezierInterpolation(Vector3[] points, float t)
|
||||
{
|
||||
if (points.Length < 2)
|
||||
{
|
||||
Debug.LogError("至少需要2个控制点");
|
||||
return Vector3.zero;
|
||||
}
|
||||
|
||||
Vector3[] temp = new Vector3[points.Length];
|
||||
points.CopyTo(temp, 0);
|
||||
|
||||
// 德卡斯特里奥算法递推
|
||||
for (int k = 1; k < points.Length; k++)
|
||||
{
|
||||
for (int i = 0; i < points.Length - k; i++)
|
||||
{
|
||||
temp[i] = Vector3.Lerp(temp[i], temp[i + 1], t);
|
||||
}
|
||||
}
|
||||
return temp[0];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0f6bf90b6c476e4eb75f7a6dae5c45d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo
|
||||
{
|
||||
public static class VectorExtension {
|
||||
|
||||
|
||||
public static Vector3Ctor GetVector3Ctor(this Vector3 vector)
|
||||
{
|
||||
return new Vector3Ctor(vector);
|
||||
}
|
||||
|
||||
public static Vector3 SetVector3Ctor(this Vector3Ctor vector3Ctor)
|
||||
{
|
||||
return new Vector3(vector3Ctor.x, vector3Ctor.y, vector3Ctor.z);
|
||||
}
|
||||
|
||||
public static Vector2Ctor GetVector2Ctor( this Vector2 vector)
|
||||
{
|
||||
return new Vector2Ctor(vector);
|
||||
}
|
||||
|
||||
public static Vector2 SetVector2Data(this Vector2Ctor vector3Ctor)
|
||||
{
|
||||
return new Vector2(vector3Ctor.x, vector3Ctor.y);
|
||||
}
|
||||
|
||||
}
|
||||
[Serializable]
|
||||
public class Vector3Ctor
|
||||
{
|
||||
public float x;
|
||||
public float y;
|
||||
public float z;
|
||||
|
||||
public Vector3Ctor()
|
||||
{
|
||||
|
||||
}
|
||||
public Vector3Ctor(Vector3 vector)
|
||||
{
|
||||
x = vector.x;
|
||||
y = vector.y;
|
||||
z = vector.z;
|
||||
}
|
||||
public Vector3Ctor(float x, float y, float z)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
[Serializable]
|
||||
public class Vector2Ctor
|
||||
{
|
||||
public float x;
|
||||
public float y;
|
||||
|
||||
public Vector2Ctor(Vector2 vector)
|
||||
{
|
||||
x = vector.x;
|
||||
y = vector.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1077acf7c628ea24586d2c243ab718b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using Rokid.UXR.Module;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Android;
|
||||
using ModuleManager = Rokid.UXR.Module.ModuleManager;
|
||||
|
||||
public class VoiceSwitchingScene : MonoBehaviour
|
||||
{
|
||||
private String[] _sceneNames = new string[]
|
||||
{
|
||||
"打开第一个场景",
|
||||
"打开第二个场景",
|
||||
"打开第三个场景",
|
||||
"打开第四个场景",
|
||||
"打开第五个场景",
|
||||
"打开第六个场景",
|
||||
"打开第七个场景",
|
||||
"打开第八个场景",
|
||||
"打开第九个场景",
|
||||
"打开第十个场景",
|
||||
"打开第十一个场景",
|
||||
"打开第十二个场景",
|
||||
"打开第十三个场景",
|
||||
"打开第十四个场景",
|
||||
"打开第十五个场景",
|
||||
"打开第十六个场景",
|
||||
"打开第十七个场景",
|
||||
"打开第十八个场景",
|
||||
"打开第十九个场景",
|
||||
"打开第二十个场景",
|
||||
|
||||
};
|
||||
|
||||
private String[] _sceneNamesSpell = new string[]
|
||||
{
|
||||
"da kai di yi ge chang jing",
|
||||
"da kai di er ge chang jing",
|
||||
"da kai di san ge chang jing",
|
||||
"da kai di si ge chang jing",
|
||||
"da kai di wu ge chang jing",
|
||||
"da kai di liu ge chang jing",
|
||||
"da kai di qi ge chang jing",
|
||||
"da kai di ba ge chang jing",
|
||||
"da kai di jiu ge chang jing",
|
||||
"da kai di shi ge chang jing",
|
||||
"da kai di shi yi ge chang jing",
|
||||
"da kai di shi er ge chang jing",
|
||||
"da kai di shi san ge chang jing",
|
||||
"da kai di shi si ge chang jing",
|
||||
"da kai di shi wu ge chang jing",
|
||||
"da kai di shi liu ge chang jing",
|
||||
"da kai di shi qi ge chang jing",
|
||||
"da kai di shi ba ge chang jing",
|
||||
"da kai di shi jiu ge chang jing",
|
||||
"da kai di shi er shi ge chang jing",
|
||||
};
|
||||
private HybridClREntrance hybridClREntrance;
|
||||
|
||||
private MainDomainAll mainDomainAll;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
hybridClREntrance = GetComponent<HybridClREntrance>();
|
||||
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);
|
||||
|
||||
mainDomainAll = Resources.Load<MainDomainAll>("MainDomainAll");
|
||||
for (int i = 0; i < mainDomainAll.domainAll.Length; i++)
|
||||
{
|
||||
if(mainDomainAll.domainAll[i].isVideo)
|
||||
OfflineVoiceModule.Instance.AddInstruct(LANGUAGE.CHINESE, _sceneNames[i], _sceneNamesSpell[i], this.gameObject.name, "OnReceive");
|
||||
}
|
||||
OfflineVoiceModule.Instance.Commit();
|
||||
}
|
||||
|
||||
|
||||
void OnReceive(string msg)
|
||||
{
|
||||
int index = Array.IndexOf(_sceneNames, msg);
|
||||
if (index != -1)
|
||||
{
|
||||
hybridClREntrance.OpenDomain(mainDomainAll.domainAll[index].domainName , OpenDomainType.VIOICE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97f6e15196934254c94bd3de1f798b77
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Stary.Evo
|
||||
{
|
||||
public class WebRequestTools
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48091c7012fc4cd88a54c096febdcdd0
|
||||
timeCreated: 1748318581
|
||||
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
namespace Stary.Evo
|
||||
{
|
||||
public class YooAssetFileSystem
|
||||
{
|
||||
public static InitializeParameters OfflineInitializeParameter()
|
||||
{
|
||||
var buildinFileSystemParams = FileSystemParameters.CreateDefaultBuildinFileSystemParameters();
|
||||
var initParameters = new OfflinePlayModeParameters();
|
||||
initParameters.BuildinFileSystemParameters = buildinFileSystemParams;
|
||||
return initParameters;
|
||||
}
|
||||
public static InitializeParameters hostInitializeParameter()
|
||||
{
|
||||
var initParameters = new OfflinePlayModeParameters();
|
||||
var buildinFileSystemParams = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(null,
|
||||
$"{Application.persistentDataPath}/DownloadedContent/{AppConfig.PackageDomainName}");
|
||||
buildinFileSystemParams.AddParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, true);
|
||||
buildinFileSystemParams.AddParameter(FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST, true);
|
||||
initParameters.BuildinFileSystemParameters = buildinFileSystemParams;
|
||||
return initParameters;
|
||||
}
|
||||
public static InitializeParameters EditorSimulateInitializeParameter()
|
||||
{
|
||||
var buildResult = EditorSimulateModeHelper.SimulateBuild(AppConfig.PackageDomainName);
|
||||
var packageRoot = buildResult.PackageRootDirectory;
|
||||
var editorFileSystemParameters = FileSystemParameters.CreateDefaultEditorFileSystemParameters(packageRoot);
|
||||
var initParams = new EditorSimulateModeParameters();
|
||||
initParams.EditorFileSystemParameters = editorFileSystemParameters;
|
||||
return initParams;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6f288f9aa65416baf25a50a4056fcae
|
||||
timeCreated: 1749695458
|
||||
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace Stary.Evo
|
||||
{
|
||||
public class ZipTool
|
||||
{
|
||||
// 新增:带进度回调的下载解压方法
|
||||
public static async UniTask DownloadAndUnzipAsync(string fildId, string extractPath,
|
||||
Action<float> downloadProgress = null, Action<float> unzipProgress = null)
|
||||
{
|
||||
string tempPath = Path.Combine(Application.persistentDataPath, "temp.zip");
|
||||
|
||||
try
|
||||
{
|
||||
string url = $"{AppConfig.IpConfig}/FileLoad/Download/{fildId}";
|
||||
await WebRequestSystem.GetFile(url, tempPath,downloadProgress);
|
||||
|
||||
// 解压下载的文件
|
||||
await UnzipAsync(tempPath, extractPath, unzipProgress);
|
||||
File.Delete(tempPath);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// 清理临时文件
|
||||
if (File.Exists(tempPath))
|
||||
{
|
||||
File.Delete(tempPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 修改:添加进度回调参数
|
||||
public static async UniTask UnzipAsync(string zipPath, string extractPath,
|
||||
Action<float> progressCallback = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
|
||||
{
|
||||
float totalEntries = archive.Entries.Count;
|
||||
float processed = 0;
|
||||
|
||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||
{
|
||||
string filePath = Path.Combine(extractPath, entry.FullName);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
|
||||
|
||||
if (!string.IsNullOrEmpty(entry.Name))
|
||||
{
|
||||
using (Stream inputStream = entry.Open())
|
||||
using (FileStream outputStream = File.Create(filePath))
|
||||
{
|
||||
await inputStream.CopyToAsync(outputStream);
|
||||
}
|
||||
}
|
||||
|
||||
processed++;
|
||||
float progress = processed / totalEntries;
|
||||
progressCallback?.Invoke(progress);
|
||||
}
|
||||
}
|
||||
Debug.Log($"解压完成: {extractPath}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"解压失败: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自定义网络请求器需要登录
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
private static UnityWebRequest WebRequester(string url)
|
||||
{
|
||||
var request = new UnityWebRequest(url, UnityWebRequest.kHttpVerbGET);
|
||||
var authorization = GetAuthorization(AppConfig.UserName, AppConfig.PassWord);
|
||||
request.SetRequestHeader("AUTHORIZATION", authorization);
|
||||
return request;
|
||||
}
|
||||
|
||||
private static string GetAuthorization(string userName, string password)
|
||||
{
|
||||
string auth = userName + ":" + password;
|
||||
var bytes = System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(auth);
|
||||
return "Basic " + System.Convert.ToBase64String(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f5ebd73225744188b38cf307e565ff2
|
||||
timeCreated: 1747988495
|
||||
Reference in New Issue
Block a user