From 7f42b8b4517be47b195d9bdff20638ce28c95508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=93=AE?= <834207172@qq.com> Date: Mon, 29 Sep 2025 18:24:13 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90m=E3=80=91111?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BuildAsset/BuildAssetDataSetting.cs | 25 -- .../Tool/WebRequest/WebRequestSystem.cs | 15 +- .../RunTime/UIFramework/Runtime.meta | 3 - .../Editor/Script/CreatPointModelWindow.cs | 214 ++++++++++++++++++ .../Script/CreatPointModelWindow.cs.meta | 11 + .../Script/com.pointcloud.editor.asmdef | 3 +- 6 files changed, 240 insertions(+), 31 deletions(-) delete mode 100644 Assets/06.UIFarme/RunTime/UIFramework/Runtime.meta create mode 100644 Assets/11.PointCloudTools/Editor/Script/CreatPointModelWindow.cs create mode 100644 Assets/11.PointCloudTools/Editor/Script/CreatPointModelWindow.cs.meta diff --git a/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetDataSetting.cs b/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetDataSetting.cs index 5980a83..c4b1ac6 100644 --- a/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetDataSetting.cs +++ b/Assets/00.StaryEvo/Editor/BuildAsset/BuildAssetDataSetting.cs @@ -112,14 +112,6 @@ namespace Stary.Evo.Editor } - // - // [Title("加密列表", titleAlignment: TitleAlignments.Centered)] - // [HorizontalGroup("BuildPipeline"), HideLabel] - // [ValueDropdown("GetEncryptionServices")] - // [OnValueChanged("SetEncryptionServices")] - // public Type encryption; - - [HideLabel] public AbstractBuildPipelineViewer viewer; @@ -227,23 +219,6 @@ namespace Stary.Evo.Editor _viewers.Add(selectedBuildPipelines, viewer); } } - - // private List GetEncryptionServices() - // { - // var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices)); - // if (encryption.IsNull()) - // { - // encryption = encryptionClassTypes[0]; - // } - // - // return encryptionClassTypes; - // } - // - // private void SetEncryptionServices() - // { - // AssetBundleBuilderSetting.SetPackageEncyptionClassName(packageName, selectedBuildPipelines, - // encryption.FullName); - // } } public enum VersionPosType diff --git a/Assets/00.StaryEvo/Runtime/Tool/WebRequest/WebRequestSystem.cs b/Assets/00.StaryEvo/Runtime/Tool/WebRequest/WebRequestSystem.cs index 753da37..f67cc8a 100644 --- a/Assets/00.StaryEvo/Runtime/Tool/WebRequest/WebRequestSystem.cs +++ b/Assets/00.StaryEvo/Runtime/Tool/WebRequest/WebRequestSystem.cs @@ -144,7 +144,7 @@ namespace Stary.Evo /// 获取Token值的服务URL地址(很重要) /// 传入请求的参数,此处参数为JOSN格式 /// - public static async Task PostFile(string url, string[] path) + public static async Task PostFile(string url, string[] path,Action uploadProgress = null) { if (!GetTokenState()) { @@ -174,7 +174,18 @@ namespace Stary.Evo webRequest.disposeDownloadHandlerOnDispose = true; webRequest.disposeCertificateHandlerOnDispose = true; webRequest.timeout = 60; - await webRequest.SendWebRequest(); + + // 发送请求但不等待完成 + var operation = webRequest.SendWebRequest(); + // 轮询获取上传进度 + while (!operation.isDone) + { + // 调用进度回调函数 + uploadProgress?.Invoke(webRequest.uploadProgress); + // 等待一帧,避免阻塞 + await UniTask.Yield(); + } + webRequest.uploadHandler?.Dispose(); // 更新错误检查方式 if (webRequest.result == UnityWebRequest.Result.ConnectionError || diff --git a/Assets/06.UIFarme/RunTime/UIFramework/Runtime.meta b/Assets/06.UIFarme/RunTime/UIFramework/Runtime.meta deleted file mode 100644 index 5f5a5d1..0000000 --- a/Assets/06.UIFarme/RunTime/UIFramework/Runtime.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 125226ccd07f47c5bf3b94157bf12fc3 -timeCreated: 1758179120 \ No newline at end of file diff --git a/Assets/11.PointCloudTools/Editor/Script/CreatPointModelWindow.cs b/Assets/11.PointCloudTools/Editor/Script/CreatPointModelWindow.cs new file mode 100644 index 0000000..96a880f --- /dev/null +++ b/Assets/11.PointCloudTools/Editor/Script/CreatPointModelWindow.cs @@ -0,0 +1,214 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using Cysharp.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Sirenix.OdinInspector; +using Sirenix.OdinInspector.Editor; +using Stary.Evo; +using Stary.Evo.Editor; +using Stary.Evo.Editor.Entity; +using UnityEditor; +using UnityEngine; + +public class CreatPointModelWindow : OdinEditorWindow +{ + private static List _modelTypes; + public static List ScenarioTypes; + + [MenuItem("Evo/创建ModelLibrary")] + private static async void Init() + { + _modelTypes = await GetModelTypes(); + ScenarioTypes = await GetScenarioTypes(); + // Get existing open window or if none, make a new one: + CreatPointModelWindow window = (CreatPointModelWindow)EditorWindow.GetWindow(typeof(CreatPointModelWindow)); + window.Show(); + } + + protected override void OnEnable() + { + base.OnEnable(); + documentFileid = EditorPrefs.GetString("documentFileid"); + modelType = EditorPrefs.GetString("modelType"); + scenarioType = EditorPrefs.GetString("scenarioType"); + } + + [TitleGroup("创建")] [InfoBox("Model名称")] + public string modelName; + + [TitleGroup("创建")] [InfoBox("Model描述")] [ValueDropdown("GetModelType")][OnValueChanged("SetModelType")] + public string modelType; + + [TitleGroup("创建")] [InfoBox("Scenario描述")] [ValueDropdown("GetScenarioType")][OnValueChanged("SetScenarioType")] + public string scenarioType; + + [TitleGroup("创建")] [ReadOnly] [InfoBox("文件所对应数据库id")] + public string documentFileid; + + private List GetModelType() => _modelTypes; + private List GetScenarioType() => ScenarioTypes; + + private void SetModelType() => EditorPrefs.SetString("modelType", modelType); + private void SetScenarioType() => EditorPrefs.SetString("scenarioType", scenarioType); + + private static async UniTask> GetModelTypes() + { + string ip = EditorPrefs.GetString("ip"); + if (string.IsNullOrEmpty(ip)) + { + EditorUtility.DisplayDialog("提示", "ip不能为空", "确定"); + return null; + } + + // var entity = new PointModelEntity + // { + // modelName = modelName, + // modelType = modelType, + // scenarioType = scenarioType, + // }; + //string postData = JsonConvert.SerializeObject(entity); + ResultMessageEntity entity = await WebRequestSystem.Get(ip, "/ModelLibrary/FindModelType"); + if (entity.code == 200) + { + var modelTypes = JsonConvert.DeserializeObject>(entity.data.ToString()); + return modelTypes; + } + else + { + return null; + } + } + + private static async UniTask> GetScenarioTypes() + { + string ip = EditorPrefs.GetString("ip"); + if (string.IsNullOrEmpty(ip)) + { + EditorUtility.DisplayDialog("提示", "ip不能为空", "确定"); + return null; + } + + ResultMessageEntity entity = await WebRequestSystem.Get(ip, "/SceneWork/FindScenarioType"); + if (entity.code == 200) + { + var scenarioTypes = JsonConvert.DeserializeObject>(entity.data.ToString()); + return scenarioTypes; + } + else + { + return null; + } + } + + [TitleGroup("创建")] + [Button("创建Model", ButtonSizes.Large)] + public async void CreatModel() + { + if (string.IsNullOrEmpty(modelName) || string.IsNullOrEmpty(modelType) || string.IsNullOrEmpty(scenarioType) || + string.IsNullOrEmpty(documentFileid)) + { + EditorUtility.DisplayDialog("提示", "modelName和modelType和scenarioType和documentFileid不能为空", "确定"); + return; + } + + string ip = EditorPrefs.GetString("ip"); + if (string.IsNullOrEmpty(ip)) + { + EditorUtility.DisplayDialog("提示", "ip不能为空", "确定"); + return; + } + + var pointModelEntity = new PointModelEntity + { + Name = modelName, + ModelType = modelType, + ScenarioType = scenarioType, + DocumentFileid = documentFileid, + }; + string postData = JsonConvert.SerializeObject(pointModelEntity); + ResultMessageEntity entity = await WebRequestSystem.Post($"{ip}/ModelLibrary/AddModel", postData); + if (entity.code == 200) + { + EditorUtility.DisplayDialog("提示", "创建成功", "确定"); + modelName = ""; + documentFileid = ""; + EditorPrefs.SetString("documentFileid",""); + EditorPrefs.SetString("modelType",""); + EditorPrefs.SetString("scenarioType",""); + } + else if (entity.code == 4009) + { + EditorUtility.DisplayDialog("提示", $"创建失败,存在相同名称元素", "确定"); + } + } + + [TitleGroup("上传")] [InfoBox("Model路径")] [Sirenix.OdinInspector.FilePath(Extensions = "$modelType")] + public string modelPath; + + [TitleGroup("上传")] [ReadOnly][HideLabel, ProgressBar(0, 100f)] + public float modelUpdateInterval = 0f; + + [TitleGroup("上传")] + [Button("上传Model", ButtonSizes.Large)] + public async void UpdateModel() + { + if (string.IsNullOrEmpty(modelPath)) + { + EditorUtility.DisplayDialog("提示", "modelPath不能为空", "确定"); + return; + } + + string ip = EditorPrefs.GetString("ip"); + if (string.IsNullOrEmpty(ip)) + { + EditorUtility.DisplayDialog("提示", "ip不能为空", "确定"); + return; + } + + var messageEntity = await WebRequestSystem.PostFile(ip + "/FileLoad/UpLoadFile", new[] { modelPath }, (progress) => + { + modelUpdateInterval = progress * 100f; + }); + + if (messageEntity.code == 200) + { + List resultMessageEntities = + JsonConvert.DeserializeObject>(messageEntity.data.ToString()); + if (resultMessageEntities.Count > 0) + { + foreach (var resultMessageEntity in resultMessageEntities) + { + var data = JsonConvert.DeserializeObject(resultMessageEntity.data.ToString()) as JObject; + documentFileid = data["id"].ToString(); + EditorPrefs.SetString("documentFileid", documentFileid); + } + } + } + } + + [Serializable] + public class PointModelEntity + { + /// + /// 模型名称 + /// + public string Name { get; set; } + + /// + /// 模型标签 + /// + public string ModelType { get; set; } + + /// + /// 场景标签 + /// + public string ScenarioType { get; set; } + + /// + /// 文件id + /// + public string DocumentFileid { get; set; } + } +} \ No newline at end of file diff --git a/Assets/11.PointCloudTools/Editor/Script/CreatPointModelWindow.cs.meta b/Assets/11.PointCloudTools/Editor/Script/CreatPointModelWindow.cs.meta new file mode 100644 index 0000000..06cfcff --- /dev/null +++ b/Assets/11.PointCloudTools/Editor/Script/CreatPointModelWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 63cfd397008223c4cae6325df57adc06 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/11.PointCloudTools/Editor/Script/com.pointcloud.editor.asmdef b/Assets/11.PointCloudTools/Editor/Script/com.pointcloud.editor.asmdef index b26eeba..dba3ae0 100644 --- a/Assets/11.PointCloudTools/Editor/Script/com.pointcloud.editor.asmdef +++ b/Assets/11.PointCloudTools/Editor/Script/com.pointcloud.editor.asmdef @@ -2,7 +2,8 @@ "name": "com.pointcloud.reditor", "rootNamespace": "", "references": [ - "GUID:d1a793c2b6959e04ea45b972eaa369c8" + "GUID:d1a793c2b6959e04ea45b972eaa369c8", + "GUID:f51ebe6a0ceec4240a699833d6309b23" ], "includePlatforms": [ "Editor"