2차 수정 및 asset완전삭제 기능 추가
This commit is contained in:
@@ -10,17 +10,17 @@ public class CustomMessagePackResolver : IFormatterResolver
|
||||
|
||||
private static readonly Dictionary<Type, object> formatters = new Dictionary<Type, object>
|
||||
{
|
||||
{ typeof(XED.Manage.MaterialPropertyData), new MessagePack.Formatters.XED.Asset.MaterialPropertyDataFormatter() },
|
||||
{ typeof(XED.Manage.ModelData), new MessagePack.Formatters.XED.Asset.ModelDataFormatter() },
|
||||
{ typeof(XED.Manage.SaveData), new MessagePack.Formatters.XED.Asset.SaveDataFormatter() },
|
||||
{ typeof(XED.Manage.SavedModelData), new MessagePack.Formatters.XED.Asset.SavedModelDataFormatter() },
|
||||
{ typeof(XED.Manage.SerializableMesh), new MessagePack.Formatters.XED.Asset.SerializableMeshFormatter() },
|
||||
{ typeof(XED.Manage.SerializableQuaternion), new MessagePack.Formatters.XED.Asset.SerializableQuaternionFormatter() },
|
||||
{ typeof(XED.Manage.SerializableVector2), new MessagePack.Formatters.XED.Asset.SerializableVector2Formatter() },
|
||||
{ typeof(XED.Manage.SerializableVector3), new MessagePack.Formatters.XED.Asset.SerializableVector3Formatter() },
|
||||
{ typeof(XED.Manage.SubmeshData), new MessagePack.Formatters.XED.Asset.SubmeshDataFormatter() },
|
||||
{ typeof(XED.Manage.TextureData), new MessagePack.Formatters.XED.Asset.TextureDataFormatter() },
|
||||
{ typeof(XED.Manage.TransformData), new MessagePack.Formatters.XED.Asset.TransformDataFormatter() },
|
||||
{ typeof(XED.Manage.MaterialPropertyData), new MessagePack.Formatters.XED.Manage.MaterialPropertyDataFormatter() },
|
||||
{ typeof(XED.Manage.ModelData), new MessagePack.Formatters.XED.Manage.ModelDataFormatter() },
|
||||
{ typeof(XED.Manage.SaveData), new MessagePack.Formatters.XED.Manage.SaveDataFormatter() },
|
||||
{ typeof(XED.Manage.SavedModelData), new MessagePack.Formatters.XED.Manage.SavedModelDataFormatter() },
|
||||
{ typeof(XED.Manage.SerializableMesh), new MessagePack.Formatters.XED.Manage.SerializableMeshFormatter() },
|
||||
{ typeof(XED.Manage.SerializableQuaternion), new MessagePack.Formatters.XED.Manage.SerializableQuaternionFormatter() },
|
||||
{ typeof(XED.Manage.SerializableVector2), new MessagePack.Formatters.XED.Manage.SerializableVector2Formatter() },
|
||||
{ typeof(XED.Manage.SerializableVector3), new MessagePack.Formatters.XED.Manage.SerializableVector3Formatter() },
|
||||
{ typeof(XED.Manage.SubmeshData), new MessagePack.Formatters.XED.Manage.SubmeshDataFormatter() },
|
||||
{ typeof(XED.Manage.TextureData), new MessagePack.Formatters.XED.Manage.TextureDataFormatter() },
|
||||
{ typeof(XED.Manage.TransformData), new MessagePack.Formatters.XED.Manage.TransformDataFormatter() },
|
||||
};
|
||||
|
||||
public IMessagePackFormatter<T> GetFormatter<T>()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Printing;
|
||||
using UnityEngine;
|
||||
using XED.Asset;
|
||||
using XED.HierarchyTree;
|
||||
@@ -120,7 +121,7 @@ namespace XED
|
||||
connectedAsset.assetData.RemoveTransform(connectedAsset.renderObject.transform);
|
||||
connectedAsset.renderObject.gameObject.SetActive(false);
|
||||
}
|
||||
connector.onCompletelyRemoveObjects?.Invoke();
|
||||
connector.onCompletelyRemoveObjects?.Invoke(removeList);
|
||||
connector.componentScrollView.DeselectAll();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace XED.Asset
|
||||
public System.Action<string, List<GameObject>> onSelectObjects;
|
||||
public System.Action onDeselectObjects;
|
||||
public System.Action onRemoveObjects;
|
||||
public System.Action onCompletelyRemoveObjects;
|
||||
public System.Action<List<ConnectedAsset>> onCompletelyRemoveObjects;
|
||||
public System.Action onAssetDropped;
|
||||
|
||||
public CustomAssetDataHandler assetDataHandler;
|
||||
|
||||
@@ -5,6 +5,7 @@ using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using XED.Asset;
|
||||
using XED.DataStructures;
|
||||
using XED.Interfaces;
|
||||
using XED.Manage;
|
||||
@@ -160,13 +161,9 @@ namespace XED.Util
|
||||
onDeselectAll?.Invoke();
|
||||
}
|
||||
|
||||
public void RemoveAll()
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
return;
|
||||
}
|
||||
CompletelyRemoveAllSelections();
|
||||
public void RemoveAll(List<ConnectedAsset> removeList)
|
||||
{
|
||||
CompletelyRemoveAllSelections(removeList);
|
||||
onDeselectAll?.Invoke();
|
||||
}
|
||||
|
||||
@@ -206,13 +203,11 @@ namespace XED.Util
|
||||
selectedGameObjects.Clear();
|
||||
rtgController.SetGizmoTargetObjects(selectedGameObjects);
|
||||
}
|
||||
public void CompletelyRemoveAllSelections()
|
||||
public void CompletelyRemoveAllSelections(List<ConnectedAsset> removeList)
|
||||
{
|
||||
for (int i = 0; i < selectedRenderObjects.Count; i++)
|
||||
for (int i = 0; i < removeList.Count; i++)
|
||||
{
|
||||
Debug.Log("enter");
|
||||
selectedRenderObjects[i].Deselect();
|
||||
Destroy(selectedRenderObjects[i].gameObject);
|
||||
Destroy(removeList[i].renderObject.gameObject);
|
||||
}
|
||||
selectedRenderObjects.Clear();
|
||||
selectedGameObjects.Clear();
|
||||
|
||||
@@ -5,12 +5,9 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using TriLibCore.SFB;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build.Pipeline.WriteTypes;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using XED.Asset;
|
||||
using XED.Hierarchy;
|
||||
using XED.Repositories;
|
||||
using XED.HierarchyTree;
|
||||
using XED.Service;
|
||||
using XED.Util;
|
||||
using XRLib;
|
||||
|
||||
@@ -45,15 +42,12 @@ namespace XED.Manage
|
||||
return;
|
||||
|
||||
List<AssetData> assetDatas = assetDataService.SortAssetDatas(connector.connectedAssets);
|
||||
ProjectData projectData = CreateProjectData(path, assetDatas);
|
||||
|
||||
ProjectData projectData = new ProjectData
|
||||
{
|
||||
filePath = path,
|
||||
updateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
assetDatas = assetDatas
|
||||
};
|
||||
curProjectPath = path;
|
||||
curProjectData = projectData;
|
||||
|
||||
SaveFile(path, projectData);
|
||||
SaveFile();
|
||||
}
|
||||
|
||||
public void LoadProject()
|
||||
@@ -88,6 +82,16 @@ namespace XED.Manage
|
||||
Init();
|
||||
}
|
||||
|
||||
private ProjectData CreateProjectData(string path, List<AssetData> assetDatas)
|
||||
{
|
||||
return new ProjectData
|
||||
{
|
||||
filePath = path,
|
||||
updateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
assetDatas = assetDatas
|
||||
};
|
||||
}
|
||||
|
||||
private void LoadAssets(List<AssetData> assets)
|
||||
{
|
||||
foreach (AssetData asset in assets)
|
||||
@@ -96,6 +100,12 @@ namespace XED.Manage
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadAsset(AssetData asset)
|
||||
{
|
||||
onLoadAsset?.Invoke(asset);
|
||||
itemDict.Add(asset.id, connector.connectedAssets.Last().hierarchyItem);
|
||||
}
|
||||
|
||||
private void RestoreHierarchys(List<AssetData> assets)
|
||||
{
|
||||
foreach (AssetData asset in assets)
|
||||
@@ -104,57 +114,6 @@ namespace XED.Manage
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveObject()
|
||||
{
|
||||
List<CustomAssetRenderObject> objects = connector.connectedAssets.Select(x => x.renderObject).ToList();
|
||||
onRemoveAsset?.Invoke(objects);
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
curProjectPath = string.Empty;
|
||||
curProjectData = null;
|
||||
connector.connectedAssets.Clear();
|
||||
CommandManager.I.Clear();
|
||||
itemDict.Clear();
|
||||
}
|
||||
|
||||
public string GetSaveFilePath()
|
||||
{
|
||||
var data = StandaloneFileBrowser.SaveFilePanel("SaveProject", "", "", "json");
|
||||
return data.Name;
|
||||
}
|
||||
|
||||
public string GetOpenFilePath()
|
||||
{
|
||||
var data = StandaloneFileBrowser.OpenFilePanel("OpenProject", "", "json", false);
|
||||
return data.Count >= 1 ? data[0].Name : "";
|
||||
}
|
||||
|
||||
public void SaveFile(string path, ProjectData data)
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(data);
|
||||
FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write);
|
||||
StreamWriter writer = new StreamWriter(fs, System.Text.Encoding.Unicode);
|
||||
writer.Write(json);
|
||||
writer.Close();
|
||||
|
||||
curProjectPath = path;
|
||||
curProjectData = data;
|
||||
}
|
||||
|
||||
public ProjectData GetFileData(string path)
|
||||
{
|
||||
string json = File.ReadAllText(path);
|
||||
return JsonConvert.DeserializeObject<ProjectData>(json);
|
||||
}
|
||||
|
||||
private void LoadAsset(AssetData asset)
|
||||
{
|
||||
onLoadAsset?.Invoke(asset);
|
||||
itemDict.Add(asset.id, connector.connectedAssets.Last().hierarchyItem);
|
||||
}
|
||||
|
||||
private void RestoreHierarchy(AssetData asset)
|
||||
{
|
||||
foreach (int id in asset.children)
|
||||
@@ -167,6 +126,48 @@ namespace XED.Manage
|
||||
|
||||
onRestoreHierarchy?.Invoke(parent, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveObject()
|
||||
{
|
||||
List<CustomAssetRenderObject> objects = connector.connectedAssets.Select(x => x.renderObject).ToList();
|
||||
onRemoveAsset?.Invoke(objects);
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
curProjectPath = string.Empty;
|
||||
curProjectData = null;
|
||||
connector.connectedAssets.Clear();
|
||||
CommandManager.I.Clear();
|
||||
itemDict.Clear();
|
||||
}
|
||||
|
||||
private string GetSaveFilePath()
|
||||
{
|
||||
var data = StandaloneFileBrowser.SaveFilePanel("SaveProject", "", "", "json");
|
||||
return data.Name;
|
||||
}
|
||||
|
||||
private string GetOpenFilePath()
|
||||
{
|
||||
var data = StandaloneFileBrowser.OpenFilePanel("OpenProject", "", "json", false);
|
||||
return data.Count >= 1 ? data[0].Name : "";
|
||||
}
|
||||
|
||||
private void SaveFile()
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(curProjectData);
|
||||
FileStream fs = new FileStream(curProjectPath, FileMode.Create, FileAccess.Write);
|
||||
StreamWriter writer = new StreamWriter(fs, System.Text.Encoding.Unicode);
|
||||
writer.Write(json);
|
||||
writer.Close();
|
||||
}
|
||||
|
||||
private ProjectData GetFileData(string path)
|
||||
{
|
||||
string json = File.ReadAllText(path);
|
||||
return JsonConvert.DeserializeObject<ProjectData>(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using XED.Manage;
|
||||
using XED.Util;
|
||||
using XED.Asset;
|
||||
using System.Linq;
|
||||
using XED.Hierarchy;
|
||||
using XED.HierarchyTree;
|
||||
|
||||
namespace XED
|
||||
namespace XED.Service
|
||||
{
|
||||
public class AssetDataService
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user