78 lines
2.4 KiB
C#
78 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Newtonsoft.Json;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Stary.Evo.Editor
|
|
{
|
|
[Serializable]
|
|
public class CreatPointCloudEntity
|
|
{
|
|
private CreatPointCloudWindow window;
|
|
[HideInInspector] public string id;
|
|
|
|
[HorizontalGroup("identifier")] [ReadOnly]
|
|
public string sceneName;
|
|
|
|
[HorizontalGroup("identifier")] [ReadOnly]
|
|
public string identifier;
|
|
|
|
[ReadOnly] public string sceneDesc;
|
|
[HorizontalGroup("button")] public bool isActive;
|
|
|
|
public CreatPointCloudEntity(CreatPointCloudWindow window)
|
|
{
|
|
this.window = window;
|
|
}
|
|
|
|
[HorizontalGroup("button")]
|
|
[Button("", Icon = SdfIconType.ArrowUpCircleFill, IconAlignment = IconAlignment.RightEdge)]
|
|
public async void UpdatePointCloud()
|
|
{
|
|
string ip = EditorPrefs.GetString("ip");
|
|
if (string.IsNullOrEmpty(ip))
|
|
{
|
|
EditorUtility.DisplayDialog("提示", "ip不能为空", "确定");
|
|
return;
|
|
}
|
|
|
|
var scene = new
|
|
{
|
|
id = id,
|
|
sceneName = sceneName,
|
|
sceneDesc = sceneDesc,
|
|
isActive = isActive,
|
|
};
|
|
string body = JsonConvert.SerializeObject(scene);
|
|
ResultMessageEntity entity = await WebRequestSystem.Put($"{ip}/SceneWork/UpdateScene", body);
|
|
if (entity.code == 200)
|
|
{
|
|
|
|
EditorUtility.DisplayDialog("提示", $"更新成功{scene}", "确定");
|
|
}
|
|
}
|
|
|
|
|
|
[HorizontalGroup("button")]
|
|
[Button("", Icon = SdfIconType.XCircle, IconAlignment = IconAlignment.RightEdge)]
|
|
public async void DeletePointCloud()
|
|
{
|
|
string ip = EditorPrefs.GetString("ip");
|
|
if (string.IsNullOrEmpty(ip))
|
|
{
|
|
EditorUtility.DisplayDialog("提示", "ip不能为空", "确定");
|
|
return;
|
|
}
|
|
|
|
ResultMessageEntity entity = await WebRequestSystem.Delete(ip, $"/SceneWork/DeleteScenebyId/{id}");
|
|
if (entity.code == 200)
|
|
{
|
|
window.SceneWorkEntities.Remove(this);
|
|
EditorUtility.DisplayDialog("提示", "删除成功", "确定");
|
|
}
|
|
}
|
|
}
|
|
} |