From 2cd4331c9922cd2c577b4c911f64df0ceaa41230 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 18 Aug 2021 17:56:04 +0900 Subject: [PATCH] namespace --- .../AnimationBridgeSample/AnimationBridge.cs | 2 +- .../CanvasManager.cs | 2 +- .../CanvasManager.cs.meta | 0 .../FirstPersonSample/FileDialogForWindows.cs | 118 ++++++++++++++++++ .../FileDialogForWindows.cs.meta | 12 ++ .../FirstPersonSample/VRMRuntimeLoader.cs | 2 +- .../FileDialogForWindows.cs | 118 ++++++++++++++++++ .../FileDialogForWindows.cs.meta | 12 ++ .../VRMRuntimeExporter.cs | 2 +- .../SimpleViewer/{Scripts => }/AIUEO.cs | 2 +- .../SimpleViewer/{Scripts => }/AIUEO.cs.meta | 0 .../{Scripts => }/FileDialogForWindows.cs | 2 +- .../FileDialogForWindows.cs.meta | 0 .../{Scripts => }/RokuroCamera.cs | 2 +- .../{Scripts => }/RokuroCamera.cs.meta | 0 Assets/VRM/Samples/SimpleViewer/Scripts.meta | 9 -- .../SimpleViewer/{Scripts => }/TargetMover.cs | 2 +- .../{Scripts => }/TargetMover.cs.meta | 0 .../SimpleViewer/{Scripts => }/ViewerUI.cs | 2 +- .../{Scripts => }/ViewerUI.cs.meta | 0 20 files changed, 269 insertions(+), 18 deletions(-) rename Assets/VRM/Samples/{RuntimeExporterSample => FirstPersonSample}/CanvasManager.cs (94%) rename Assets/VRM/Samples/{RuntimeExporterSample => FirstPersonSample}/CanvasManager.cs.meta (100%) create mode 100644 Assets/VRM/Samples/FirstPersonSample/FileDialogForWindows.cs create mode 100644 Assets/VRM/Samples/FirstPersonSample/FileDialogForWindows.cs.meta create mode 100644 Assets/VRM/Samples/RuntimeExporterSample/FileDialogForWindows.cs create mode 100644 Assets/VRM/Samples/RuntimeExporterSample/FileDialogForWindows.cs.meta rename Assets/VRM/Samples/SimpleViewer/{Scripts => }/AIUEO.cs (98%) rename Assets/VRM/Samples/SimpleViewer/{Scripts => }/AIUEO.cs.meta (100%) rename Assets/VRM/Samples/SimpleViewer/{Scripts => }/FileDialogForWindows.cs (99%) rename Assets/VRM/Samples/SimpleViewer/{Scripts => }/FileDialogForWindows.cs.meta (100%) rename Assets/VRM/Samples/SimpleViewer/{Scripts => }/RokuroCamera.cs (99%) rename Assets/VRM/Samples/SimpleViewer/{Scripts => }/RokuroCamera.cs.meta (100%) delete mode 100644 Assets/VRM/Samples/SimpleViewer/Scripts.meta rename Assets/VRM/Samples/SimpleViewer/{Scripts => }/TargetMover.cs (96%) rename Assets/VRM/Samples/SimpleViewer/{Scripts => }/TargetMover.cs.meta (100%) rename Assets/VRM/Samples/SimpleViewer/{Scripts => }/ViewerUI.cs (99%) rename Assets/VRM/Samples/SimpleViewer/{Scripts => }/ViewerUI.cs.meta (100%) diff --git a/Assets/VRM/Samples/AnimationBridgeSample/AnimationBridge.cs b/Assets/VRM/Samples/AnimationBridgeSample/AnimationBridge.cs index d45ab3062..5b8035f3b 100644 --- a/Assets/VRM/Samples/AnimationBridgeSample/AnimationBridge.cs +++ b/Assets/VRM/Samples/AnimationBridgeSample/AnimationBridge.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using UnityEngine; -namespace VRM.Samples +namespace VRM.AnimationBridgeSample { /// /// VRMからAnimatorを取り外してからアタッチしてください。 diff --git a/Assets/VRM/Samples/RuntimeExporterSample/CanvasManager.cs b/Assets/VRM/Samples/FirstPersonSample/CanvasManager.cs similarity index 94% rename from Assets/VRM/Samples/RuntimeExporterSample/CanvasManager.cs rename to Assets/VRM/Samples/FirstPersonSample/CanvasManager.cs index 7e288e1f3..6cf18248f 100644 --- a/Assets/VRM/Samples/RuntimeExporterSample/CanvasManager.cs +++ b/Assets/VRM/Samples/FirstPersonSample/CanvasManager.cs @@ -3,7 +3,7 @@ using UnityEngine; using UnityEngine.UI; -namespace VRM.Samples +namespace VRM.FirstPersonSample { public class CanvasManager : MonoBehaviour { diff --git a/Assets/VRM/Samples/RuntimeExporterSample/CanvasManager.cs.meta b/Assets/VRM/Samples/FirstPersonSample/CanvasManager.cs.meta similarity index 100% rename from Assets/VRM/Samples/RuntimeExporterSample/CanvasManager.cs.meta rename to Assets/VRM/Samples/FirstPersonSample/CanvasManager.cs.meta diff --git a/Assets/VRM/Samples/FirstPersonSample/FileDialogForWindows.cs b/Assets/VRM/Samples/FirstPersonSample/FileDialogForWindows.cs new file mode 100644 index 000000000..575b2f02f --- /dev/null +++ b/Assets/VRM/Samples/FirstPersonSample/FileDialogForWindows.cs @@ -0,0 +1,118 @@ +#if UNITY_STANDALONE_WIN +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.InteropServices; +#endif + + +namespace VRM.FirstPersonSample +{ + public static class FileDialogForWindows + { +#if UNITY_STANDALONE_WIN + #region GetOpenFileName + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public class OpenFileName + { + public int structSize = 0; + public IntPtr dlgOwner = IntPtr.Zero; + public IntPtr instance = IntPtr.Zero; + public String filter = null; + public String customFilter = null; + public int maxCustFilter = 0; + public int filterIndex = 0; + public String file = null; + public int maxFile = 0; + public String fileTitle = null; + public int maxFileTitle = 0; + public String initialDir = null; + public String title = null; + public int flags = 0; + public short fileOffset = 0; + public short fileExtension = 0; + public String defExt = null; + public IntPtr custData = IntPtr.Zero; + public IntPtr hook = IntPtr.Zero; + public String templateName = null; + public IntPtr reservedPtr = IntPtr.Zero; + public int reservedInt = 0; + public int flagsEx = 0; + } + + [DllImport("Comdlg32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)] + public static extern bool GetOpenFileName([In, Out] OpenFileName ofn); + /* + public static bool GetOpenFileName1([In, Out] OpenFileName ofn) + { + return GetOpenFileName(ofn); + } + */ + + [DllImport("Comdlg32.dll", SetLastError = true, CharSet = CharSet.Auto)] + private static extern bool GetSaveFileName([In, Out] OpenFileName ofn); + + static string Filter(params string[] filters) + { + return string.Join("\0", filters) + "\0"; + } + public static string FileDialog(string title, params string[] extensions) + { + OpenFileName ofn = new OpenFileName(); + ofn.structSize = Marshal.SizeOf(ofn); + + var filters = new List(); + filters.Add("All Files"); filters.Add("*.*"); + foreach(var ext in extensions) + { + filters.Add(ext); filters.Add("*" + ext); + } + ofn.filter = Filter(filters.ToArray()); + ofn.filterIndex = 2; + ofn.file = new string(new char[256]); + ofn.maxFile = ofn.file.Length; + ofn.fileTitle = new string(new char[64]); + ofn.maxFileTitle = ofn.fileTitle.Length; + ofn.initialDir = UnityEngine.Application.dataPath; + ofn.title = title; + //ofn.defExt = "PNG"; + ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;//OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR + if (!GetOpenFileName(ofn)) + { + return null; + } + + return ofn.file; + } + public static string SaveDialog(string title, string path) + { + var extension = Path.GetExtension(path); + OpenFileName ofn = new OpenFileName(); + ofn.structSize = Marshal.SizeOf(ofn); + ofn.filter = Filter("All Files", "*.*", extension, "*" + extension); + ofn.filterIndex = 2; + var chars = new char[256]; + var it = Path.GetFileName(path).GetEnumerator(); + for (int i = 0; i < chars.Length && it.MoveNext(); ++i) + { + chars[i] = it.Current; + } + ofn.file = new string(chars); + ofn.maxFile = ofn.file.Length; + ofn.fileTitle = new string(new char[64]); + ofn.maxFileTitle = ofn.fileTitle.Length; + ofn.initialDir = Path.GetDirectoryName(path); + ofn.title = title; + //ofn.defExt = "PNG"; + ofn.flags = 0x00000002 | 0x00000004; // OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; + if (!GetSaveFileName(ofn)) + { + return null; + } + + return ofn.file; + } + #endregion +#endif + } +} diff --git a/Assets/VRM/Samples/FirstPersonSample/FileDialogForWindows.cs.meta b/Assets/VRM/Samples/FirstPersonSample/FileDialogForWindows.cs.meta new file mode 100644 index 000000000..a2df32d3f --- /dev/null +++ b/Assets/VRM/Samples/FirstPersonSample/FileDialogForWindows.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 65d59ee778edf8142a3701fe8d9ddf4d +timeCreated: 1524038001 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/Samples/FirstPersonSample/VRMRuntimeLoader.cs b/Assets/VRM/Samples/FirstPersonSample/VRMRuntimeLoader.cs index 303c10611..b3bf99658 100644 --- a/Assets/VRM/Samples/FirstPersonSample/VRMRuntimeLoader.cs +++ b/Assets/VRM/Samples/FirstPersonSample/VRMRuntimeLoader.cs @@ -4,7 +4,7 @@ using UniGLTF; using UnityEngine; -namespace VRM.Samples +namespace VRM.FirstPersonSample { public class VRMRuntimeLoader : MonoBehaviour { diff --git a/Assets/VRM/Samples/RuntimeExporterSample/FileDialogForWindows.cs b/Assets/VRM/Samples/RuntimeExporterSample/FileDialogForWindows.cs new file mode 100644 index 000000000..a6f6be06b --- /dev/null +++ b/Assets/VRM/Samples/RuntimeExporterSample/FileDialogForWindows.cs @@ -0,0 +1,118 @@ +#if UNITY_STANDALONE_WIN +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.InteropServices; +#endif + + +namespace VRM.RuntimeExporterSample +{ + public static class FileDialogForWindows + { +#if UNITY_STANDALONE_WIN + #region GetOpenFileName + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public class OpenFileName + { + public int structSize = 0; + public IntPtr dlgOwner = IntPtr.Zero; + public IntPtr instance = IntPtr.Zero; + public String filter = null; + public String customFilter = null; + public int maxCustFilter = 0; + public int filterIndex = 0; + public String file = null; + public int maxFile = 0; + public String fileTitle = null; + public int maxFileTitle = 0; + public String initialDir = null; + public String title = null; + public int flags = 0; + public short fileOffset = 0; + public short fileExtension = 0; + public String defExt = null; + public IntPtr custData = IntPtr.Zero; + public IntPtr hook = IntPtr.Zero; + public String templateName = null; + public IntPtr reservedPtr = IntPtr.Zero; + public int reservedInt = 0; + public int flagsEx = 0; + } + + [DllImport("Comdlg32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)] + public static extern bool GetOpenFileName([In, Out] OpenFileName ofn); + /* + public static bool GetOpenFileName1([In, Out] OpenFileName ofn) + { + return GetOpenFileName(ofn); + } + */ + + [DllImport("Comdlg32.dll", SetLastError = true, CharSet = CharSet.Auto)] + private static extern bool GetSaveFileName([In, Out] OpenFileName ofn); + + static string Filter(params string[] filters) + { + return string.Join("\0", filters) + "\0"; + } + public static string FileDialog(string title, params string[] extensions) + { + OpenFileName ofn = new OpenFileName(); + ofn.structSize = Marshal.SizeOf(ofn); + + var filters = new List(); + filters.Add("All Files"); filters.Add("*.*"); + foreach(var ext in extensions) + { + filters.Add(ext); filters.Add("*" + ext); + } + ofn.filter = Filter(filters.ToArray()); + ofn.filterIndex = 2; + ofn.file = new string(new char[256]); + ofn.maxFile = ofn.file.Length; + ofn.fileTitle = new string(new char[64]); + ofn.maxFileTitle = ofn.fileTitle.Length; + ofn.initialDir = UnityEngine.Application.dataPath; + ofn.title = title; + //ofn.defExt = "PNG"; + ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;//OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR + if (!GetOpenFileName(ofn)) + { + return null; + } + + return ofn.file; + } + public static string SaveDialog(string title, string path) + { + var extension = Path.GetExtension(path); + OpenFileName ofn = new OpenFileName(); + ofn.structSize = Marshal.SizeOf(ofn); + ofn.filter = Filter("All Files", "*.*", extension, "*" + extension); + ofn.filterIndex = 2; + var chars = new char[256]; + var it = Path.GetFileName(path).GetEnumerator(); + for (int i = 0; i < chars.Length && it.MoveNext(); ++i) + { + chars[i] = it.Current; + } + ofn.file = new string(chars); + ofn.maxFile = ofn.file.Length; + ofn.fileTitle = new string(new char[64]); + ofn.maxFileTitle = ofn.fileTitle.Length; + ofn.initialDir = Path.GetDirectoryName(path); + ofn.title = title; + //ofn.defExt = "PNG"; + ofn.flags = 0x00000002 | 0x00000004; // OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; + if (!GetSaveFileName(ofn)) + { + return null; + } + + return ofn.file; + } + #endregion +#endif + } +} diff --git a/Assets/VRM/Samples/RuntimeExporterSample/FileDialogForWindows.cs.meta b/Assets/VRM/Samples/RuntimeExporterSample/FileDialogForWindows.cs.meta new file mode 100644 index 000000000..9ccb20bed --- /dev/null +++ b/Assets/VRM/Samples/RuntimeExporterSample/FileDialogForWindows.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8ff6db533f20357449eccbc5651a5cf8 +timeCreated: 1524038001 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/Samples/RuntimeExporterSample/VRMRuntimeExporter.cs b/Assets/VRM/Samples/RuntimeExporterSample/VRMRuntimeExporter.cs index 5c8d662ef..770536a65 100644 --- a/Assets/VRM/Samples/RuntimeExporterSample/VRMRuntimeExporter.cs +++ b/Assets/VRM/Samples/RuntimeExporterSample/VRMRuntimeExporter.cs @@ -7,7 +7,7 @@ using UnityEngine.UI; using VRM; using VRMShaders; -namespace VRM.Samples +namespace VRM.RuntimeExporterSample { public class VRMRuntimeExporter : MonoBehaviour diff --git a/Assets/VRM/Samples/SimpleViewer/Scripts/AIUEO.cs b/Assets/VRM/Samples/SimpleViewer/AIUEO.cs similarity index 98% rename from Assets/VRM/Samples/SimpleViewer/Scripts/AIUEO.cs rename to Assets/VRM/Samples/SimpleViewer/AIUEO.cs index a7a7e61b8..07581e399 100644 --- a/Assets/VRM/Samples/SimpleViewer/Scripts/AIUEO.cs +++ b/Assets/VRM/Samples/SimpleViewer/AIUEO.cs @@ -2,7 +2,7 @@ using UnityEngine; -namespace VRM.Samples +namespace VRM.SimpleViewer { public class AIUEO : MonoBehaviour { diff --git a/Assets/VRM/Samples/SimpleViewer/Scripts/AIUEO.cs.meta b/Assets/VRM/Samples/SimpleViewer/AIUEO.cs.meta similarity index 100% rename from Assets/VRM/Samples/SimpleViewer/Scripts/AIUEO.cs.meta rename to Assets/VRM/Samples/SimpleViewer/AIUEO.cs.meta diff --git a/Assets/VRM/Samples/SimpleViewer/Scripts/FileDialogForWindows.cs b/Assets/VRM/Samples/SimpleViewer/FileDialogForWindows.cs similarity index 99% rename from Assets/VRM/Samples/SimpleViewer/Scripts/FileDialogForWindows.cs rename to Assets/VRM/Samples/SimpleViewer/FileDialogForWindows.cs index de10f2d9c..2979219ae 100644 --- a/Assets/VRM/Samples/SimpleViewer/Scripts/FileDialogForWindows.cs +++ b/Assets/VRM/Samples/SimpleViewer/FileDialogForWindows.cs @@ -6,7 +6,7 @@ using System.Runtime.InteropServices; #endif -namespace VRM.Samples +namespace VRM.SimpleViewer { public static class FileDialogForWindows { diff --git a/Assets/VRM/Samples/SimpleViewer/Scripts/FileDialogForWindows.cs.meta b/Assets/VRM/Samples/SimpleViewer/FileDialogForWindows.cs.meta similarity index 100% rename from Assets/VRM/Samples/SimpleViewer/Scripts/FileDialogForWindows.cs.meta rename to Assets/VRM/Samples/SimpleViewer/FileDialogForWindows.cs.meta diff --git a/Assets/VRM/Samples/SimpleViewer/Scripts/RokuroCamera.cs b/Assets/VRM/Samples/SimpleViewer/RokuroCamera.cs similarity index 99% rename from Assets/VRM/Samples/SimpleViewer/Scripts/RokuroCamera.cs rename to Assets/VRM/Samples/SimpleViewer/RokuroCamera.cs index 74d1568bb..dff6e14b7 100644 --- a/Assets/VRM/Samples/SimpleViewer/Scripts/RokuroCamera.cs +++ b/Assets/VRM/Samples/SimpleViewer/RokuroCamera.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using UnityEngine; -namespace VRM.Samples +namespace VRM.SimpleViewer { public class RokuroCamera : MonoBehaviour { diff --git a/Assets/VRM/Samples/SimpleViewer/Scripts/RokuroCamera.cs.meta b/Assets/VRM/Samples/SimpleViewer/RokuroCamera.cs.meta similarity index 100% rename from Assets/VRM/Samples/SimpleViewer/Scripts/RokuroCamera.cs.meta rename to Assets/VRM/Samples/SimpleViewer/RokuroCamera.cs.meta diff --git a/Assets/VRM/Samples/SimpleViewer/Scripts.meta b/Assets/VRM/Samples/SimpleViewer/Scripts.meta deleted file mode 100644 index 797727f85..000000000 --- a/Assets/VRM/Samples/SimpleViewer/Scripts.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: d97e18dfaff15ed45908b0fca0f661ee -folderAsset: yes -timeCreated: 1524032882 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/Samples/SimpleViewer/Scripts/TargetMover.cs b/Assets/VRM/Samples/SimpleViewer/TargetMover.cs similarity index 96% rename from Assets/VRM/Samples/SimpleViewer/Scripts/TargetMover.cs rename to Assets/VRM/Samples/SimpleViewer/TargetMover.cs index 97a822328..9b6dc1bf7 100644 --- a/Assets/VRM/Samples/SimpleViewer/Scripts/TargetMover.cs +++ b/Assets/VRM/Samples/SimpleViewer/TargetMover.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using UnityEngine; -namespace VRM.Samples +namespace VRM.SimpleViewer { public class TargetMover : MonoBehaviour { diff --git a/Assets/VRM/Samples/SimpleViewer/Scripts/TargetMover.cs.meta b/Assets/VRM/Samples/SimpleViewer/TargetMover.cs.meta similarity index 100% rename from Assets/VRM/Samples/SimpleViewer/Scripts/TargetMover.cs.meta rename to Assets/VRM/Samples/SimpleViewer/TargetMover.cs.meta diff --git a/Assets/VRM/Samples/SimpleViewer/Scripts/ViewerUI.cs b/Assets/VRM/Samples/SimpleViewer/ViewerUI.cs similarity index 99% rename from Assets/VRM/Samples/SimpleViewer/Scripts/ViewerUI.cs rename to Assets/VRM/Samples/SimpleViewer/ViewerUI.cs index 91dc07138..4a6cbf777 100644 --- a/Assets/VRM/Samples/SimpleViewer/Scripts/ViewerUI.cs +++ b/Assets/VRM/Samples/SimpleViewer/ViewerUI.cs @@ -9,7 +9,7 @@ using UnityEngine.UI; using VRMShaders; -namespace VRM.Samples +namespace VRM.SimpleViewer { diff --git a/Assets/VRM/Samples/SimpleViewer/Scripts/ViewerUI.cs.meta b/Assets/VRM/Samples/SimpleViewer/ViewerUI.cs.meta similarity index 100% rename from Assets/VRM/Samples/SimpleViewer/Scripts/ViewerUI.cs.meta rename to Assets/VRM/Samples/SimpleViewer/ViewerUI.cs.meta