Camera, Gizmo, Project Command 추가 #50

Merged
UVCXR merged 3 commits from pgd/20250417 into main 2025-04-21 16:35:45 +09:00
31 changed files with 590 additions and 297 deletions

View File

@@ -255,6 +255,52 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 88186217}
m_CullTransparentMesh: 0
--- !u!1 &121134311
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 121134312}
- component: {fileID: 121134313}
m_Layer: 0
m_Name: LinkDataUIManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &121134312
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 121134311}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1093055756}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &121134313
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 121134311}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: beaea798e37c61142a62ba5cecd426f2, type: 3}
m_Name:
m_EditorClassIdentifier:
prf_LinkDataUI: {fileID: 3588877776299194241, guid: 9f62a52c6a3d48947b57fdd4f941a260, type: 3}
body: {fileID: 1617081465}
--- !u!1 &157533902
GameObject:
m_ObjectHideFlags: 0
@@ -965,7 +1011,8 @@ PrefabInstance:
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedComponents:
- {fileID: 7997719753715833387, guid: 82511e73cbe6181438fd98254170e476, type: 3}
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
@@ -4272,6 +4319,7 @@ Transform:
- {fileID: 749092880}
- {fileID: 671739451}
- {fileID: 391151068}
- {fileID: 121134312}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1093055757
@@ -9591,6 +9639,11 @@ RectTransform:
m_CorrespondingSourceObject: {fileID: 2186512387788540450, guid: 985020025db5cc04da0f50eaa5351616, type: 3}
m_PrefabInstance: {fileID: 1615364366}
m_PrefabAsset: {fileID: 0}
--- !u!224 &1617081465 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 940260026812176822, guid: 82511e73cbe6181438fd98254170e476, type: 3}
m_PrefabInstance: {fileID: 297039007}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1647579088
GameObject:
m_ObjectHideFlags: 0

View File

@@ -10,6 +10,8 @@ using System;
using System.Linq;
using XED.Repositories;
using XED.Asset;
using Ookii.Dialogs;
using XED.Command;
namespace XED.Manage
{
@@ -52,23 +54,23 @@ namespace XED.Manage
private void OnLoadLocalFBXDirectory(IList<ItemWithStream> list)
{
for (int i = 0; i < list.Count; i++)
{
if (!list[i].HasData)
continue;
//for (int i = 0; i < list.Count; i++)
//{
// if (!list[i].HasData)
// continue;
var path = list[i].Name;
Debug.Log("path " + path);
var files = Directory.GetFiles(path, "*.fbx", SearchOption.AllDirectories);
// var path = list[i].Name;
// Debug.Log("path " + path);
// var files = Directory.GetFiles(path, "*.fbx", SearchOption.AllDirectories);
if (dataRepo.TryGetDataFromPath(path, out var p))
return;
// if (dataRepo.TryGetDataFromPath(path, out var p))
// return;
foreach (var file in files)
{
loadFilePath.Enqueue(file);
}
}
// foreach (var file in files)
// {
// loadFilePath.Enqueue(file);
// }
//}
}
public void SaveToLocalData(List<CustomAssetData> assetDatas, string path = "")
@@ -87,7 +89,18 @@ namespace XED.Manage
}
string path = Application.streamingAssetsPath + "/baseAssetData";
CoroutineRunner.instance.StartCoroutine(CoroutineLoadFromLocalData(path));
string filePath = GetLocalPath(path);
if (!CheckFilePathExists(filePath))
{
isLoadTaskComplete = true;
return;
}
// var command = new ActivateMoveGizmoCommand(rtgController);
//CommandInvoker.instance.Invoke(command);
CoroutineRunner.instance.StartCoroutine(CoroutineLoadFromLocalData(filePath));
}
public CustomAssetData GetCustomAssetData(string name)
@@ -96,126 +109,6 @@ namespace XED.Manage
//return listAssets.FirstOrDefault(x => x.name == name);
}
IEnumerator CoroutineLoadLocalFiles()
{
while (true)
{
yield return new WaitUntil(() => loadFilePath.Count > 0);
string path = loadFilePath.Dequeue();
string name = System.IO.Path.GetFileNameWithoutExtension(path);
//if (listAssets.Find(x => x.name == name) != null)
//{
// yield return null;
// continue;
//}
if (dataRepo.TryGetDataFromName(name, out var p))
{
yield return null;
continue;
}
string directoryPath = Path.GetDirectoryName(path);
string lastFolderName = Path.GetFileName(directoryPath);
string createDate = File.GetCreationTime(path).ToShortDateString();
string lastRevisionDate = File.GetLastAccessTime(path).ToShortDateString();
string uploadDate = DateTime.Now.ToShortDateString();
GameObject newObject = new GameObject(name);
newObject.transform.parent = fbxAnchor;
CustomAssetData assetData = newObject.AddComponent<CustomAssetData>();
assetData.assetName = name;
assetData.folderName = lastFolderName;
assetData.createDate = createDate;
assetData.LastRevisionDate = lastRevisionDate;
assetData.UploadDate = uploadDate;
assetData.Creator = "xr@uvc.co.kr";
assetData.Manager = "xr@uvc.co.kr";
assetData.LoadLocalFBX(path);
dataRepo.Add(assetData);
//onLoadFbxFile?.Invoke(name, lastFolderName, assetData);
yield return new WaitUntil(() => (assetData.isLoadComplete == true && assetData.progress == 1) || assetData.isLoadError == true);
if (assetData.isLoadError)
{
dataRepo.Remove(assetData);
ManagerHub.instance.Get<CustomAssetConnector>().assetDataHandler.OnRemoveFbxFile(name);
//onRemoveFbxFile?.Invoke(name);
}
yield return null;
}
}
IEnumerator CoroutineSaveToLocalData(List<CustomAssetData> assetDatas, string path)
{
//if (assetDatas == null || assetDatas.Count == 0)
//{
// assetDatas = listAssets;
//}
//if (assetDatas.Count == 0)
//{
// Debug.Log("No AssetDatas to Save");
// isSaveTaskComplete = true;
// yield break;
//}
if (dataRepo.isEmpty)
{
dataRepo.AddRange(assetDatas);
}
if (dataRepo.isEmpty)
{
Debug.Log("No AssetDatas to Save");
isSaveTaskComplete = true;
yield break;
}
isSaveTaskComplete = false;
List<SavedModelData> savedModels = new List<SavedModelData>();
List<ThumbnailData> thumbnails = new List<ThumbnailData>();
RuntimePreviewGenerator.BackgroundColor = Color.clear;
RuntimePreviewGenerator.OrthographicMode = true;
for (int i = 0; i < assetDatas.Count; i++)
{
var modelData = ConvertToSaveData(assetDatas[i]);
Texture2D thumbnail = RuntimePreviewGenerator.GenerateModelPreview(assetDatas[i].loadedObject.transform, 320, 200);
thumbnail = thumbnail.MakeReadableTexture();
thumbnails.Add(new ThumbnailData(thumbnail.EncodeToPNG()));
savedModels.Add(modelData);
}
saveData.modelDatas = savedModels.ToArray();
saveData.textureDatas = sharedMaterial.textureDatas.ToArray();
saveData.thumbnailDatas = thumbnails.ToArray();
yield return null;
//Task task = SaveAsync(identifier, saveData);
string filePath = string.IsNullOrEmpty(path) ? Path.Combine(Application.persistentDataPath, identifier) : path;
Task task = Task.Run(() => messagePacker.SaveAsync(filePath, saveData));
yield return new WaitUntil(() => task.IsCompleted);
isSaveTaskComplete = true;
yield return null;
}
SavedModelData ConvertToSaveData(CustomAssetData assetData)
{
SavedModelData modelData = new SavedModelData();
modelData.SaveData(assetData.loadedObject, sharedMaterial);
//갯수 제한 없음 원하는 만큼 조절 가능. 테스트로 10개만 지정
modelData.attributes = new string[7][];
modelData.attributes[0] = new string[] { "assetName", assetData.assetName };
modelData.attributes[1] = new string[] { "folderName", assetData.folderName };
modelData.attributes[2] = new string[] { "createDate", assetData.createDate };
modelData.attributes[3] = new string[] { "LastRevisionDate", assetData.LastRevisionDate };
modelData.attributes[4] = new string[] { "UploadDate", assetData.UploadDate };
modelData.attributes[5] = new string[] { "Creator", assetData.createDate };
modelData.attributes[6] = new string[] { "Manager", assetData.Manager };
return modelData;
}
string GetLocalPath(string path)
{
if (string.IsNullOrEmpty(path))
@@ -237,25 +130,9 @@ namespace XED.Manage
return true;
}
IEnumerator CoroutineLoadFromLocalData(string path)
IEnumerator CoroutineLoadFromLocalData(string filePath)
{
isLoadTaskComplete = false;
float loadTime = 0;
//string filePath = string.IsNullOrEmpty(path) ? Path.Combine(Application.persistentDataPath, identifier) : path;
string filePath = GetLocalPath(path);
if (!CheckFilePathExists(filePath))
{
isLoadTaskComplete = true;
yield break;
}
//if (!System.IO.File.Exists(filePath))
//{
// Debug.Log("No File Found At : " + filePath);
// isLoadTaskComplete = true;
// yield break;
//}
Task<SaveData> task = Task<SaveData>.Run(() => messagePacker.LoadAsync(filePath));
yield return new WaitUntil(() => task.IsCompleted);
@@ -267,72 +144,19 @@ namespace XED.Manage
isLoadTaskComplete = true;
yield break;
}
saveData = task.Result;
for (int i = 0; i < saveData.textureDatas.Length; i++)
{
TextureData texData = saveData.textureDatas[i];
sharedMaterial.AddTextureData(texData);
loadTime += Time.deltaTime;
if (loadTime > 1.0f / 30.0f)
{
loadTime = 0;
yield return null;
}
}
for (int i = 0; i < saveData.modelDatas.Length; i++)
{
if (!LoadSaveData(saveData, i))
{
continue;
}
loadTime += Time.deltaTime;
if (loadTime > 1.0f / 30.0f)
{
loadTime = 0;
yield return null;
}
}
// float loadTime = 0f;
var command = new LoadLocalTextureDataCommand(sharedMaterial, saveData.textureDatas);
CommandInvoker.instance.Invoke(command);
var command2 = new LoadLocalModelDataCommand(saveData, dataRepo, fbxAnchor, sharedMaterial);
CommandInvoker.instance.Invoke(command2);
isLoadTaskComplete = true;
yield return null;
}
bool LoadSaveData(SaveData saveData, int index)
{
var modelData = saveData.modelDatas[index];
string assetName = modelData.attributes.FirstOrDefault(x => x[0].Equals("assetName"))?[1];
if (dataRepo.TryGetDataFromName(assetName, out var p))
return false;
string folderName = modelData.attributes.FirstOrDefault(x => x[0].Equals("folderName"))?[1];
string createDate = modelData.attributes.FirstOrDefault(x => x[0].Equals("createDate"))?[1];
string lastRevisionDate = modelData.attributes.FirstOrDefault(x => x[0].Equals("lastRevisionDate"))?[1];
string uploadDate = modelData.attributes.FirstOrDefault(x => x[0].Equals("uploadDate"))?[1];
string creator = modelData.attributes.FirstOrDefault(x => x[0].Equals("creator"))?[1];
string manager = modelData.attributes.FirstOrDefault(x => x[0].Equals("manager"))?[1];
Texture2D thumbnail = new Texture2D(1, 1);
thumbnail.LoadImage(saveData.thumbnailDatas[index].data);
GameObject newObject = new GameObject(assetName);
newObject.transform.parent = fbxAnchor;
CustomAssetData assetData = newObject.AddComponent<CustomAssetData>();
assetData.assetName = assetName;
assetData.folderName = folderName;
assetData.createDate = createDate;
assetData.LastRevisionDate = lastRevisionDate;
assetData.UploadDate = uploadDate;
assetData.Creator = creator;
assetData.Manager = manager;
assetData.loadedObject = modelData.LoadModelData(sharedMaterial);
assetData.thumbnail = thumbnail;
assetData.OnLoadComplete();
dataRepo.Add(assetData);
//listAssets.Add(assetData);
ManagerHub.instance.Get<CustomAssetConnector>().assetDataHandler.OnLoadFbxFile(assetData.assetName, assetData.folderName, assetData);
return true;
}
}
}

View File

@@ -3,15 +3,13 @@ using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using XED.Asset;
using XED.Command;
using XED.Core;
using XED.DataStructures;
using XED.Interfaces;
using XED.Manage;
using XED.RuntimeGizmo;
using XED.RuntimeGizmo;
namespace XED.Util
{
@@ -218,19 +216,23 @@ namespace XED.Util
}
public void ResetRTG()
{
rtgController.SetWorkGizmoId(RTGController.GizmoId.None);
var command = new ResetGizmoCommand(rtgController);
CommandInvoker.instance.Invoke(command);
}
public void SetRTGMove()
{
rtgController.SetWorkGizmoId(RTGController.GizmoId.Move);
var command = new ActivateMoveGizmoCommand(rtgController);
CommandInvoker.instance.Invoke(command);
}
public void SetRTGScale()
{
rtgController.SetWorkGizmoId(RTGController.GizmoId.Scale);
var command = new ActivateScaleGizmoCommand(rtgController);
CommandInvoker.instance.Invoke(command);
}
public void SetRTGRotate()
{
rtgController.SetWorkGizmoId(RTGController.GizmoId.Rotate);
var command = new ActivateRotateGizmoCommand(rtgController);
CommandInvoker.instance.Invoke(command);
}
public void OnTransformBegin()
{

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 553a24c445d45734e93db3694688a065
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
using System.IO;
using UnityEngine;
using XED.Command;
namespace XED
{
public class MoveToTargetCommand : IIrreversibleCommand
{
private Transform target;
private Vector3 viewAngle;
private float cameraDistance;
public MoveToTargetCommand(Transform target, Vector3 viewAngle, float cameraDistance)
{
this.target = target;
this.viewAngle = viewAngle;
this.cameraDistance = cameraDistance;
}
public string id { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
public bool CanExecute()
{
throw new System.NotImplementedException();
}
public void Execute()
{
Camera.main.transform.rotation = Quaternion.Euler(viewAngle);
Camera.main.transform.position = target.position;
Camera.main.transform.position += -Camera.main.transform.forward * cameraDistance;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: af71595b728196a4391585fa1be345c8

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0344068c97e98f2499c3ef328e804d1c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,94 @@
using System.Collections;
using System.Linq;
using UnityEngine;
using XED.Asset;
using XED.Manage;
using XED.Repositories;
using XED.Util;
namespace XED.Command
{
public class LoadLocalModelDataCommand : IIrreversibleCommand
{
private SaveData saveData;
private CustomAssetDataRepository dataRepo;
private Transform fbxAnchor;
private SharedMaterial sharedMaterial;
float loadTime = 0f;
public LoadLocalModelDataCommand(SaveData saveData, CustomAssetDataRepository dataRepo, Transform fbxAnchor, SharedMaterial sharedMaterial)
{
this.saveData = saveData;
this.dataRepo = dataRepo;
this.fbxAnchor = fbxAnchor;
this.sharedMaterial = sharedMaterial;
}
public string id { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
public bool CanExecute()
{
throw new System.NotImplementedException();
}
public void Execute()
{
for (int i = 0; i < saveData.modelDatas.Length; i++)
{
CoroutineRunner.instance.StartCoroutine(LoadModelData(i));
}
}
IEnumerator LoadModelData(int index)
{
if (!LoadSaveData(saveData, index))
yield break;
loadTime += Time.deltaTime;
if (loadTime > 1f / 30f)
{
loadTime = 0f;
yield return null;
}
}
bool LoadSaveData(SaveData saveData, int index)
{
var modelData = saveData.modelDatas[index];
string assetName = modelData.attributes.FirstOrDefault(x => x[0].Equals("assetName"))?[1];
if (dataRepo.TryGetDataFromName(assetName, out var p))
return false;
string folderName = modelData.attributes.FirstOrDefault(x => x[0].Equals("folderName"))?[1];
string createDate = modelData.attributes.FirstOrDefault(x => x[0].Equals("createDate"))?[1];
string lastRevisionDate = modelData.attributes.FirstOrDefault(x => x[0].Equals("lastRevisionDate"))?[1];
string uploadDate = modelData.attributes.FirstOrDefault(x => x[0].Equals("uploadDate"))?[1];
string creator = modelData.attributes.FirstOrDefault(x => x[0].Equals("creator"))?[1];
string manager = modelData.attributes.FirstOrDefault(x => x[0].Equals("manager"))?[1];
Texture2D thumbnail = new Texture2D(1, 1);
thumbnail.LoadImage(saveData.thumbnailDatas[index].data);
GameObject newObject = new GameObject(assetName);
newObject.transform.parent = fbxAnchor;
CustomAssetData assetData = newObject.AddComponent<CustomAssetData>();
assetData.assetName = assetName;
assetData.folderName = folderName;
assetData.createDate = createDate;
assetData.LastRevisionDate = lastRevisionDate;
assetData.UploadDate = uploadDate;
assetData.Creator = creator;
assetData.Manager = manager;
assetData.loadedObject = modelData.LoadModelData(sharedMaterial);
assetData.thumbnail = thumbnail;
assetData.OnLoadComplete();
dataRepo.Add(assetData);
//listAssets.Add(assetData);
ManagerHub.instance.Get<CustomAssetConnector>().assetDataHandler.OnLoadFbxFile(assetData.assetName, assetData.folderName, assetData);
return true;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 34c7091e151c4654f80f16448c43f36d

View File

@@ -0,0 +1,50 @@
using System.Collections;
using UnityEngine;
using XED.Manage;
namespace XED.Command
{
public class LoadLocalTextureDataCommand : IIrreversibleCommand
{
private SharedMaterial sharedMaterial;
private TextureData[] textureData;
float loadTime = 0f;
public LoadLocalTextureDataCommand(SharedMaterial sharedMaterial, TextureData[] textureData)
{
this.sharedMaterial = sharedMaterial;
this.textureData = textureData;
}
public string id { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
public bool CanExecute()
{
throw new System.NotImplementedException();
}
public void Execute()
{
foreach (var tex in textureData)
{
CoroutineRunner.instance.StartCoroutine(LoadTextureData(tex));
}
}
IEnumerator LoadTextureData(TextureData texData)
{
sharedMaterial.AddTextureData(texData);
loadTime += Time.deltaTime;
if (loadTime > 1f / 30f)
{
loadTime = 0f;
yield return null;
}
// yield return null;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 243104ea078b0364e811f6803ef3b3b2

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 58c7bd081b97acf42a09b5b4ef1d3fad
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using XED.RuntimeGizmo;
namespace XED.Command
{
public class ActivateMoveGizmoCommand : IIrreversibleCommand
{
private RTGController rtgController;
public ActivateMoveGizmoCommand(RTGController rtgController)
{
this.rtgController = rtgController;
}
public string id { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
public bool CanExecute()
{
throw new System.NotImplementedException();
}
public void Execute()
{
rtgController.SetWorkGizmoId(RTGController.GizmoId.Move);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 96806282dbad1954fb33e13354823e92

View File

@@ -0,0 +1,26 @@
using XED.RuntimeGizmo;
namespace XED.Command
{
public class ActivateRotateGizmoCommand : IIrreversibleCommand
{
private RTGController rtgController;
public ActivateRotateGizmoCommand(RTGController rtgController)
{
this.rtgController = rtgController;
}
public string id { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
public bool CanExecute()
{
throw new System.NotImplementedException();
}
public void Execute()
{
rtgController.SetWorkGizmoId(RTGController.GizmoId.Rotate);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b70e099d374f64847834ff12c191bd91

View File

@@ -0,0 +1,26 @@
using XED.RuntimeGizmo;
namespace XED.Command
{
public class ActivateScaleGizmoCommand : IIrreversibleCommand
{
private RTGController rtgController;
public ActivateScaleGizmoCommand(RTGController rtgController)
{
this.rtgController = rtgController;
}
public string id { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
public bool CanExecute()
{
throw new System.NotImplementedException();
}
public void Execute()
{
rtgController.SetWorkGizmoId(RTGController.GizmoId.Scale);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8959657a6330abd448297620191164d5

View File

@@ -0,0 +1,26 @@
using XED.RuntimeGizmo;
namespace XED.Command
{
public class ResetGizmoCommand : IIrreversibleCommand
{
private RTGController rtgController;
public ResetGizmoCommand(RTGController rtgController)
{
this.rtgController = rtgController;
}
public string id { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
public bool CanExecute()
{
throw new System.NotImplementedException();
}
public void Execute()
{
rtgController.SetWorkGizmoId(RTGController.GizmoId.None);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6d2c3f6f335592d4e888a96dbd9903d3

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cee17c4be8819da47a5eb95110ec3455
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,62 @@
using System.Collections.Generic;
using System.Linq;
using XED.Asset;
using XED.HierarchyTree;
using XED.Util;
namespace XED.Command
{
public class LoadProjectCommand : IIrreversibleCommand
{
private List<AssetData> assets;
private CustomAssetConnector connector;
Dictionary<int, HierarchyItem> itemDict = new Dictionary<int, HierarchyItem>();
public LoadProjectCommand(List<AssetData> assets, CustomAssetConnector connector)
{
this.assets = assets;
this.connector = connector;
}
public string id { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
public bool CanExecute()
{
throw new System.NotImplementedException();
}
public void Execute()
{
foreach (AssetData asset in assets)
{
LoadAsset(asset);
}
foreach (AssetData asset in assets)
{
RestoreHierarchy(asset);
}
}
private void LoadAsset(AssetData asset)
{
connector.OnLoadAsset(asset);
itemDict.Add(asset.id, connector.connectedAssets.Last().hierarchyItem);
}
private void RestoreHierarchy(AssetData asset)
{
foreach (int id in asset.children)
{
HierarchyItem parent = itemDict[asset.id];
HierarchyItem child = itemDict[id];
if (parent == null || child == null)
continue;
connector.OnRestoreHierarchy(parent, child);
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 58dff3fed88a2eb4fab1bc8116f0c170

View File

@@ -0,0 +1,27 @@
using XED.Asset;
namespace XED.Command
{
public class NewProjectCommand : IIrreversibleCommand
{
CustomAssetConnector connector;
public NewProjectCommand(CustomAssetConnector connector)
{
this.connector = connector;
}
public string id { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
public bool CanExecute()
{
throw new System.NotImplementedException();
}
public void Execute()
{
connector.ClearObjects();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 16f7564790f59584283a83911585ada8

View File

@@ -0,0 +1,36 @@
using Newtonsoft.Json;
using System.IO;
using XED.Command;
using XED.Util;
namespace XED
{
public class SaveProjectCommand : IIrreversibleCommand
{
private string projectPath;
private ProjectData projectData;
public SaveProjectCommand(string projectPath, ProjectData projectData)
{
this.projectPath = projectPath;
this.projectData = projectData;
}
public string id { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
public bool CanExecute()
{
throw new System.NotImplementedException();
}
public void Execute()
{
string json = JsonConvert.SerializeObject(projectData);
FileStream fs = new FileStream(projectPath, FileMode.Create, FileAccess.Write);
StreamWriter writer = new StreamWriter(fs, System.Text.Encoding.Unicode);
writer.Write(json);
writer.Close();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 91703b89f5f43354d9d896c2f4b8dcde

View File

@@ -1,24 +1,23 @@
using UnityEngine;
using XED.Command;
namespace XED.Manage
{
public class CameraManager : Manager
{
private float objectViewDistance;
private Vector3 objectViewRotation;
private float cameraDistance;
private Vector3 viewAngle;
public override void Init()
{
objectViewDistance = 25f;
objectViewRotation = new Vector3(45, 145, 0);
cameraDistance = 25f;
viewAngle = new Vector3(45, 145, 0);
}
public void MoveToTwinObjectPos(TwinObject twinObject)
public void MoveToTwinObjectPos(TwinObject target)
{
Camera.main.transform.rotation = Quaternion.Euler(objectViewRotation);
Camera.main.transform.position = twinObject.transform.position;
Camera.main.transform.position += -Camera.main.transform.forward * objectViewDistance;
var command = new MoveToTargetCommand(target.transform, viewAngle, cameraDistance);
CommandInvoker.instance.Invoke(command);
}
}
}

View File

@@ -3,9 +3,11 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using TriLibCore.Dae.Schema;
using TriLibCore.SFB;
using UnityEditor;
using XED.Asset;
using XED.Command;
using XED.HierarchyTree;
using XED.Service;
using XED.Util;
@@ -16,23 +18,23 @@ namespace XED.Manage
public class ProjectManager : Manager
{
private AssetDataService assetDataService;
private CustomAssetConnector connector;
private string curProjectPath;
private ProjectData curProjectData;
Dictionary<int, HierarchyItem> itemDict = new Dictionary<int, HierarchyItem>();
public ProjectManager()
{
assetDataService = new AssetDataService();
connector = ManagerHub.instance.Get<CustomAssetConnector>();
}
public override void Init()
{
curProjectPath = string.Empty;
curProjectData = null;
itemDict.Clear();
}
public void SaveProject()
{
bool isNewProject = string.IsNullOrEmpty(curProjectPath);
@@ -42,14 +44,14 @@ namespace XED.Manage
if (string.IsNullOrEmpty(path))
return;
var connector = ManagerHub.instance.Get<CustomAssetConnector>();
List<AssetData> assetDatas = assetDataService.SortAssetDatas(connector.connectedAssets);
ProjectData projectData = CreateProjectData(path, assetDatas);
curProjectPath = path;
curProjectData = projectData;
SaveFile();
var command = new SaveProjectCommand(curProjectPath, curProjectData);
CommandInvoker.instance.Invoke(command);
}
public void LoadProject()
@@ -67,24 +69,23 @@ namespace XED.Manage
if (projectData == null)
return;
var connector = ManagerHub.instance.Get<CustomAssetConnector>();
connector.ClearObjects();
Init();
LoadAssets(projectData.assetDatas);
RestoreHierarchys(projectData.assetDatas);
curProjectPath = path;
curProjectData = projectData;
var command = new LoadProjectCommand(curProjectData.assetDatas, connector);
CommandInvoker.instance.Invoke(command);
}
public void NewProject()
{
var connector = ManagerHub.instance.Get<CustomAssetConnector>();
connector.ClearObjects();
Init();
var command = new NewProjectCommand(connector);
CommandInvoker.instance.Invoke(command);
}
private ProjectData CreateProjectData(string path, List<AssetData> assetDatas)
@@ -97,43 +98,6 @@ namespace XED.Manage
};
}
private void LoadAssets(List<AssetData> assets)
{
foreach (AssetData asset in assets)
{
LoadAsset(asset);
}
}
private void LoadAsset(AssetData asset)
{
var connector = ManagerHub.instance.Get<CustomAssetConnector>();
connector.OnLoadAsset(asset);
itemDict.Add(asset.id, connector.connectedAssets.Last().hierarchyItem);
}
private void RestoreHierarchys(List<AssetData> assets)
{
foreach (AssetData asset in assets)
{
RestoreHierarchy(asset);
}
}
private void RestoreHierarchy(AssetData asset)
{
foreach (int id in asset.children)
{
HierarchyItem parent = itemDict[asset.id];
HierarchyItem child = itemDict[id];
if (parent == null || child == null)
continue;
ManagerHub.instance.Get<CustomAssetConnector>().OnRestoreHierarchy(parent, child);
}
}
private string GetSaveFilePath()
{
var data = StandaloneFileBrowser.SaveFilePanel("SaveProject", "", "", "json");
@@ -146,14 +110,6 @@ namespace XED.Manage
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)
{

View File

@@ -1,11 +1,10 @@
using UnityEngine;
using UnityEngine.EventSystems;
using XED.Manage;
using XED.UI;
using XED.Util;
using XED.VirtualFactory;
using XRLib;
using XRLib.UI;
using XED.UI;
using XED.VirtualFactory;
using XED.Manage;
using XED.Util;
namespace XED
{

View File

@@ -36,7 +36,7 @@ namespace XED.UI
panel_topbar.onClickSaveProject += projectManager.SaveProject;
panel_topbar.onClickLoadProject += projectManager.LoadProject;
panel_topbar.onClickNewProject += projectManager.NewProject;
panel_topbar.onClickLoadAssets += fbxFileManager.LoadLocalFBXDirectory;
//panel_topbar.onClickLoadAssets += fbxFileManager.LoadLocalFBXDirectory;
panel_topbar.onClickAssetWindow += fbxFileManager.LoadLocalData;
panel_toolbar.onClickMove += renderObjectHandler.SetRTGMove;