Compare commits

...

1 Commits

Author SHA1 Message Date
geondo55
e67b716dcf 백업 2025-05-21 18:45:17 +09:00
22 changed files with 6810 additions and 75 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 B

View File

@@ -0,0 +1,143 @@
fileFormatVersion: 2
guid: 8ae7ba28e5e688341bb4e3e8ff1c5402
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,143 @@
fileFormatVersion: 2
guid: b72b5d6903362d84bafed8c3a24b81d8
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -4,16 +4,5 @@ namespace Studio.UVC.UI
{
public class CreateUIPanel : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
}

View File

@@ -7,7 +7,7 @@ using UnityEngine;
using UnityEngine.Rendering;
using XED.UI;
namespace XED
namespace XED.Test
{
public class SDIDashboardTest : MonoBehaviour
{

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 891a21f60f52f5a478a40b70b28ccbe0
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,3 +1,4 @@
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -394,6 +395,31 @@ namespace XED.Util
userInputManager .RemoveHandler(myHandler);
}
private void ActiveMoveGizmoCommand()
{
CommandInvoker.instance.Invoke(new ActivateMoveGizmoCommand());
}
private void ActivateRotateGizmoCommand()
{
CommandInvoker.instance.Invoke(new ActivateRotateGizmoCommand());
}
private void ActivateScaleGizmoCommand()
{
CommandInvoker.instance.Invoke(new ActivateScaleGizmoCommand());
}
private void ResetGizmoCommand()
{
CommandInvoker.instance.Invoke(new ResetGizmoCommand());
}
private void CopyObjectCommand()
{
CommandInvoker.instance.Invoke(new CopyObjectCommand());
}
public InputHandler GetInputHandler()
{
var getKeyActions = new Dictionary<KeyCode, Action>();
@@ -402,25 +428,60 @@ namespace XED.Util
downKeyActions.Add(KeyCode.Mouse0, OnMousePointerDown);
upKeyActions.Add(KeyCode.Mouse0, OnMousePointerUp);
getKeyActions.Add(KeyCode.Q, () => CommandInvoker.instance.Invoke(new ActivateMoveGizmoCommand()));
getKeyActions.Add(KeyCode.W, () => CommandInvoker.instance.Invoke(new ActivateRotateGizmoCommand()));
getKeyActions.Add(KeyCode.E, () => CommandInvoker.instance.Invoke(new ActivateScaleGizmoCommand()));
getKeyActions.Add(KeyCode.R, () => CommandInvoker.instance.Invoke(new ResetGizmoCommand()));
getKeyActions.Add(KeyCode.Q, ActiveMoveGizmoCommand);
getKeyActions.Add(KeyCode.W, ActivateRotateGizmoCommand);
getKeyActions.Add(KeyCode.E, ActivateScaleGizmoCommand);
getKeyActions.Add(KeyCode.R, ResetGizmoCommand);
getKeyActions.Add(KeyCode.V, VertexSnap);
var shortcutTable = new Dictionary<KeyCode, Dictionary<KeyCode, Action>>();
#if UNITY_EDITOR
shortcutTable.Add(KeyCode.LeftShift, new Dictionary<KeyCode, Action>());
shortcutTable[KeyCode.LeftShift].Add(KeyCode.C, SaveItemsToCopy);
shortcutTable[KeyCode.LeftShift].Add(KeyCode.V, () => CommandInvoker.instance.Invoke(new CopyObjectCommand()));
#else
shortcutTable.Add(KeyCode.LeftControl, new Dictionary<KeyCode, Action>());
shortcutTable[KeyCode.LeftControl].Add(KeyCode.C, SaveItemsToCopy);
shortcutTable[KeyCode.LeftShift].Add(KeyCode.V, () => CommandInvoker.instance.Invoke(new CopyObjectCommand()));
#endif
var shortcutTable = new Dictionary<KeyCode, Dictionary<KeyCode, Dictionary<KeyCode, Action>>>();
var handler = new InputHandler(getKeyActions, downKeyActions, upKeyActions, shortcutTable);
#if UNITY_EDITOR
shortcutTable[KeyCode.LeftShift] = new Dictionary<KeyCode, Dictionary<KeyCode, Action>>
{
[KeyCode.None] = new Dictionary<KeyCode, Action>
{
[KeyCode.C] = SaveItemsToCopy,
[KeyCode.V] = CopyObjectCommand
}
};
#else
// Ctrl + (None) + C/V
shortcutTable[KeyCode.LeftControl] = new Dictionary<KeyCode, Dictionary<KeyCode, Action>>
{
[KeyCode.None] = new Dictionary<KeyCode, Action>
{
[KeyCode.C] = SaveItemsToCopy,
[KeyCode.V] = () => CommandInvoker.instance.Invoke(new CopyObjectCommand())
}
};
#endif
var handler = new RenderObjectHandlerInputHandler(GetType().FullName, getKeyActions, downKeyActions, upKeyActions, shortcutTable);
ManagerHub.instance.Get<UserInputHandlerManager>().CreateInputHandler(handler);
return handler;
}
}
public class RenderObjectHandlerInputHandler : InputHandler
{
public string owner;
public RenderObjectHandlerInputHandler(
string owner,
Dictionary<KeyCode, Action> getKeyActions,
Dictionary<KeyCode, Action> downKeyActions,
Dictionary<KeyCode, Action> upKeyActions,
Dictionary<KeyCode, Dictionary<KeyCode, Dictionary<KeyCode, Action>>> shortCutActions,
Action updateLoop = null
) : base(
getKeyActions: getKeyActions,
downKeyActions: downKeyActions,
upKeyActions: upKeyActions,
shortCutActions: shortCutActions,
updateLoop: updateLoop
)
{
this.owner = owner;
}
}
}

View File

@@ -42,12 +42,38 @@ namespace XED.Command
}
public InputHandler GetInputHandler()
{
var shortcutTable = new Dictionary<KeyCode, Dictionary<KeyCode, Action>>();
shortcutTable.Add(KeyCode.LeftControl, new Dictionary<KeyCode, Action>());
shortcutTable[KeyCode.LeftControl].Add(KeyCode.Z, Undo);
shortcutTable[KeyCode.LeftControl].Add(KeyCode.X, Redo);
var handler = new InputHandler(null, null, null, shortcutTable);
var shortcutTable = new Dictionary<KeyCode, Dictionary<KeyCode, Dictionary<KeyCode, Action>>>();
shortcutTable[KeyCode.LeftShift] = new Dictionary<KeyCode, Dictionary<KeyCode, Action>>
{
[KeyCode.None] = new Dictionary<KeyCode, Action>
{
[KeyCode.Z] = Undo,
[KeyCode.X] = Redo
}
};
var handler = new CommandInvokerInputHandler(null, null, null, shortcutTable);
ManagerHub.instance.Get<UserInputHandlerManager>().CreateInputHandler(handler);
return handler;
}
public class CommandInvokerInputHandler : InputHandler
{
public CommandInvokerInputHandler(
Dictionary<KeyCode, Action> getKeyActions,
Dictionary<KeyCode, Action> downKeyActions,
Dictionary<KeyCode, Action> upKeyActions,
Dictionary<KeyCode, Dictionary<KeyCode, Dictionary<KeyCode, Action>>> shortCutActions,
Action updateLoop = null
) : base(
getKeyActions: getKeyActions,
downKeyActions: downKeyActions,
upKeyActions: upKeyActions,
shortCutActions: shortCutActions,
updateLoop: updateLoop
)
{
}
}
}
}

View File

@@ -1,3 +1,4 @@
using UnityEngine;
using XED.Manage;
namespace XED.Interfaces

View File

@@ -987,7 +987,7 @@ namespace XED.Manage
public void StatusEnterEvent()
{
raycaster.AddEvent(Raycaster.EventType.FirstStay, typeof (Map), OnStayMap);
raycaster.AddEvent(Raycaster.EventType.FirstStay, typeof(Map), OnStayMap);
raycaster.AddEvent(Raycaster.EventType.FirstClick, typeof(Map), OnClickMap);
raycaster.AddEvent(Raycaster.EventType.FirstClick, typeof(LinePoint), OnClickLinePoint);

View File

@@ -428,8 +428,9 @@ namespace XED.Manage
getKeyActions.Add(KeyCode.Alpha4, () => ChangeSelectMode(NodeSelectMode.SelectRunNode));
getKeyActions.Add(KeyCode.Escape, () => ChangeSelectMode(NodeSelectMode.Idle));
var handler = new InputHandler(getKeyActions, downKeyActions, upKeyActions);
ManagerHub.instance.Get<UserInputHandlerManager>().CreateInputHandler(handler);
return handler;
}

View File

@@ -36,24 +36,24 @@ namespace XED.Manage
var userInputManager = GameObject.FindAnyObjectByType<UserInputManager>();
var commandHandler = CommandInvoker.instance.GetInputHandler();
userInputManager.SetHandler(GetDefaultInputHandler());
//userInputManager.SetHandler(GetDefaultInputHandler());
userInputManager.SetHandler(commandHandler);
}
InputHandler defaultInputHandler;
InputHandler GetDefaultInputHandler()
{
if (defaultInputHandler == null)
{
Dictionary<KeyCode, Action> upKeyActions = new();
Dictionary<KeyCode, Action> getKeyActions = new();
Dictionary<KeyCode, Action> downKeyActions = new();
Dictionary<KeyCode, Dictionary<KeyCode, Action>> hotkeyActions = new();
//InputHandler defaultInputHandler;
//public InputHandler GetDefaultInputHandler()
//{
// if (defaultInputHandler == null)
// {
// Dictionary<KeyCode, Action> upKeyActions = new();
// Dictionary<KeyCode, Action> getKeyActions = new();
// Dictionary<KeyCode, Action> downKeyActions = new();
// Dictionary<KeyCode, Dictionary<KeyCode, Dictionary<KeyCode, Action>>> hotkeyActions = new();
defaultInputHandler = new InputHandler(getKeyActions, downKeyActions, upKeyActions, hotkeyActions);
}
// defaultInputHandler = new InputHandler(getKeyActions, downKeyActions, upKeyActions, hotkeyActions);
// }
return defaultInputHandler;
}
// return defaultInputHandler;
//}
}
}

View File

@@ -6,16 +6,17 @@ namespace XED.Manage
{
public class InputHandler
{
public string id;
public Action updateLoop;
public Dictionary<KeyCode, Action> getKeyActions;
public Dictionary<KeyCode, Action> downKeyActions;
public Dictionary<KeyCode, Action> upKeyActions;
public Dictionary<KeyCode, Dictionary<KeyCode, Action>> shortCutActions;
public Dictionary<KeyCode, Dictionary<KeyCode, Dictionary<KeyCode, Action>>> shortCutActions;
public InputHandler(
Dictionary<KeyCode, Action> getKeyActions = null,
Dictionary<KeyCode, Action> downKeyActions = null,
Dictionary<KeyCode, Action> upKeyActions = null,
Dictionary<KeyCode, Dictionary<KeyCode, Action>> shortCutActions = null,
Dictionary<KeyCode, Dictionary<KeyCode, Dictionary<KeyCode, Action>>> shortCutActions= null,
Action updateLoop = null)
{
if (getKeyActions == null)
@@ -26,16 +27,16 @@ namespace XED.Manage
if (downKeyActions == null)
downKeyActions = new();
this.downKeyActions = downKeyActions;
if(upKeyActions == null)
if (upKeyActions == null)
upKeyActions = new();
this.upKeyActions = upKeyActions;
if(shortCutActions == null)
if (shortCutActions == null)
shortCutActions = new();
this.shortCutActions = shortCutActions;
this.updateLoop=updateLoop;
this.updateLoop = updateLoop;
}
}
}

View File

@@ -25,6 +25,7 @@ namespace XED.Manage
Join(new AGVManager());
Join(new WallBuilder());
Join(new MeshCreator());
Join(new UserInputHandlerManager());
foreach(var m in managers)
{

View File

@@ -0,0 +1,213 @@
using Best.HTTP.JSON;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;
using static UnityEngine.EventSystems.EventTrigger;
namespace XED.Manage
{
public class UserInputHandlerManager : Manager
{
List<InputHandler> inputHandlers = new List<InputHandler>();
public override void Init()
{
// SaveHandlerStack();
}
public void CreateInputHandler(InputHandler inputHandler)
{
for (int i = 0; i < inputHandlers.Count; i++)
{
if (inputHandlers[i].GetType() == inputHandler.GetType())
{
inputHandlers[i] = inputHandler;
return;
}
}
inputHandlers.Add(inputHandler);
}
public void SaveHandlerStack()
{
var data = new HandlerStackData();
foreach (var handler in inputHandlers)
{
var preset = new HandlerPreset()
{
id = handler.GetType().FullName,
updateLoopId = handler.updateLoop?.Method.Name,
};
foreach (var pair in handler.getKeyActions)
preset.getKeyActions.Add(new KeyActionEntry
{
key = pair.Key.ToString(),
actionId = pair.Value.Method.Name,
});
foreach (var pair in handler.downKeyActions)
preset.downKeyActions.Add(new KeyActionEntry
{
key = pair.Key.ToString(),
actionId = pair.Value.Method.Name,
});
foreach (var pair in handler.upKeyActions)
preset.upKeyActions.Add(new KeyActionEntry
{
key = pair.Key.ToString(),
actionId = pair.Value.Method.Name,
});
foreach (var key1 in handler.shortCutActions)
{
foreach (var key2 in key1.Value)
{
foreach (var key3 in key2.Value)
{
preset.shortcutActions.Add(new ShortcutEntry
{
key1 = key1.Key.ToString(),
key2 = key2.Key.ToString(),
key3 = key3.Key.ToString(),
actionId = key3.Value.Method.Name,
});
}
}
}
data.handlers.Add(preset);
}
json = JsonConvert.SerializeObject(data);
Debug.Log("data " + json);
}
public void LoadHandlerStack()
{
var data = JsonConvert.DeserializeObject<HandlerStackData>(json);
foreach (var preset in data.handlers)
{
Type handlerType = Type.GetType(preset.id);
if (handlerType == null)
{
continue;
}
Debug.Log("preset.id " + preset.id);
Debug.Log("handlerType " + handlerType.FullName);
var handler = inputHandlers.FirstOrDefault(h => h.GetType() == handlerType);
if (handler == null)
{
continue;
}
// Debug.Log("handler " + handler);
// owner 접근
var ownerField = handlerType.GetField("owner", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
var ownerString = ownerField?.GetValue(handler) as string;
if (string.IsNullOrEmpty(ownerString))
{
continue;
}
var ownerType = Type.GetType(ownerString);
if (ownerType == null)
{
continue;
}
var ownerMethods = ownerType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (var entry in preset.getKeyActions)
{
// 함수 찾기
var method = ownerMethods.FirstOrDefault(m => m.Name == entry.actionId);
Debug.Log("method "+ method.Name);
Debug.Log("method " + method.Name);
Debug.Log("바보의 이름은")
//if (method != null)
//{
// var ownerInstanceObj = Activator.CreateInstance(ownerType);
// var action = (Action)Delegate.CreateDelegate(typeof(Action), ownerInstanceObj, method);
// var keyCode = ParseKeyCode(entry.key);
// Debug.Log("enter commit1");
// if (!handler.getKeyActions.ContainsKey(keyCode))
// {
// Debug.Log("enter commit2");
// handler.getKeyActions[keyCode] = action;
// }
//}
}
}
}
private KeyCode ParseKeyCode(string key)
{
if (Enum.TryParse<KeyCode>(key, out var result))
return result;
return KeyCode.None;
}
string json = @"{
""handlers"": [
{
""id"": ""CommandInvokerInputHandler"",
""updateLoopId"": null,
""getKeyActions"": [],
""downKeyActions"": [],
""upKeyActions"": [],
""shortcutActions"": [
{
""key1"": ""LeftShift"",
""key2"": ""None"",
""key3"": ""Z"",
""actionId"": ""Undo""
},
{
""key1"": ""LeftShift"",
""key2"": ""None"",
""key3"": ""X"",
""actionId"": ""Redo""
}
]
},
{
""id"": ""RenderObjectHandlerInputHandler"",
""updateLoopId"": null,
""getKeyActions"": [
{ ""key"": ""E"", ""actionId"": ""<GetInputHandler>b__36_0"" },
{ ""key"": ""W"", ""actionId"": ""<GetInputHandler>b__36_1"" },
{ ""key"": ""Q"", ""actionId"": ""<GetInputHandler>b__36_2"" },
{ ""key"": ""R"", ""actionId"": ""<GetInputHandler>b__36_3"" },
{ ""key"": ""V"", ""actionId"": ""VertexSnap"" }
],
""downKeyActions"": [
{ ""key"": ""Mouse0"", ""actionId"": ""OnMousePointerDown"" }
],
""upKeyActions"": [
{ ""key"": ""Mouse0"", ""actionId"": ""OnMousePointerUp"" }
],
""shortcutActions"": [
{ ""key1"": ""LeftShift"", ""key2"": ""None"", ""key3"": ""C"", ""actionId"": ""SaveItemsToCopy"" },
{ ""key1"": ""LeftShift"", ""key2"": ""None"", ""key3"": ""V"", ""actionId"": ""<GetInputHandler>b__36_4"" }
]
}
]
}";
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 41b60638740b3384ba1723efd9e19f03

View File

@@ -1,7 +1,12 @@
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using UnityEngine;
using XED.Util;
using XRLib;
namespace XED.Manage
@@ -11,9 +16,11 @@ namespace XED.Manage
Dictionary<KeyCode, Action> getKeyActionTable = new Dictionary<KeyCode, Action>();
Dictionary<KeyCode, Action> upKeyActionTable = new Dictionary<KeyCode, Action>();
Dictionary<KeyCode, Action> downKeyActionTable = new Dictionary<KeyCode, Action>();
Dictionary<KeyCode, Dictionary<KeyCode, Action>> shortCutActionTable = new ();
Dictionary<KeyCode, Dictionary<KeyCode, Dictionary<KeyCode, Action>>> shortCutActionTable = new();
Stack<InputHandler> handlerStack = new();
Action updateLoop;
public Func<InputHandler> onChangeShortcutKey;
public void SetHandler(InputHandler handler)
{
@@ -22,6 +29,7 @@ namespace XED.Manage
public void RemoveHandler(InputHandler handler)
{
Debug.Log("remove");
Stack<InputHandler> tempStack = new();
while (handlerStack.Count > 0)
@@ -60,12 +68,27 @@ namespace XED.Manage
downKeyActionTable.Remove(k.Key);
}
foreach(var k in handler.shortCutActions)
foreach (var k1 in handler.shortCutActions)
{
foreach(var kk in k.Value)
if (!shortCutActionTable.ContainsKey(k1.Key))
continue;
foreach (var k2 in k1.Value)
{
shortCutActionTable[k.Key].Remove(kk.Key);
if (!shortCutActionTable[k1.Key].ContainsKey(k2.Key))
continue;
foreach (var k3 in k2.Value)
{
shortCutActionTable[k1.Key][k2.Key].Remove(k3.Key);
}
if (shortCutActionTable[k1.Key][k2.Key].Count == 0)
shortCutActionTable[k1.Key].Remove(k2.Key);
}
if (shortCutActionTable[k1.Key].Count == 0)
shortCutActionTable.Remove(k1.Key);
}
updateLoop -= handler.updateLoop;
}
@@ -87,19 +110,20 @@ namespace XED.Manage
downKeyActionTable[k.Key]= k.Value;
}
foreach (var k in handler.shortCutActions)
foreach (var k1 in handler.shortCutActions)
{
if (!shortCutActionTable.ContainsKey(k.Key))
{
shortCutActionTable.Add(k.Key, new Dictionary<KeyCode, Action>());
}
if (!shortCutActionTable.ContainsKey(k1.Key))
shortCutActionTable[k1.Key] = new();
foreach (var kk in k.Value)
foreach (var k2 in k1.Value)
{
if (shortCutActionTable[k.Key].ContainsKey(kk.Key))
shortCutActionTable[k.Key].Remove(kk.Key);
if (!shortCutActionTable[k1.Key].ContainsKey(k2.Key))
shortCutActionTable[k1.Key][k2.Key] = new();
shortCutActionTable[k.Key].Add(kk.Key, kk.Value);
foreach (var k3 in k2.Value)
{
shortCutActionTable[k1.Key][k2.Key][k3.Key] = k3.Value;
}
}
}
updateLoop += handler.updateLoop;
@@ -130,24 +154,168 @@ namespace XED.Manage
}
}
foreach (var key in shortCutActionTable.Keys)
foreach (var key1 in shortCutActionTable)
{
if (Input.GetKey(key))
if (!Input.GetKey(key1.Key))
continue;
foreach (var key2 in key1.Value)
{
if (shortCutActionTable.TryGetValue(key, out var kk))
if (key2.Key != KeyCode.None && !Input.GetKey(key2.Key))
continue;
foreach (var key3 in key2.Value)
{
foreach (var k in kk)
if (Input.GetKeyDown(key3.Key))
{
if (Input.GetKeyDown(k.Key))
{
k.Value?.Invoke();
}
key3.Value?.Invoke();
}
}
}
}
updateLoop?.Invoke();
if (Input.GetKeyDown(KeyCode.L))
{
ManagerHub.instance.Get<UserInputHandlerManager>().SaveHandlerStack();
}
if(Input.GetKeyDown(KeyCode.K))
{
ManagerHub.instance.Get<UserInputHandlerManager>().LoadHandlerStack();
}
}
public static string GetId(Action action)
{
var methods = typeof(UserInputManager).GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
foreach (var method in methods)
{
if (method.ReturnType == typeof(void) && method.GetParameters().Length == 0)
{
var del = (Action)Delegate.CreateDelegate(typeof(Action), method);
if (del == action)
return method.Name;
}
}
return null;
}
//private void LoadHandlerStack(string json)
//{
// var data = JsonConvert.DeserializeObject<HandlerStackData>(json);
// foreach (var preset in data.handlers)
// {
// RemapTable(preset.getKeyActions, getKeyActionTable);
// RemapTable(preset.downKeyActions, downKeyActionTable);
// RemapTable(preset.upKeyActions, upKeyActionTable);
// foreach (var entry in preset.shortcutActions)
// {
// var actionId = entry.actionId;
// foreach (var key1 in shortCutActionTable.Keys.ToList())
// {
// foreach (var key2 in shortCutActionTable[key1].Keys.ToList())
// {
// foreach (var key3 in shortCutActionTable[key1][key2].Keys.ToList())
// {
// var action = shortCutActionTable[key1][key2][key3];
// if (action.Method.Name == actionId)
// {
// var newKey1 = ParseKeyCode(entry.key1);
// var newKey2 = ParseKeyCode(entry.key2);
// var newKey3 = ParseKeyCode(entry.key3);
// shortCutActionTable[key1][key2].Remove(key3);
// if (shortCutActionTable[key1][key2].Count == 0)
// shortCutActionTable[key1].Remove(key2);
// if (shortCutActionTable[key1].Count == 0)
// shortCutActionTable.Remove(key1);
// if (!shortCutActionTable.ContainsKey(newKey1))
// shortCutActionTable[newKey1] = new();
// if (!shortCutActionTable[newKey1].ContainsKey(newKey2))
// shortCutActionTable[newKey1][newKey2] = new();
// shortCutActionTable[newKey1][newKey2][newKey3] = action;
// }
// }
// }
// }
// }
// }
//}
//private void RemapTable(List<KeyActionEntry> entries, Dictionary<KeyCode, Action> table)
//{
// foreach (var entry in entries)
// {
// var newKey = ParseKeyCode(entry.key);
// var actionId = entry.actionId;
// Debug.Log("newKey " + newKey);
// foreach (var kvp in table.ToList())
// {
// if (kvp.Value.Method.Name == actionId && kvp.Key != newKey)
// {
// table.Remove(kvp.Key);
// table[newKey] = kvp.Value;
// Debug.Log("kev.Value " + kvp.Value.Method.Name);
// break;
// }
// }
// }
//}
KeyCode ParseKeyCode(string name)
{
return (KeyCode)Enum.Parse(typeof(KeyCode), name);
}
private void GetAction(string nmae)
{
}
}
[Serializable]
public class KeyActionEntry
{
public string key;
public string actionId;
}
[Serializable]
public class ShortcutEntry
{
public string key1;
public string key2;
public string key3;
public string actionId;
}
[Serializable]
public class HandlerPreset
{
public string id;
public string updateLoopId;
public List<KeyActionEntry> getKeyActions = new();
public List<KeyActionEntry> downKeyActions = new();
public List<KeyActionEntry> upKeyActions = new();
public List<ShortcutEntry> shortcutActions = new();
}
[Serializable]
public class HandlerStackData
{
public List<HandlerPreset> handlers = new();
}
}

View File

@@ -1,4 +1,5 @@
using UnityEngine;
using XED.Command;
using XED.Manage;
using XED.UI;
using XED.Util;
@@ -55,6 +56,10 @@ namespace XED
var linkDataUIManager = GameObject.FindAnyObjectByType<LinkDataUIManager>();
linkDataUIManager.onUISelected += panel_assetedit.SetAssetData;
//var userInputManager = FindAnyObjectByType<UserInputManager>();
//userInputManager.onChangeShortcutKey += EventConnector.instance.GetDefaultInputHandler;
//userInputManager.onChangeShortcutKey += CommandInvoker.instance.GetInputHandler;
}
void SetPanelAsLastSibling(UIBase panel)

View File

@@ -0,0 +1,54 @@
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using XRLib.UI;
namespace XED.UI
{
public class Panel_ShortcutKeySetting : PanelBase
{
public TMP_InputField InputField_MoveGizmo;
public TMP_InputField InputField_RotateGizmo;
public TMP_InputField InputField_ScaleGizmo;
public TMP_InputField InputField_ResetGizmo;
public TMP_InputField InputField_VertexSnap;
public TMP_InputField InputField_Undo;
public TMP_InputField InputField_Redo;
//public Button Button_Confirm;
public override void AfterAwake()
{
//InputField_MoveGizmo.onEndEdit.AddListener((text) => OnInputEndEdit(text, InputField_MoveGizmo));
//InputField_RotateGizmo.onEndEdit.AddListener((text) => OnInputEndEdit(text, InputField_RotateGizmo));
//InputField_ScaleGizmo.onEndEdit.AddListener((text) => OnInputEndEdit(text, InputField_ScaleGizmo));
//InputField_ResetGizmo.onEndEdit.AddListener((text) => OnInputEndEdit(text, InputField_ResetGizmo));
//InputField_VertexSnap.onEndEdit.AddListener((text) => OnInputEndEdit(text, InputField_VertexSnap));
//InputField_Undo.onEndEdit.AddListener((text) => OnInputEndEdit(text, InputField_Undo));
//InputField_Redo.onEndEdit.AddListener((text) => OnInputEndEdit(text, InputField_Redo));
//Button_Confirm.onClick.AddListener(OnClickConfirm);
}
private void OnInputEndEdit(string text, TMP_InputField inputField)
{
var keys = text.ToUpper()
.Where(char.IsLetterOrDigit)
.Distinct()
.Take(3)
.ToArray();
string formatted = string.Join(" + ", keys);
inputField.text = string.Empty;
inputField.placeholder.GetComponent<TMP_Text>().text = formatted;
}
private void OnClickConfirm()
{
}
}
}

View File

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