diff --git a/Assets/UniGLTF/Editor/MeshUtility/MeshUtilityDialog.cs b/Assets/UniGLTF/Editor/MeshUtility/MeshUtilityDialog.cs index c2feca8ff..65bfb6dc5 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/MeshUtilityDialog.cs +++ b/Assets/UniGLTF/Editor/MeshUtility/MeshUtilityDialog.cs @@ -240,7 +240,7 @@ namespace UniGLTF.MeshUtility Mesh WriteAndReload(Mesh src, string assetPath) { - Debug.LogFormat("CreateAsset: {0}", assetPath); + UniGLTFLogger.Log($"CreateAsset: {assetPath}"); AssetDatabase.CreateAsset(src, assetPath); var unityPath = UnityPath.FromUnityPath(assetPath); unityPath.ImportAsset(); @@ -278,7 +278,7 @@ namespace UniGLTF.MeshUtility protected virtual string WritePrefab(string assetFolder, GameObject instance) { var prefabPath = $"{assetFolder}/Integrated.prefab"; - Debug.Log(prefabPath); + UniGLTFLogger.Log(prefabPath); PrefabUtility.SaveAsPrefabAsset(instance, prefabPath, out bool success); if (!success) { diff --git a/Assets/UniGLTF/Editor/MeshUtility/PrefabContext.cs b/Assets/UniGLTF/Editor/MeshUtility/PrefabContext.cs index df80d3f3b..4e3a841bd 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/PrefabContext.cs +++ b/Assets/UniGLTF/Editor/MeshUtility/PrefabContext.cs @@ -47,7 +47,6 @@ namespace UniGLTF.MeshUtility if (prefab != null) { folder = AssetDatabase.GetAssetPath(prefab); - // Debug.Log(folder); } // 新規で作成されるアセットはすべてこのフォルダの中に作る。上書きチェックはしない diff --git a/Assets/UniGLTF/Editor/MeshUtility/TabBoneMeshRemover.cs b/Assets/UniGLTF/Editor/MeshUtility/TabBoneMeshRemover.cs index ac06f7747..1dd1543b9 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/TabBoneMeshRemover.cs +++ b/Assets/UniGLTF/Editor/MeshUtility/TabBoneMeshRemover.cs @@ -76,7 +76,7 @@ namespace UniGLTF.MeshUtility ASSET_SUFFIX ); } - Debug.LogFormat("CreateAsset: {0}", assetPath); + UniGLTFLogger.Log($"CreateAsset: {assetPath}"); AssetDatabase.CreateAsset(erased.sharedMesh, assetPath); // destroy BoneMeshEraser in the source diff --git a/Assets/UniGLTF/Editor/MeshUtility/TabMeshSeparator.cs b/Assets/UniGLTF/Editor/MeshUtility/TabMeshSeparator.cs index 992681a57..84cdea27a 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/TabMeshSeparator.cs +++ b/Assets/UniGLTF/Editor/MeshUtility/TabMeshSeparator.cs @@ -77,7 +77,7 @@ namespace UniGLTF.MeshUtility { // save mesh as asset var assetPath = string.Format("{0}{1}", Path.GetFileNameWithoutExtension(mesh.name), ASSET_SUFFIX); - Debug.Log(assetPath); + UniGLTFLogger.Log(assetPath); if (!string.IsNullOrEmpty((AssetDatabase.GetAssetPath(mesh)))) { var directory = Path.GetDirectoryName(AssetDatabase.GetAssetPath(mesh)).Replace("\\", "/"); @@ -87,7 +87,7 @@ namespace UniGLTF.MeshUtility { assetPath = string.Format("Assets/{0}{1}", Path.GetFileNameWithoutExtension(mesh.name) + "_" + blendShapeLabel.ToString(), ASSET_SUFFIX); } - Debug.LogFormat("CreateAsset: {0}", assetPath); + UniGLTFLogger.Log($"CreateAsset: {assetPath}"); AssetDatabase.CreateAsset(newMesh, assetPath); } @@ -266,7 +266,7 @@ namespace UniGLTF.MeshUtility if (mesh.vertexCount > ushort.MaxValue) { #if UNITY_2017_3_OR_NEWER - Debug.LogFormat("exceed 65535 vertices: {0}", mesh.vertexCount); + UniGLTFLogger.Log($"exceed 65535 vertices: {mesh.vertexCount}"); newMesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; #else throw new NotImplementedException(String.Format("exceed 65535 vertices: {0}", integrator.Positions.Count.ToString())); diff --git a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogState.cs b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogState.cs index dfced70da..e280d9b59 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogState.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogState.cs @@ -59,10 +59,7 @@ namespace UniGLTF } if (m_root.IsPrefab) { - if (Symbols.VRM_DEVELOP) - { - Debug.Log($"PrefabUtility.UnloadPrefabContents({m_root.GameObject})"); - } + UniGLTFLogger.Log($"PrefabUtility.UnloadPrefabContents({m_root.GameObject})"); PrefabUtility.UnloadPrefabContents(m_root.GameObject); } m_root = (value, isPrefab); diff --git a/Assets/UniGLTF/Editor/UniGLTF/Gizmo/BoneSelector.cs b/Assets/UniGLTF/Editor/UniGLTF/Gizmo/BoneSelector.cs index 36d02e653..a98254799 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/Gizmo/BoneSelector.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/Gizmo/BoneSelector.cs @@ -119,7 +119,6 @@ namespace UniGLTF } var min = _hitBones.Aggregate((result, next) => result.Value < next.Value ? result : next); - // Debug.Log("Hit!! = " + min.Key.HeadBone); info = min.Key; return info.HeadObject; } diff --git a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporterBase.cs b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporterBase.cs index 2da25c315..d6215598d 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporterBase.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporterBase.cs @@ -57,10 +57,7 @@ namespace UniGLTF /// protected static void Import(ScriptedImporter scriptedImporter, AssetImportContext context, Axes reverseAxis, RenderPipelineTypes renderPipeline) { - if (Symbols.VRM_DEVELOP) - { - Debug.Log("OnImportAsset to " + scriptedImporter.assetPath); - } + UniGLTFLogger.Log("OnImportAsset to " + scriptedImporter.assetPath); // // Import(create unity objects) diff --git a/Assets/UniGLTF/Editor/UniGLTF/UniGLTFPreference.cs b/Assets/UniGLTF/Editor/UniGLTF/UniGLTFPreference.cs index 2d03c7085..d27af7aae 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/UniGLTFPreference.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/UniGLTFPreference.cs @@ -23,7 +23,7 @@ namespace UniGLTF { if (glb.m_reverseAxis == ScriptedImporterAxes.Default) { - Debug.Log($"[reimport] {assetPath}"); + UniGLTFLogger.Log($"[reimport] {assetPath}"); yield return assetPath; } } @@ -31,7 +31,7 @@ namespace UniGLTF { if (gltf.m_reverseAxis == ScriptedImporterAxes.Default) { - Debug.Log($"[reimport] {assetPath}"); + UniGLTFLogger.Log($"[reimport] {assetPath}"); yield return assetPath; } } diff --git a/Assets/UniGLTF/Editor/UniHumanoid/BoneMappingEditor.cs b/Assets/UniGLTF/Editor/UniHumanoid/BoneMappingEditor.cs index d94a21aa7..bdd6f444d 100644 --- a/Assets/UniGLTF/Editor/UniHumanoid/BoneMappingEditor.cs +++ b/Assets/UniGLTF/Editor/UniHumanoid/BoneMappingEditor.cs @@ -117,7 +117,7 @@ animator.GetBoneTransform(x.Head), animator.GetBoneTransform(x.Tail))) AssetDatabase.CreateAsset(description, assetPath); // overwrite AssetDatabase.AddObjectToAsset(avatar, assetPath); - Debug.LogFormat("Create avatar {0}", path); + UniGLTF.UniGLTFLogger.Log($"Create avatar {path}"); AssetDatabase.ImportAsset(assetPath); Selection.activeObject = avatar; } diff --git a/Assets/UniGLTF/Editor/UniHumanoid/HumanoidEditor.cs b/Assets/UniGLTF/Editor/UniHumanoid/HumanoidEditor.cs index e1191d6d4..c0a2df396 100644 --- a/Assets/UniGLTF/Editor/UniHumanoid/HumanoidEditor.cs +++ b/Assets/UniGLTF/Editor/UniHumanoid/HumanoidEditor.cs @@ -394,7 +394,7 @@ namespace UniHumanoid if (avatar != null) { avatar.name = "avatar"; - Debug.LogFormat("Create avatar {0}", unityPath); + UniGLTF.UniGLTFLogger.Log($"Create avatar {unityPath}"); AssetDatabase.CreateAsset(avatar, unityPath); AssetDatabase.ImportAsset(unityPath); diff --git a/Assets/UniGLTF/Editor/UniHumanoid/MuscleInspectorEditor.cs b/Assets/UniGLTF/Editor/UniHumanoid/MuscleInspectorEditor.cs index c48010c6b..609886c91 100644 --- a/Assets/UniGLTF/Editor/UniHumanoid/MuscleInspectorEditor.cs +++ b/Assets/UniGLTF/Editor/UniHumanoid/MuscleInspectorEditor.cs @@ -319,7 +319,7 @@ namespace UniHumanoid && animator.avatar.isHuman ) { - Debug.LogFormat("MuscleInspectorEditor.OnEnable"); + UniGLTF.UniGLTFLogger.Log("MuscleInspectorEditor.OnEnable"); m_handler = new HumanPoseHandler(animator.avatar, animator.transform); m_TreeView = new BoneTreeView(new TreeViewState(), GetHeaderState(), m_handler); diff --git a/Assets/UniGLTF/Editor/UniHumanoid/UniHumanoid.Editor.asmdef b/Assets/UniGLTF/Editor/UniHumanoid/UniHumanoid.Editor.asmdef index 01e781359..3611b881a 100644 --- a/Assets/UniGLTF/Editor/UniHumanoid/UniHumanoid.Editor.asmdef +++ b/Assets/UniGLTF/Editor/UniHumanoid/UniHumanoid.Editor.asmdef @@ -1,8 +1,10 @@ { "name": "UniHumanoid.Editor", + "rootNamespace": "", "references": [ "GUID:05dd262a0c0a2f841b8252c8c3815582", - "GUID:b7aa47b240b57de44a4b2021c143c9bf" + "GUID:b7aa47b240b57de44a4b2021c143c9bf", + "GUID:1cd941934d098654fa21a13f28346412" ], "includePlatforms": [ "Editor" diff --git a/Assets/UniGLTF/Editor/UniHumanoid/bvhAssetPostprocessor.cs b/Assets/UniGLTF/Editor/UniHumanoid/bvhAssetPostprocessor.cs index 4f08f26a6..0ca4ca2d8 100644 --- a/Assets/UniGLTF/Editor/UniHumanoid/bvhAssetPostprocessor.cs +++ b/Assets/UniGLTF/Editor/UniHumanoid/bvhAssetPostprocessor.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using UniGLTF; using UnityEditor; using UnityEngine; @@ -21,14 +22,14 @@ namespace UniHumanoid { if (IsStreamingAsset(path)) { - Debug.LogFormat("Skip StreamingAssets: {0}", path); + UniGLTFLogger.Log($"Skip StreamingAssets: {path}"); continue; } var ext = Path.GetExtension(path).ToLower(); if (ext == ".bvh") { - Debug.LogFormat("ImportBvh: {0}", path); + UniGLTFLogger.Log($"ImportBvh: {path}"); var context = new BvhImporterContext(); try { @@ -37,7 +38,7 @@ namespace UniHumanoid context.SaveAsAsset(); context.Destroy(false); } - catch(Exception ex) + catch (Exception ex) { Debug.LogError(ex); context.Destroy(true); diff --git a/Assets/UniGLTF/Runtime/MeshUtility/MeshExclude.cs b/Assets/UniGLTF/Runtime/MeshUtility/MeshExclude.cs index 7361e86f5..f11b0f2e2 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/MeshExclude.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/MeshExclude.cs @@ -27,7 +27,7 @@ namespace UniGLTF.MeshUtility } if (_excludes.Contains(smr.sharedMesh)) { - Debug.LogFormat("{0} has excluded", smr); + UniGLTFLogger.Log($"{smr} has excluded"); return true; } return false; @@ -50,10 +50,10 @@ namespace UniGLTF.MeshUtility } if (_excludes.Contains(filter.sharedMesh)) { - Debug.LogFormat("{0} has excluded", mr); + UniGLTFLogger.Log($"{mr} has excluded"); return true; } return false; } } -} +} \ No newline at end of file diff --git a/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrator.cs b/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrator.cs index b1db1d5dc..dd2f29a47 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrator.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrator.cs @@ -63,7 +63,6 @@ namespace UniGLTF.MeshUtility { foreach (var x in BlendShapes) { - //Debug.LogFormat("AddBlendShapeFrame: {0}", kv.Key); mesh.AddBlendShapeFrame(x.Name, 100.0f, x.Positions.ToArray(), x.Normals.ToArray(), @@ -169,7 +168,6 @@ namespace UniGLTF.MeshUtility { if (renderer == null) { - // Debug.LogWarningFormat("{0} was destroyed", renderer); return; } @@ -331,7 +329,7 @@ namespace UniGLTF.MeshUtility mesh.name = name; if (Positions.Count > ushort.MaxValue) { - Debug.LogFormat("exceed 65535 vertices: {0}", Positions.Count); + UniGLTFLogger.Log($"exceed 65535 vertices: {Positions.Count}"); mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; } mesh.vertices = Positions.ToArray(); diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshData.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshData.cs index b96f05c9f..bb1cf57a9 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshData.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshData.cs @@ -267,7 +267,6 @@ namespace UniGLTF var count = maxIndex + 1; if (list.Count > count) { - // Debug.LogWarning($"remove {count} to {list.Count}"); list.RemoveRange(count, list.Count - count); } } diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshUploader.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshUploader.cs index 9fefcc477..a97dc0665 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshUploader.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshUploader.cs @@ -76,7 +76,6 @@ namespace UniGLTF } else { - // Debug.LogFormat("empty blendshape: {0}.{1}", mesh.name, blendShape.Name); // add empty blend shape for keep blend shape index mesh.AddBlendShapeFrame(blendShape.Name, FrameWeight, emptyVertices, @@ -123,7 +122,7 @@ namespace UniGLTF { Mesh = mesh, Materials = data.MaterialIndices.Select(materialFromIndex).ToArray(), - ShouldSetRendererNodeAsBone = data.ShouldSetRendererNodeAsBone, + ShouldSetRendererNodeAsBone = data.ShouldSetRendererNodeAsBone, }; await awaitCaller.NextFrame(); diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs index ce3d4e5aa..a6a0fb937 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs @@ -104,7 +104,6 @@ namespace UniGLTF { // empty mesh.name = "mesh_" + Guid.NewGuid().ToString("N"); - // Debug.LogWarning($"mesh.name: => {mesh.name}"); used.Add(mesh.name); } else @@ -114,7 +113,6 @@ namespace UniGLTF { // rename var uname = lower + "_" + Guid.NewGuid().ToString("N"); - // Debug.LogWarning($"mesh.name: {lower} => {uname}"); mesh.name = uname; lower = uname; } diff --git a/Assets/UniGLTF/Runtime/UniHumanoid/IO/BvhImporterContext.cs b/Assets/UniGLTF/Runtime/UniHumanoid/IO/BvhImporterContext.cs index f50f4f577..423496eb5 100644 --- a/Assets/UniGLTF/Runtime/UniHumanoid/IO/BvhImporterContext.cs +++ b/Assets/UniGLTF/Runtime/UniHumanoid/IO/BvhImporterContext.cs @@ -211,7 +211,7 @@ namespace UniHumanoid } // Create or update Main Asset - Debug.LogFormat("create prefab: {0}", path); + UniGLTF.UniGLTFLogger.Log($"create prefab: {path}"); PrefabUtility.SaveAsPrefabAssetAndConnect(Root, path, InteractionMode.AutomatedAction); AssetDatabase.ImportAsset(path); diff --git a/Assets/UniGLTF/Runtime/UniJSON/ConcreteCast.cs b/Assets/UniGLTF/Runtime/UniJSON/ConcreteCast.cs index eb06243d7..19141433e 100644 --- a/Assets/UniGLTF/Runtime/UniJSON/ConcreteCast.cs +++ b/Assets/UniGLTF/Runtime/UniJSON/ConcreteCast.cs @@ -20,7 +20,7 @@ namespace UniJSON public static MethodInfo GetMethod(Type src, Type dst) { var name = GetMethodName(src, dst); - var mi = typeof(ConcreteCast).GetMethod(name, + var mi = typeof(ConcreteCast).GetMethod(name, BindingFlags.Static | BindingFlags.Public); return mi; } @@ -74,7 +74,7 @@ namespace UniJSON { } var path = Application.dataPath + SOURCE; - Debug.LogFormat("{0}", path); + UniGLTF.UniGLTFLogger.Log($"{path}"); File.WriteAllText(path, s.ToString().Replace("\r\n", "\n"), new UTF8Encoding(false)); AssetDatabase.ImportAsset("Assets" + SOURCE); } diff --git a/Assets/UniGLTF/Runtime/Utils/UniGLTFLogger.cs b/Assets/UniGLTF/Runtime/Utils/UniGLTFLogger.cs new file mode 100644 index 000000000..594636d4a --- /dev/null +++ b/Assets/UniGLTF/Runtime/Utils/UniGLTFLogger.cs @@ -0,0 +1,58 @@ +using UnityEngine; + +namespace UniGLTF +{ + public static class UniGLTFLogger + { + class DefaultUnityLogger : ILogHandler + { + public void LogException(System.Exception exception, UnityEngine.Object context) + { + Debug.LogException(exception, context); + } + + public void LogFormat(LogType logType, UnityEngine.Object context, string format, params object[] args) + { + switch (logType) + { + case LogType.Error: + Debug.LogError(string.Format(format, args), context); + break; + case LogType.Assert: + Debug.LogAssertion(string.Format(format, args), context); + break; + case LogType.Warning: + Debug.LogWarning(string.Format(format, args), context); + break; + case LogType.Log: + Debug.Log(string.Format(format, args), context); + break; + case LogType.Exception: + // where exception ? + Debug.LogError(string.Format(format, args), context); + break; + default: + throw new System.NotImplementedException(); + } + } + } + + static ILogHandler s_logger = new DefaultUnityLogger(); + + public static void SetLogger(ILogHandler logger) + { + if (logger != null) + { + s_logger = logger; + } + else + { + s_logger = new DefaultUnityLogger(); + } + } + + [System.Diagnostics.Conditional("VRM_DEVELOP")] + [HideInCallstack] + public static void Log(string msg, UnityEngine.Object context = null) => s_logger.LogFormat(LogType.Log, context, msg); + } +} \ No newline at end of file diff --git a/Assets/VRM/Editor/Format/VRMAssetWriter.cs.meta b/Assets/UniGLTF/Runtime/Utils/UniGLTFLogger.cs.meta similarity index 69% rename from Assets/VRM/Editor/Format/VRMAssetWriter.cs.meta rename to Assets/UniGLTF/Runtime/Utils/UniGLTFLogger.cs.meta index 264ff80ec..bf104f312 100644 --- a/Assets/VRM/Editor/Format/VRMAssetWriter.cs.meta +++ b/Assets/UniGLTF/Runtime/Utils/UniGLTFLogger.cs.meta @@ -1,8 +1,7 @@ fileFormatVersion: 2 -guid: 8b409aa5d363b9948995cc00f7f1a0d0 -timeCreated: 1520241647 -licenseType: Free +guid: b011202d2621ae44fba62d201fb60448 MonoImporter: + externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 diff --git a/Assets/VRM/Editor/BlendShape/PreviewEditor.cs b/Assets/VRM/Editor/BlendShape/PreviewEditor.cs index 6a27374ff..a84b9ecd2 100644 --- a/Assets/VRM/Editor/BlendShape/PreviewEditor.cs +++ b/Assets/VRM/Editor/BlendShape/PreviewEditor.cs @@ -50,12 +50,10 @@ namespace VRM { if (m_prefab == value) return; - //Debug.LogFormat("Prefab = {0}", value); m_prefab = value; if (m_scene != null) { - //Debug.LogFormat("OnDestroy"); GameObject.DestroyImmediate(m_scene.gameObject); m_scene = null; } @@ -112,7 +110,6 @@ namespace VRM { if (m_scene != null) { - //Debug.LogFormat("OnDestroy"); m_scene.Clean(); GameObject.DestroyImmediate(m_scene.gameObject); m_scene = null; @@ -219,7 +216,6 @@ namespace VRM break; case EventType.ScrollWheel: - //Debug.LogFormat("wheel: {0}", current.delta); if (r.Contains(e.mousePosition)) { if (e.delta.y > 0) @@ -237,7 +233,6 @@ namespace VRM } //return scrollPosition; } - //Debug.LogFormat("{0}", previewDir); if (Event.current.type != EventType.Repaint) { diff --git a/Assets/VRM/Editor/Format/VRMAssetWriter.cs b/Assets/VRM/Editor/Format/VRMAssetWriter.cs deleted file mode 100644 index c1a359a0f..000000000 --- a/Assets/VRM/Editor/Format/VRMAssetWriter.cs +++ /dev/null @@ -1,214 +0,0 @@ -#if false -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using UniGLTF; -using UnityEditor; -using UnityEngine; - - -namespace VRM -{ - public static class VRMAssetWriter - { - interface ISubAssetWriter - { - void WriteIfHas(GameObject go); - } - - class SubAssetWriter: ISubAssetWriter where T : UnityEngine.Object - { - HashSet m_set = new HashSet(); - - String m_assetPath; - public delegate IEnumerable GetterFunc(GameObject go); - GetterFunc m_getter; - public SubAssetWriter(string assetPath, GetterFunc getter) - { - m_assetPath = assetPath; - m_getter = getter; - } - - public void WriteIfHas(GameObject go) - { - foreach(var o in m_getter(go)) - { - if (!m_set.Contains(o)) - { - AssetDatabase.AddObjectToAsset(o, m_assetPath); - m_set.Add(o); - } - } - } - } - - static IEnumerable GetMeshs(GameObject go) - { - var skinnedMesh = go.GetComponent(); - if (skinnedMesh != null) - { - yield return skinnedMesh.sharedMesh; - } - - var filter = go.GetComponent(); - if (filter != null) - { - yield return filter.sharedMesh; - } - } - - static IEnumerable GetMaterials(GameObject go) - { - var renderer = go.GetComponent(); - if (renderer != null) - { - return renderer.sharedMaterials; - } - else - { - return Enumerable.Empty(); - } - } - - static IEnumerable GetTextures(GameObject go) - { - foreach (var m in GetMaterials(go)) - { - foreach(Texture2D x in m.GetTextures()) - { - if (x != null) - { - yield return x; - } - } - } - } - - static IEnumerable GetAvatars(GameObject go) - { - var animator = go.GetComponent(); - if(animator!=null && animator.avatar != null) - { - yield return animator.avatar; - } - } - - static IEnumerable GetBlendShapeClips(GameObject go) - { - var proxy = go.GetComponent(); - if (proxy != null && proxy.BlendShapeAvatar != null) - { - return proxy.BlendShapeAvatar.Clips; - } - else - { - return Enumerable.Empty(); - } - } - - static IEnumerable GetBlendShapeAvatars(GameObject go) - { - var proxy = go.GetComponent(); - if (proxy != null && proxy.BlendShapeAvatar != null) - { - yield return proxy.BlendShapeAvatar; - } - } - - static IEnumerable GetAvatarDecriptions(GameObject go) - { - var humanoid = go.GetComponent(); - if (humanoid!=null && humanoid.Description != null) - { - yield return humanoid.Description; - } - else - { - var animator = go.GetComponent(); - if(animator!=null && animator.avatar) - { - var description= UniHumanoid.AvatarDescription.CreateFrom(animator.avatar); - if (description != null) - { - description.name = "AvatarDescription"; - yield return description; - } - } - } - } - - static IEnumerable GetThumbnails(GameObject go) - { - var meta = go.GetComponent(); - if (meta != null && meta.Thumbnail != null) - { - yield return meta.Thumbnail; - } - } - - static IEnumerable GetSubAssets(String prefabPath) - { - return AssetDatabase.LoadAllAssetsAtPath(prefabPath); - } - - public static void SaveAsPrefab(GameObject root, String path) - { - var prefabPath = path.ToUnityRelativePath(); - Debug.LogFormat("SaveAsPrefab: {0}", prefabPath); - - // clear subassets - if (File.Exists(prefabPath)) - { - //Debug.LogFormat("Exist: {0}", m_prefabPath); - - // clear subassets - foreach (var x in GetSubAssets(prefabPath)) - { - if (x is Transform - || x is GameObject) - { - continue; - } - GameObject.DestroyImmediate(x, true); - } - } - - // add subassets - var writers = new ISubAssetWriter[]{ - new SubAssetWriter(prefabPath, GetTextures), - new SubAssetWriter(prefabPath, GetMaterials), - new SubAssetWriter(prefabPath, GetMeshs), - new SubAssetWriter(prefabPath, GetAvatars), - // VRM Objects - new SubAssetWriter(prefabPath, GetBlendShapeClips), - new SubAssetWriter(prefabPath, GetBlendShapeAvatars), - new SubAssetWriter(prefabPath, GetAvatarDecriptions), - new SubAssetWriter(prefabPath, GetThumbnails), - }; - foreach (var x in root.transform.Traverse()) - { - foreach (var writer in writers) - { - writer.WriteIfHas(x.gameObject); - } - } - - /// - /// create prefab, after subasset AssetDatabase.AddObjectToAsset - /// - if (File.Exists(prefabPath)) - { - //Debug.LogFormat("ReplacePrefab: {0}", m_prefabPath); - var prefab = AssetDatabase.LoadAssetAtPath(prefabPath); - PrefabUtility.ReplacePrefab(root, prefab, ReplacePrefabOptions.ConnectToPrefab); - } - else - { - //Debug.LogFormat("CreatePrefab: {0}", m_prefabPath); - PrefabUtility.CreatePrefab(prefabPath, root, ReplacePrefabOptions.ConnectToPrefab); - } - } - } -} -#endif \ No newline at end of file diff --git a/Assets/VRM/Editor/Format/VRMEditorExporter.cs b/Assets/VRM/Editor/Format/VRMEditorExporter.cs index f727df52f..3a126c349 100644 --- a/Assets/VRM/Editor/Format/VRMEditorExporter.cs +++ b/Assets/VRM/Editor/Format/VRMEditorExporter.cs @@ -28,7 +28,7 @@ namespace VRM { foreach (var x in destroy) { - // x.name がエラーを引き起こす場合がある + // エラーを引き起こす場合がある // Debug.LogFormat("destroy: {0}", x.name); GameObject.DestroyImmediate(x); } diff --git a/Assets/VRM/Editor/Format/VRMEditorImporterContext.cs b/Assets/VRM/Editor/Format/VRMEditorImporterContext.cs index f2bf44317..17640e7f7 100644 --- a/Assets/VRM/Editor/Format/VRMEditorImporterContext.cs +++ b/Assets/VRM/Editor/Format/VRMEditorImporterContext.cs @@ -154,13 +154,13 @@ namespace VRM // Create or update Main Asset if (m_prefabPath.IsFileExists) { - Debug.LogFormat("replace prefab: {0}", m_prefabPath); + UniGLTFLogger.Log($"replace prefab: {m_prefabPath}"); var prefab = m_prefabPath.LoadAsset(); PrefabUtility.SaveAsPrefabAssetAndConnect(root, m_prefabPath.Value, InteractionMode.AutomatedAction); } else { - Debug.LogFormat("create prefab: {0}", m_prefabPath); + UniGLTFLogger.Log($"create prefab: {m_prefabPath}"); PrefabUtility.SaveAsPrefabAssetAndConnect(root, m_prefabPath.Value, InteractionMode.AutomatedAction); } diff --git a/Assets/VRM/Runtime/BlendShape/BlendShapeAvatar.cs b/Assets/VRM/Runtime/BlendShape/BlendShapeAvatar.cs index 743ef2001..ec990d466 100644 --- a/Assets/VRM/Runtime/BlendShape/BlendShapeAvatar.cs +++ b/Assets/VRM/Runtime/BlendShape/BlendShapeAvatar.cs @@ -38,14 +38,13 @@ namespace VRM Clips.Add(clip); } - Debug.LogFormat("{0}", clip.name); + UniGLTFLogger.Log(clip.name); } Clips = Clips.OrderBy(x => BlendShapeKey.CreateFromClip(x)).ToList(); } static public BlendShapeClip CreateBlendShapeClip(string path) { - //Debug.LogFormat("{0}", path); var clip = ScriptableObject.CreateInstance(); clip.BlendShapeName = Path.GetFileNameWithoutExtension(path); AssetDatabase.CreateAsset(clip, path); diff --git a/Assets/VRM/Runtime/BlendShape/PreviewSceneManager.cs b/Assets/VRM/Runtime/BlendShape/PreviewSceneManager.cs index e334356ac..cc6285288 100644 --- a/Assets/VRM/Runtime/BlendShape/PreviewSceneManager.cs +++ b/Assets/VRM/Runtime/BlendShape/PreviewSceneManager.cs @@ -34,10 +34,10 @@ namespace VRM { if (x.Prefab == prefab) { - Debug.LogFormat("find {0}", manager); + UniGLTFLogger.Log($"find {manager}"); return manager; } - Debug.LogFormat("destroy {0}", x); + UniGLTFLogger.Log($"destroy {x}"); GameObject.DestroyImmediate(x.gameObject); } @@ -82,7 +82,6 @@ namespace VRM private void Initialize(GameObject prefab) { - //Debug.LogFormat("[PreviewSceneManager.Initialize] {0}", prefab); Prefab = prefab; var materialNames = new List(); @@ -98,7 +97,6 @@ namespace VRM dst = new Material(src); map.Add(src, dst); - //Debug.LogFormat("add material {0}", src.name); materialNames.Add(src.name); m_materialMap.Add(src.name, MaterialItem.Create(dst)); } @@ -238,7 +236,6 @@ namespace VRM if (bake.MaterialValueBindings != null && m_materialMap != null) { // clear - //Debug.LogFormat("clear material"); foreach (var kv in m_materialMap) { foreach (var _kv in kv.Value.PropMap) diff --git a/Assets/VRM/Runtime/IO/MaterialIO/BuiltInRP/Export/BuiltInVrmExtensionMaterialPropertyExporter.cs b/Assets/VRM/Runtime/IO/MaterialIO/BuiltInRP/Export/BuiltInVrmExtensionMaterialPropertyExporter.cs index 02275ad85..84fb47e2a 100644 --- a/Assets/VRM/Runtime/IO/MaterialIO/BuiltInRP/Export/BuiltInVrmExtensionMaterialPropertyExporter.cs +++ b/Assets/VRM/Runtime/IO/MaterialIO/BuiltInRP/Export/BuiltInVrmExtensionMaterialPropertyExporter.cs @@ -86,7 +86,7 @@ namespace VRM } if (value == -1) { - Debug.LogFormat("not found {0}", texture.name); + Debug.LogWarningFormat("not found {0}", texture.name); } else { diff --git a/Assets/VRM10/Editor/Components/Expression/VRM10ExpressionEditor.cs b/Assets/VRM10/Editor/Components/Expression/VRM10ExpressionEditor.cs index 1f69bf86f..94b695ecb 100644 --- a/Assets/VRM10/Editor/Components/Expression/VRM10ExpressionEditor.cs +++ b/Assets/VRM10/Editor/Components/Expression/VRM10ExpressionEditor.cs @@ -37,7 +37,6 @@ namespace UniVRM10 { if (m_scene != null) { - //Debug.Log("Bake"); m_scene.Bake(CurrentExpression(), 1.0f); } } @@ -46,7 +45,6 @@ namespace UniVRM10 { if (m_scene != null) { - //Debug.LogFormat("OnDestroy"); m_scene.Clean(); GameObject.DestroyImmediate(m_scene.gameObject); m_scene = null; @@ -190,7 +188,6 @@ namespace UniVRM10 break; case EventType.ScrollWheel: - //Debug.LogFormat("wheel: {0}", current.delta); if (r.Contains(e.mousePosition)) { if (e.delta.y > 0) @@ -208,7 +205,6 @@ namespace UniVRM10 } //return scrollPosition; } - //Debug.LogFormat("{0}", previewDir); if (Event.current.type != EventType.Repaint) { diff --git a/Assets/VRM10/Editor/PackageResource.cs b/Assets/VRM10/Editor/PackageResource.cs index 5e9a187e2..593319022 100644 --- a/Assets/VRM10/Editor/PackageResource.cs +++ b/Assets/VRM10/Editor/PackageResource.cs @@ -30,14 +30,9 @@ namespace UniVRM10 var asset = AssetDatabase.LoadAssetAtPath(path); if (asset is null) { - // Debug.LogWarning($"fail to LoadAssetAtPath: {path}"); path = $"{PackageResource.PackageBase}/{relpath}"; asset = AssetDatabase.LoadAssetAtPath(path); } - // if (asset is null) - // { - // Debug.LogWarning($"fail to LoadAssetAtPath: {path}"); - // } return asset; } } diff --git a/Assets/VRM10/Runtime/Components/Expression/Preview/PreviewSceneManager.cs b/Assets/VRM10/Runtime/Components/Expression/Preview/PreviewSceneManager.cs index 418d0eebe..bf222816a 100644 --- a/Assets/VRM10/Runtime/Components/Expression/Preview/PreviewSceneManager.cs +++ b/Assets/VRM10/Runtime/Components/Expression/Preview/PreviewSceneManager.cs @@ -3,6 +3,7 @@ using System.Linq; using UnityEngine; using System; using VRMShaders; +using UniGLTF; namespace UniVRM10 @@ -36,10 +37,10 @@ namespace UniVRM10 { if (x.Prefab == prefab) { - Debug.LogFormat("find {0}", manager); + UniGLTFLogger.Log($"find {manager}"); return manager; } - Debug.LogFormat("destroy {0}", x); + UniGLTFLogger.Log($"destroy {x}"); GameObject.DestroyImmediate(x.gameObject); } @@ -87,7 +88,6 @@ namespace UniVRM10 { hasError = false; - //Debug.LogFormat("[PreviewSceneManager.Initialize] {0}", prefab); Prefab = prefab; var materialNames = new List(); @@ -116,7 +116,6 @@ namespace UniVRM10 m_materialMap.Add(src.name, previewMaterialItem); - //Debug.LogFormat("add material {0}", src.name); materialNames.Add(src.name); } return dst; @@ -279,7 +278,6 @@ namespace UniVRM10 // } var value = item.Material.GetVector(prop.Name); - //Debug.LogFormat("{0} => {1}", valueName, x.TargetValue); value += ((x.TargetValue - prop.DefaultValues) * weight); item.Material.SetColor(prop.Name, value); } diff --git a/Assets/VRM10/Runtime/Components/Expression/PreviewMaterialItem.cs b/Assets/VRM10/Runtime/Components/Expression/PreviewMaterialItem.cs index 460f14809..9e5a388f6 100644 --- a/Assets/VRM10/Runtime/Components/Expression/PreviewMaterialItem.cs +++ b/Assets/VRM10/Runtime/Components/Expression/PreviewMaterialItem.cs @@ -143,7 +143,6 @@ namespace UniVRM10 public void AddScaleOffset(Vector4 scaleOffset, float weight) { var value = Material.GetVector(UV_PROPERTY); - //Debug.LogFormat("{0} => {1}", valueName, x.TargetValue); value += (scaleOffset - DefaultUVScaleOffset) * weight; Material.SetColor(UV_PROPERTY, value); } diff --git a/Assets/VRM10/Runtime/StringExtensions.cs b/Assets/VRM10/Runtime/StringExtensions.cs index bf790040d..673ddd351 100644 --- a/Assets/VRM10/Runtime/StringExtensions.cs +++ b/Assets/VRM10/Runtime/StringExtensions.cs @@ -45,7 +45,6 @@ namespace UniVRM10 return path.Substring(UnityBasePath.Length + 1); } - //Debug.LogWarningFormat("{0} is starts with {1}", path, basePath); return path; }