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>
|
private static readonly Dictionary<Type, object> formatters = new Dictionary<Type, object>
|
||||||
{
|
{
|
||||||
{ typeof(XED.Manage.MaterialPropertyData), new MessagePack.Formatters.XED.Asset.MaterialPropertyDataFormatter() },
|
{ typeof(XED.Manage.MaterialPropertyData), new MessagePack.Formatters.XED.Manage.MaterialPropertyDataFormatter() },
|
||||||
{ typeof(XED.Manage.ModelData), new MessagePack.Formatters.XED.Asset.ModelDataFormatter() },
|
{ typeof(XED.Manage.ModelData), new MessagePack.Formatters.XED.Manage.ModelDataFormatter() },
|
||||||
{ typeof(XED.Manage.SaveData), new MessagePack.Formatters.XED.Asset.SaveDataFormatter() },
|
{ typeof(XED.Manage.SaveData), new MessagePack.Formatters.XED.Manage.SaveDataFormatter() },
|
||||||
{ typeof(XED.Manage.SavedModelData), new MessagePack.Formatters.XED.Asset.SavedModelDataFormatter() },
|
{ typeof(XED.Manage.SavedModelData), new MessagePack.Formatters.XED.Manage.SavedModelDataFormatter() },
|
||||||
{ typeof(XED.Manage.SerializableMesh), new MessagePack.Formatters.XED.Asset.SerializableMeshFormatter() },
|
{ typeof(XED.Manage.SerializableMesh), new MessagePack.Formatters.XED.Manage.SerializableMeshFormatter() },
|
||||||
{ typeof(XED.Manage.SerializableQuaternion), new MessagePack.Formatters.XED.Asset.SerializableQuaternionFormatter() },
|
{ typeof(XED.Manage.SerializableQuaternion), new MessagePack.Formatters.XED.Manage.SerializableQuaternionFormatter() },
|
||||||
{ typeof(XED.Manage.SerializableVector2), new MessagePack.Formatters.XED.Asset.SerializableVector2Formatter() },
|
{ typeof(XED.Manage.SerializableVector2), new MessagePack.Formatters.XED.Manage.SerializableVector2Formatter() },
|
||||||
{ typeof(XED.Manage.SerializableVector3), new MessagePack.Formatters.XED.Asset.SerializableVector3Formatter() },
|
{ typeof(XED.Manage.SerializableVector3), new MessagePack.Formatters.XED.Manage.SerializableVector3Formatter() },
|
||||||
{ typeof(XED.Manage.SubmeshData), new MessagePack.Formatters.XED.Asset.SubmeshDataFormatter() },
|
{ typeof(XED.Manage.SubmeshData), new MessagePack.Formatters.XED.Manage.SubmeshDataFormatter() },
|
||||||
{ typeof(XED.Manage.TextureData), new MessagePack.Formatters.XED.Asset.TextureDataFormatter() },
|
{ typeof(XED.Manage.TextureData), new MessagePack.Formatters.XED.Manage.TextureDataFormatter() },
|
||||||
{ typeof(XED.Manage.TransformData), new MessagePack.Formatters.XED.Asset.TransformDataFormatter() },
|
{ typeof(XED.Manage.TransformData), new MessagePack.Formatters.XED.Manage.TransformDataFormatter() },
|
||||||
};
|
};
|
||||||
|
|
||||||
public IMessagePackFormatter<T> GetFormatter<T>()
|
public IMessagePackFormatter<T> GetFormatter<T>()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing.Printing;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using XED.Asset;
|
using XED.Asset;
|
||||||
using XED.HierarchyTree;
|
using XED.HierarchyTree;
|
||||||
@@ -120,7 +121,7 @@ namespace XED
|
|||||||
connectedAsset.assetData.RemoveTransform(connectedAsset.renderObject.transform);
|
connectedAsset.assetData.RemoveTransform(connectedAsset.renderObject.transform);
|
||||||
connectedAsset.renderObject.gameObject.SetActive(false);
|
connectedAsset.renderObject.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
connector.onCompletelyRemoveObjects?.Invoke();
|
connector.onCompletelyRemoveObjects?.Invoke(removeList);
|
||||||
connector.componentScrollView.DeselectAll();
|
connector.componentScrollView.DeselectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace XED.Asset
|
|||||||
public System.Action<string, List<GameObject>> onSelectObjects;
|
public System.Action<string, List<GameObject>> onSelectObjects;
|
||||||
public System.Action onDeselectObjects;
|
public System.Action onDeselectObjects;
|
||||||
public System.Action onRemoveObjects;
|
public System.Action onRemoveObjects;
|
||||||
public System.Action onCompletelyRemoveObjects;
|
public System.Action<List<ConnectedAsset>> onCompletelyRemoveObjects;
|
||||||
public System.Action onAssetDropped;
|
public System.Action onAssetDropped;
|
||||||
|
|
||||||
public CustomAssetDataHandler assetDataHandler;
|
public CustomAssetDataHandler assetDataHandler;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using UnityEditor;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
using XED.Asset;
|
||||||
using XED.DataStructures;
|
using XED.DataStructures;
|
||||||
using XED.Interfaces;
|
using XED.Interfaces;
|
||||||
using XED.Manage;
|
using XED.Manage;
|
||||||
@@ -160,13 +161,9 @@ namespace XED.Util
|
|||||||
onDeselectAll?.Invoke();
|
onDeselectAll?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveAll()
|
public void RemoveAll(List<ConnectedAsset> removeList)
|
||||||
{
|
{
|
||||||
if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftShift))
|
CompletelyRemoveAllSelections(removeList);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CompletelyRemoveAllSelections();
|
|
||||||
onDeselectAll?.Invoke();
|
onDeselectAll?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,13 +203,11 @@ namespace XED.Util
|
|||||||
selectedGameObjects.Clear();
|
selectedGameObjects.Clear();
|
||||||
rtgController.SetGizmoTargetObjects(selectedGameObjects);
|
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");
|
Destroy(removeList[i].renderObject.gameObject);
|
||||||
selectedRenderObjects[i].Deselect();
|
|
||||||
Destroy(selectedRenderObjects[i].gameObject);
|
|
||||||
}
|
}
|
||||||
selectedRenderObjects.Clear();
|
selectedRenderObjects.Clear();
|
||||||
selectedGameObjects.Clear();
|
selectedGameObjects.Clear();
|
||||||
|
|||||||
@@ -5,12 +5,9 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using TriLibCore.SFB;
|
using TriLibCore.SFB;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.Build.Pipeline.WriteTypes;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Rendering;
|
|
||||||
using XED.Asset;
|
using XED.Asset;
|
||||||
using XED.Hierarchy;
|
using XED.HierarchyTree;
|
||||||
using XED.Repositories;
|
using XED.Service;
|
||||||
using XED.Util;
|
using XED.Util;
|
||||||
using XRLib;
|
using XRLib;
|
||||||
|
|
||||||
@@ -45,15 +42,12 @@ namespace XED.Manage
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
List<AssetData> assetDatas = assetDataService.SortAssetDatas(connector.connectedAssets);
|
List<AssetData> assetDatas = assetDataService.SortAssetDatas(connector.connectedAssets);
|
||||||
|
ProjectData projectData = CreateProjectData(path, assetDatas);
|
||||||
|
|
||||||
ProjectData projectData = new ProjectData
|
curProjectPath = path;
|
||||||
{
|
curProjectData = projectData;
|
||||||
filePath = path,
|
|
||||||
updateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
||||||
assetDatas = assetDatas
|
|
||||||
};
|
|
||||||
|
|
||||||
SaveFile(path, projectData);
|
SaveFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadProject()
|
public void LoadProject()
|
||||||
@@ -88,6 +82,16 @@ namespace XED.Manage
|
|||||||
Init();
|
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)
|
private void LoadAssets(List<AssetData> assets)
|
||||||
{
|
{
|
||||||
foreach (AssetData asset in 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)
|
private void RestoreHierarchys(List<AssetData> assets)
|
||||||
{
|
{
|
||||||
foreach (AssetData asset in 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)
|
private void RestoreHierarchy(AssetData asset)
|
||||||
{
|
{
|
||||||
foreach (int id in asset.children)
|
foreach (int id in asset.children)
|
||||||
@@ -168,5 +127,47 @@ namespace XED.Manage
|
|||||||
onRestoreHierarchy?.Invoke(parent, child);
|
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.Collections.Generic;
|
||||||
using System;
|
|
||||||
using UnityEngine;
|
|
||||||
using XED.Manage;
|
|
||||||
using XED.Util;
|
using XED.Util;
|
||||||
using XED.Asset;
|
using XED.Asset;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using XED.Hierarchy;
|
using XED.HierarchyTree;
|
||||||
|
|
||||||
namespace XED
|
namespace XED.Service
|
||||||
{
|
{
|
||||||
public class AssetDataService
|
public class AssetDataService
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user