mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-13 22:09:53 -05:00
Merge pull request #2362 from ousttrue/feature/univrm_logger
UniGLTFLogger を追加
This commit is contained in:
commit
c39e5e7d90
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ namespace UniGLTF.MeshUtility
|
|||
if (prefab != null)
|
||||
{
|
||||
folder = AssetDatabase.GetAssetPath(prefab);
|
||||
// Debug.Log(folder);
|
||||
}
|
||||
|
||||
// 新規で作成されるアセットはすべてこのフォルダの中に作る。上書きチェックはしない
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,10 +57,7 @@ namespace UniGLTF
|
|||
/// <param name="reverseAxis"></param>
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
{
|
||||
"name": "UniHumanoid.Editor",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:05dd262a0c0a2f841b8252c8c3815582",
|
||||
"GUID:b7aa47b240b57de44a4b2021c143c9bf"
|
||||
"GUID:b7aa47b240b57de44a4b2021c143c9bf",
|
||||
"GUID:1cd941934d098654fa21a13f28346412"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
58
Assets/UniGLTF/Runtime/Utils/UniGLTFLogger.cs
Normal file
58
Assets/UniGLTF/Runtime/Utils/UniGLTFLogger.cs
Normal file
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8b409aa5d363b9948995cc00f7f1a0d0
|
||||
timeCreated: 1520241647
|
||||
licenseType: Free
|
||||
guid: b011202d2621ae44fba62d201fb60448
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<T>: ISubAssetWriter where T : UnityEngine.Object
|
||||
{
|
||||
HashSet<T> m_set = new HashSet<T>();
|
||||
|
||||
String m_assetPath;
|
||||
public delegate IEnumerable<T> 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<Mesh> GetMeshs(GameObject go)
|
||||
{
|
||||
var skinnedMesh = go.GetComponent<SkinnedMeshRenderer>();
|
||||
if (skinnedMesh != null)
|
||||
{
|
||||
yield return skinnedMesh.sharedMesh;
|
||||
}
|
||||
|
||||
var filter = go.GetComponent<MeshFilter>();
|
||||
if (filter != null)
|
||||
{
|
||||
yield return filter.sharedMesh;
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<Material> GetMaterials(GameObject go)
|
||||
{
|
||||
var renderer = go.GetComponent<Renderer>();
|
||||
if (renderer != null)
|
||||
{
|
||||
return renderer.sharedMaterials;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Enumerable.Empty<Material>();
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<Texture2D> GetTextures(GameObject go)
|
||||
{
|
||||
foreach (var m in GetMaterials(go))
|
||||
{
|
||||
foreach(Texture2D x in m.GetTextures())
|
||||
{
|
||||
if (x != null)
|
||||
{
|
||||
yield return x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<Avatar> GetAvatars(GameObject go)
|
||||
{
|
||||
var animator = go.GetComponent<Animator>();
|
||||
if(animator!=null && animator.avatar != null)
|
||||
{
|
||||
yield return animator.avatar;
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<BlendShapeClip> GetBlendShapeClips(GameObject go)
|
||||
{
|
||||
var proxy = go.GetComponent<VRMBlendShapeProxy>();
|
||||
if (proxy != null && proxy.BlendShapeAvatar != null)
|
||||
{
|
||||
return proxy.BlendShapeAvatar.Clips;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Enumerable.Empty<BlendShapeClip>();
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<BlendShapeAvatar> GetBlendShapeAvatars(GameObject go)
|
||||
{
|
||||
var proxy = go.GetComponent<VRMBlendShapeProxy>();
|
||||
if (proxy != null && proxy.BlendShapeAvatar != null)
|
||||
{
|
||||
yield return proxy.BlendShapeAvatar;
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<UniHumanoid.AvatarDescription> GetAvatarDecriptions(GameObject go)
|
||||
{
|
||||
var humanoid = go.GetComponent<VRMHumanoidDescription>();
|
||||
if (humanoid!=null && humanoid.Description != null)
|
||||
{
|
||||
yield return humanoid.Description;
|
||||
}
|
||||
else
|
||||
{
|
||||
var animator = go.GetComponent<Animator>();
|
||||
if(animator!=null && animator.avatar)
|
||||
{
|
||||
var description= UniHumanoid.AvatarDescription.CreateFrom(animator.avatar);
|
||||
if (description != null)
|
||||
{
|
||||
description.name = "AvatarDescription";
|
||||
yield return description;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<Texture2D> GetThumbnails(GameObject go)
|
||||
{
|
||||
var meta = go.GetComponent<VRMMetaInformation>();
|
||||
if (meta != null && meta.Thumbnail != null)
|
||||
{
|
||||
yield return meta.Thumbnail;
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<UnityEngine.Object> 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<Texture2D>(prefabPath, GetTextures),
|
||||
new SubAssetWriter<Material>(prefabPath, GetMaterials),
|
||||
new SubAssetWriter<Mesh>(prefabPath, GetMeshs),
|
||||
new SubAssetWriter<Avatar>(prefabPath, GetAvatars),
|
||||
// VRM Objects
|
||||
new SubAssetWriter<BlendShapeClip>(prefabPath, GetBlendShapeClips),
|
||||
new SubAssetWriter<BlendShapeAvatar>(prefabPath, GetBlendShapeAvatars),
|
||||
new SubAssetWriter<UniHumanoid.AvatarDescription>(prefabPath, GetAvatarDecriptions),
|
||||
new SubAssetWriter<Texture2D>(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<GameObject>(prefabPath);
|
||||
PrefabUtility.ReplacePrefab(root, prefab, ReplacePrefabOptions.ConnectToPrefab);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.LogFormat("CreatePrefab: {0}", m_prefabPath);
|
||||
PrefabUtility.CreatePrefab(prefabPath, root, ReplacePrefabOptions.ConnectToPrefab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -28,7 +28,7 @@ namespace VRM
|
|||
{
|
||||
foreach (var x in destroy)
|
||||
{
|
||||
// x.name がエラーを引き起こす場合がある
|
||||
// エラーを引き起こす場合がある
|
||||
// Debug.LogFormat("destroy: {0}", x.name);
|
||||
GameObject.DestroyImmediate(x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<GameObject>();
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<BlendShapeClip>();
|
||||
clip.BlendShapeName = Path.GetFileNameWithoutExtension(path);
|
||||
AssetDatabase.CreateAsset(clip, path);
|
||||
|
|
|
|||
|
|
@ -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<string>();
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace VRM
|
|||
}
|
||||
if (value == -1)
|
||||
{
|
||||
Debug.LogFormat("not found {0}", texture.name);
|
||||
Debug.LogWarningFormat("not found {0}", texture.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,14 +30,9 @@ namespace UniVRM10
|
|||
var asset = AssetDatabase.LoadAssetAtPath<T>(path);
|
||||
if (asset is null)
|
||||
{
|
||||
// Debug.LogWarning($"fail to LoadAssetAtPath: {path}");
|
||||
path = $"{PackageResource.PackageBase}/{relpath}";
|
||||
asset = AssetDatabase.LoadAssetAtPath<T>(path);
|
||||
}
|
||||
// if (asset is null)
|
||||
// {
|
||||
// Debug.LogWarning($"fail to LoadAssetAtPath: {path}");
|
||||
// }
|
||||
return asset;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<string>();
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ namespace UniVRM10
|
|||
return path.Substring(UnityBasePath.Length + 1);
|
||||
}
|
||||
|
||||
//Debug.LogWarningFormat("{0} is starts with {1}", path, basePath);
|
||||
return path;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user