Merge branch 'master' of https://github.com/vrm-c/UniVRM into mtoonRenderFeatureFix

This commit is contained in:
Masataka SUMI
2025-02-16 02:41:58 +09:00
322 changed files with 35399 additions and 1840 deletions

117
.github/workflows/build-webgl.yml vendored Normal file
View File

@@ -0,0 +1,117 @@
name: WebGL to gh-page
on:
workflow_dispatch:
# push:
# branches:
# - workflow-webgl-wip
env:
UNITY_PROJECT_PATH: .
defaults:
run:
shell: bash
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: [self-hosted, Windows, X64, Unity]
timeout-minutes: 60
steps:
- id: checkout
uses: actions/checkout@v4
with:
submodules: recursive
lfs: true
- name: Detect Unity Version
id: detect-unity-version
run: |
PROJECT_VERSION_PATH="${{ env.UNITY_PROJECT_PATH }}/ProjectSettings/ProjectVersion.txt"
UNITY_HUB="C:\Program Files\Unity Hub\Unity Hub.exe"
UNITY_VERSION=`cat ${PROJECT_VERSION_PATH} | sed -n -E "s/^m_EditorVersion:\s+//p" | head -n 1`
UNITY_CHANGESET=`cat ${PROJECT_VERSION_PATH} | sed -n -E "s/^m_EditorVersionWithRevision:\s+\S+\s+\((\S+)\)/\1/p" | head -n 1`
UNITY_EDITOR_EXECUTABLE=`"${UNITY_HUB}" -- --headless editors --installed | \
sed -n -E "s/^${UNITY_VERSION} , installed at //p" | \
head -n 1`
if [ -z "${UNITY_EDITOR_EXECUTABLE}" ]; then
echo "Unity ${UNITY_VERSION} is not installed."
exit 1
# コマンドラインからのインストールは Unity 3.7.0 時点では UAC 必須で難しい
UNITY_INSTALL_COMMAND="\"${UNITY_HUB}\" -- --headless install \
--version ${UNITY_VERSION} \
--changeset ${UNITY_CHANGESET} \
--module windows-il2cpp \
--childModules"
fi
echo "${UNITY_EDITOR_EXECUTABLE} is installed."
echo "unity-editor-executable=${UNITY_EDITOR_EXECUTABLE}" >> "${GITHUB_OUTPUT}"
# URP
- name: Build VRM10Viewer
id: build-webgl-VRM10Viewer
run: |
# build to Build/VRM10Viewer
"${{ steps.detect-unity-version.outputs.unity-editor-executable }}" \
-batchmode -quit \
-silent-crashes \
-projectPath "${{ env.UNITY_PROJECT_PATH }}" \
-executeMethod "UniVRM10.DevOnly.BuildClass.BuildWebGL_VRM10Viewer" \
-logFile webgl-VRM10Viewer.log
echo "Success to WebGL VRM10Viewer."
# はじめに built-in RenderPipeline にして一度終わる。然るのちに
- name: Build SimpleViewer
id: build-webgl-SimpleViewer
run: |
"${{ steps.detect-unity-version.outputs.unity-editor-executable }}" \
-batchmode -quit \
-silent-crashes \
-projectPath "${{ env.UNITY_PROJECT_PATH }}" \
-executeMethod "VRM.DevOnly.BuildClass.SwitchBuiltinPipeline"
echo "Success to Switch built-in RenderPipeline."
# build to Build/SimpleViewer
"${{ steps.detect-unity-version.outputs.unity-editor-executable }}" \
-batchmode -quit \
-silent-crashes \
-projectPath "${{ env.UNITY_PROJECT_PATH }}" \
-executeMethod "VRM.DevOnly.BuildClass.BuildWebGL_SimpleViewer" \
-logFile webgl-SimpleViewer.log
echo "Success to WebGL SimpleViewer."
# make index
cat << __HTML__ > Build/index.html
<h2>$GITHUB_SHA</h2>
<ul>
<li>URP<a href="./VRM10Viewer/">VRM10Viewer</a></li>
<li>Built-in<a href="./SimpleViewer/">SimpleViewer</a></li>
</ul>
__HTML__
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: Build
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

View File

@@ -56,5 +56,8 @@
"Scriptable",
"UNIVRM"
],
"dotnet.defaultSolution": "UniVRM.sln"
"dotnet.defaultSolution": "UniVRM.sln",
"files.associations": {
"*.jslib": "javascript",
}
}

View File

@@ -133,12 +133,12 @@ namespace UniGLTF
var property = AnimationExporter.PropertyToTarget(binding.propertyName);
if (property == glTFAnimationTarget.AnimationProperties.NotImplemented)
{
Debug.LogWarning("Not Implemented keyframe property : " + binding.propertyName);
UniGLTFLogger.Warning("Not Implemented keyframe property : " + binding.propertyName);
continue;
}
if (property == glTFAnimationTarget.AnimationProperties.EulerRotation)
{
Debug.LogWarning("Interpolation setting of AnimationClip should be Quaternion");
UniGLTFLogger.Warning("Interpolation setting of AnimationClip should be Quaternion");
continue;
}

View File

@@ -33,7 +33,7 @@ namespace UniGLTF
//
if (path.StartsWithUnityAssetPath())
{
Debug.LogWarningFormat("disallow import from folder under the Assets");
UniGLTFLogger.Warning("disallow import from folder under the Assets");
return;
}

View File

@@ -212,7 +212,7 @@ namespace UniGLTF.MeshUtility
catch (Exception ex)
{
#if DEBUG
Debug.LogException(ex, context.Instance);
UniGLTFLogger.Exception(ex, context.Instance);
context.Keep = true;
#endif
}

View File

@@ -54,14 +54,14 @@ namespace UniGLTF
_tmpStackTraceLogType = Application.GetStackTraceLogType(LogType.Log);
Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);
Debug.Log($"{LogPrefix}Edit Mode Tests Started.");
UniGLTFLogger.Log($"{LogPrefix}Edit Mode Tests Started.");
}
public void RunFinished(ITestResultAdaptor result)
{
Debug.Log($"{LogPrefix}Edit Mode Tests Finished.");
Debug.Log($"{LogPrefix}Passed: {result.PassCount}, Skipped: {result.SkipCount}, Failed: {result.FailCount}");
Debug.Log($"{ResultLogPrefix}{result.FailCount}");
UniGLTFLogger.Log($"{LogPrefix}Edit Mode Tests Finished.");
UniGLTFLogger.Log($"{LogPrefix}Passed: {result.PassCount}, Skipped: {result.SkipCount}, Failed: {result.FailCount}");
UniGLTFLogger.Log($"{ResultLogPrefix}{result.FailCount}");
Application.SetStackTraceLogType(LogType.Log, _tmpStackTraceLogType);
@@ -69,7 +69,7 @@ namespace UniGLTF
{
if (!string.IsNullOrEmpty(_xmlFilePath))
{
Debug.Log($"{LogPrefix}Write NUnit XML to {_xmlFilePath}");
UniGLTFLogger.Log($"{LogPrefix}Write NUnit XML to {_xmlFilePath}");
var xmlNode = CreateNUnitXmlTree(result);
using var xmlWriter = new XmlTextWriter(_xmlFilePath, Encoding.UTF8);
@@ -92,8 +92,8 @@ namespace UniGLTF
if (result.TestStatus != TestStatus.Passed)
{
Debug.Log($"{LogPrefix}{result.Message}");
Debug.Log($"{LogPrefix}{result.StackTrace}");
UniGLTFLogger.Log($"{LogPrefix}{result.Message}");
UniGLTFLogger.Log($"{LogPrefix}{result.StackTrace}");
}
}

View File

@@ -50,11 +50,11 @@ namespace UniGLTF
{
if (Selection.activeObject is GameObject go)
{
Debug.Log(go.GetPrefabType());
UniGLTFLogger.Log($"{go.GetPrefabType()}");
}
else
{
Debug.Log(Selection.activeContext.GetType());
UniGLTFLogger.Log($"{Selection.activeContext.GetType()}");
}
}
#endif

View File

@@ -49,7 +49,7 @@ namespace UniGLTF
}
catch (ArgumentException)
{
// Debug.LogWarning(ex);
// UniGLTFLogger.LogWarning(ex);
}
}
if (m_root.GameObject == value)

View File

@@ -58,7 +58,7 @@ namespace UniGLTF
else
{
// throw new Exception($"{key} is not converted.");
Debug.LogWarning($"{key} is not converted.");
UniGLTFLogger.Warning($"{key} is not converted.");
}
}

View File

@@ -42,7 +42,7 @@ public static class GltfDeserializer
public static void GenerateSerializer()
{
var info = new ObjectSerialization(typeof(glTF), "gltf", "Deserialize_");
Debug.Log(info);
UniGLTFLogger.Log($"{info}");
using (var s = File.Open(OutPath, FileMode.Create))
using (var w = new StreamWriter(s, new UTF8Encoding(false)))
@@ -52,7 +52,7 @@ public static class GltfDeserializer
w.Write(End);
}
Debug.LogFormat("write: {0}", OutPath);
UniGLTFLogger.Log($"write: {OutPath}");
UnityPath.FromFullpath(OutPath).ImportAsset();
}
}

View File

@@ -42,7 +42,7 @@ namespace UniGLTF {
public static void GenerateSerializer()
{
var info = new ObjectSerialization(typeof(glTF), "gltf", "Serialize_");
Debug.Log(info);
UniGLTFLogger.Log($"{info}");
using (var s = File.Open(OutPath, FileMode.Create))
using (var w = new StreamWriter(s, new UTF8Encoding(false)))
@@ -52,7 +52,7 @@ namespace UniGLTF {
w.Write(End);
}
Debug.LogFormat("write: {0}", OutPath);
UniGLTFLogger.Log($"write: {OutPath}");
UnityPath.FromFullpath(OutPath).ImportAsset();
}
}

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.IO;
using UnityEditor;
using UnityEngine;
using UniGLTF;
namespace UniHumanoid
@@ -122,7 +123,7 @@ animator.GetBoneTransform(x.Head), animator.GetBoneTransform(x.Tail)))
}
else
{
Debug.LogWarning("fail to CreateAvatar");
UniGLTFLogger.Warning("fail to CreateAvatar");
}
}
}

View File

@@ -120,7 +120,6 @@ namespace UniHumanoid
var _target = (HumanPoseTransfer)target;
if (_target.PoseClip != old)
{
//Debug.Log("clip != old");
if (_target.PoseClip != null)
{
var pose = _target.PoseClip.GetPose();
@@ -133,7 +132,7 @@ namespace UniHumanoid
{
if (GUILayout.Button("Apply PoseClip"))
{
Debug.Log("apply");
UniGLTFLogger.Log("apply");
var pose = default(HumanPose);
_target.PoseClip.GetPose(out pose);
_target.SetPose(pose);

View File

@@ -5,6 +5,7 @@ using System.IO;
using UnityEditor;
using UnityEngine;
using System;
using UniGLTF;
namespace UniHumanoid
{
@@ -410,7 +411,7 @@ namespace UniHumanoid
}
else
{
Debug.LogWarning($"cannot create {path}");
UniGLTFLogger.Warning($"cannot create {path}");
}
}
}

View File

@@ -40,7 +40,7 @@ namespace UniHumanoid
}
catch (Exception ex)
{
Debug.LogError(ex);
UniGLTFLogger.Exception(ex);
context.Destroy(true);
}
}

View File

@@ -21,7 +21,7 @@ namespace UniGLTF
{
if (src == null || src.Length < 4)
{
Debug.LogWarning("Invalid argument.");
UniGLTFLogger.Warning("Invalid argument.");
return Color.magenta;
}
@@ -32,7 +32,7 @@ namespace UniGLTF
{
if (src == null || src.Length < 3)
{
Debug.LogWarning("Invalid argument.");
UniGLTFLogger.Warning("Invalid argument.");
return Color.magenta;
}

View File

@@ -46,7 +46,7 @@ namespace UniGLTF
return path.Substring(UnityBasePath.Length + 1);
}
//Debug.LogWarningFormat("{0} is starts with {1}", path, basePath);
//UniGLTFLogger.WarningFormat("{0} is starts with {1}", path, basePath);
return path;
}

View File

@@ -132,7 +132,7 @@ namespace UniGLTF
}
catch (Exception ex)
{
Debug.LogWarningFormat("{0}: {1}", generatorVersion, ex);
UniGLTFLogger.Warning($"{generatorVersion}: {ex}");
return false;
}
}

View File

@@ -43,7 +43,7 @@ namespace UniGLTF.MeshUtility
}
else
{
Debug.LogError($"SkinnedMeshRenderer not found", dst);
UniGLTFLogger.Error($"SkinnedMeshRenderer not found", dst);
}
}
else
@@ -57,12 +57,12 @@ namespace UniGLTF.MeshUtility
}
else
{
Debug.LogError($"MeshRenderer not found", dst);
UniGLTFLogger.Error($"MeshRenderer not found", dst);
}
}
else
{
Debug.LogError($"MeshFilter not found", dst);
UniGLTFLogger.Error($"MeshFilter not found", dst);
}
}
}

View File

@@ -61,7 +61,7 @@ namespace UniGLTF.MeshUtility
{
// 元のボーンが無い
indexMap[i] = -1;
Debug.LogWarningFormat("bones[{0}] is null", i);
UniGLTFLogger.Warning($"bones[{i}] is null");
}
else
{
@@ -80,7 +80,7 @@ namespace UniGLTF.MeshUtility
{
// 先のボーンが無い
indexMap[i] = -1;
Debug.LogWarningFormat("{0} is removed", srcBone.name);
UniGLTFLogger.Warning($"{srcBone.name} is removed");
}
}
}
@@ -298,10 +298,7 @@ namespace UniGLTF.MeshUtility
}
catch (Exception)
{
Debug.LogErrorFormat("fail to mesh.AddBlendShapeFrame {0}.{1}",
mesh.name,
srcMesh.GetBlendShapeName(i)
);
UniGLTFLogger.Error($"fail to mesh.AddBlendShapeFrame {mesh.name}.{srcMesh.GetBlendShapeName(i)}");
throw;
}
}

View File

@@ -99,7 +99,7 @@ namespace UniGLTF.MeshUtility
var mesh = meshFilter.sharedMesh;
if (mesh == null)
{
Debug.LogWarningFormat("{0} has no mesh", renderer.name);
UniGLTFLogger.Warning($"{renderer.name} has no mesh");
return;
}
Result.SourceMeshRenderers.Add(renderer);
@@ -125,7 +125,7 @@ namespace UniGLTF.MeshUtility
var bone = renderer.transform;
if (bone == null)
{
Debug.LogWarningFormat("{0} is root gameobject.", bone.name);
UniGLTFLogger.Warning($"{bone.name} is root gameobject.");
return;
}
var boneIndex = AddBoneIfUnique(bone);
@@ -169,7 +169,7 @@ namespace UniGLTF.MeshUtility
var mesh = renderer.sharedMesh;
if (mesh == null)
{
Debug.LogWarningFormat("{0} has no mesh", renderer.name);
UniGLTFLogger.Warning($"{renderer.name} has no mesh");
return;
}
Result.SourceSkinnedMeshRenderers.Add(renderer);

View File

@@ -45,7 +45,7 @@ MonoBehaviour:
value: 65472
diffusion:
overrideState: 1
value: 7
value: 6.4
anamorphicRatio:
overrideState: 0
value: 0

View File

@@ -219,7 +219,7 @@ namespace UniGLTF
SetBlendShapeAnimationCurve(data, animation, channel, clip, relativePath);
break;
default:
Debug.LogWarningFormat("unknown path: {0}", channel.target.path);
UniGLTFLogger.Warning($"unknown path: {channel.target.path}");
break;
}
@@ -227,7 +227,7 @@ namespace UniGLTF
}
else
{
Debug.LogWarning($"ConvertAnimationClipAsync: channel.target.node: out of range: 0<[{channel.target.node}]<{data.GLTF.nodes.Count}");
UniGLTFLogger.Warning($"ConvertAnimationClipAsync: channel.target.node: out of range: 0<[{channel.target.node}]<{data.GLTF.nodes.Count}");
}
}

View File

@@ -86,7 +86,7 @@ namespace UniGLTF
{
// ありえない。はず
var join = string.Join(", ", path);
Debug.LogWarning($"invalid json path: {join}");
UniGLTFLogger.Warning($"invalid json path: {join}");
}
}
}

View File

@@ -16,7 +16,7 @@ namespace UniGLTF
if (awaitCaller == null)
{
Debug.LogWarning("GltfUtility.LoadAsync: awaitCaller argument is null. ImmediateCaller is used as the default fallback. When playing, we recommend RuntimeOnlyAwaitCaller.");
UniGLTFLogger.Warning("GltfUtility.LoadAsync: awaitCaller argument is null. ImmediateCaller is used as the default fallback. When playing, we recommend RuntimeOnlyAwaitCaller.");
awaitCaller = new ImmediateCaller();
}
@@ -36,7 +36,7 @@ namespace UniGLTF
if (awaitCaller == null)
{
Debug.LogWarning("GltfUtility.LoadAsync: awaitCaller argument is null. ImmediateCaller is used as the default fallback. When playing, we recommend RuntimeOnlyAwaitCaller.");
UniGLTFLogger.Warning("GltfUtility.LoadAsync: awaitCaller argument is null. ImmediateCaller is used as the default fallback. When playing, we recommend RuntimeOnlyAwaitCaller.");
awaitCaller = new ImmediateCaller();
}

View File

@@ -362,7 +362,7 @@ namespace UniGLTF
{
if (index < 0 || index >= Nodes.Count)
{
Debug.LogWarning($"nodes[{index}] is not found !");
UniGLTFLogger.Warning($"nodes[{index}] is not found !");
node = default;
return false;
}

View File

@@ -23,7 +23,7 @@ namespace UniGLTF
if (Symbols.VRM_DEVELOP)
{
Debug.Log($"{self.Data.TargetPath}: {meassureTime.GetSpeedLog()}");
UniGLTFLogger.Log($"{self.Data.TargetPath}: {meassureTime.GetSpeedLog()}");
}
return task.Result;

View File

@@ -39,7 +39,7 @@ namespace UniGLTF
break;
}
Debug.Log($"Material `{m.name}` fallbacks.");
UniGLTFLogger.Log($"Material `{m.name}` fallbacks.");
return BuiltInFallbackMaterialExporter.ExportMaterial(m, textureExporter);
}
}

View File

@@ -17,7 +17,7 @@ namespace UniGLTF
// fallback
if (Symbols.VRM_DEVELOP)
{
Debug.LogWarning($"material: {i} out of range. fallback");
UniGLTFLogger.Warning($"material: {i} out of range. fallback");
}
return GetGltfDefault(GltfMaterialImportUtils.ImportMaterialName(i, null));
}

View File

@@ -38,7 +38,7 @@ namespace UniGLTF
{
if (!validation.CanExport)
{
Debug.LogError(validation.Message, src);
UniGLTFLogger.Error(validation.Message, src);
throw new UniGLTFNotSupportedException(validation.Message);
}
}
@@ -59,7 +59,7 @@ namespace UniGLTF
}
catch (Exception e)
{
Debug.LogException(e);
UniGLTFLogger.Exception(e);
dst = default;
return false;
}

View File

@@ -70,7 +70,7 @@ namespace UniGLTF
}
catch (Exception e)
{
Debug.LogException(e);
UniGLTFLogger.Exception(e);
dst = default;
return false;
}

View File

@@ -41,7 +41,7 @@ namespace UniGLTF
}
catch (Exception e)
{
Debug.LogException(e);
UniGLTFLogger.Exception(e);
dst = default;
return false;
}

View File

@@ -15,7 +15,7 @@ namespace UniGLTF
if (UrpUnlitExporter.TryExportMaterial(m, textureExporter, out dst)) return dst;
if (UrpUniUnlitExporter.TryExportMaterial(m, textureExporter, out dst)) return dst;
Debug.Log($"Material `{m.name}` fallbacks.");
UniGLTFLogger.Log($"Material `{m.name}` fallbacks.");
return FallbackExporter.ExportMaterial(m, textureExporter);
}
}

View File

@@ -18,7 +18,7 @@ namespace UniGLTF
// NOTE: Fallback to default material
if (Symbols.VRM_DEVELOP)
{
Debug.LogWarning($"material: {i} out of range. fallback");
UniGLTFLogger.Warning($"material: {i} out of range. fallback");
}
return GetGltfDefault(GltfMaterialImportUtils.ImportMaterialName(i, null));
}

View File

@@ -227,7 +227,7 @@ namespace UniGLTF
{
if (i >= targetNames.Count)
{
Debug.LogWarning($"invalid primitive.extras.targetNames length");
UniGLTFLogger.Warning($"invalid primitive.extras.targetNames length");
break;
}

View File

@@ -262,7 +262,7 @@ namespace UniGLTF
}
else
{
Debug.LogWarning($"unknown renderer: {renderer}", context: renderer);
UniGLTFLogger.Warning($"unknown renderer: {renderer}", context: renderer);
}
}

View File

@@ -168,7 +168,7 @@ namespace UniGLTF
indices.Clear();
if (j >= materials.Length)
{
Debug.LogWarningFormat("{0}.materials is not enough", mesh.name);
UniGLTFLogger.Warning($"{mesh.name}.materials is not enough");
continue;
}
@@ -184,7 +184,7 @@ namespace UniGLTF
}
else if (submeshIndices.Length < 3)
{
Debug.LogWarningFormat("Invalid primitive of type {0} found", topologyType);
UniGLTFLogger.Warning($"Invalid primitive of type {topologyType} found");
continue;
}
@@ -193,19 +193,19 @@ namespace UniGLTF
{
case MeshTopology.Triangles:
if (submeshIndices.Length % 3 != 0)
Debug.LogWarningFormat("triangle indices is not multiple of 3");
UniGLTFLogger.Warning("triangle indices is not multiple of 3");
GetTriangleIndices(indices, submeshIndices);
break;
case MeshTopology.Quads:
if (submeshIndices.Length % 4 != 0)
Debug.LogWarningFormat("quad indices is not multiple of 4");
UniGLTFLogger.Warning("quad indices is not multiple of 4");
GetQuadIndices(indices, submeshIndices);
break;
default:
case MeshTopology.Lines:
case MeshTopology.LineStrip:
case MeshTopology.Points:
Debug.LogWarningFormat("Mesh {0} has unsupported topology type {1}.", mesh.name, topologyType);
UniGLTFLogger.Warning($"Mesh {mesh.name} has unsupported topology type {topologyType}.");
continue;
}

View File

@@ -68,9 +68,7 @@ namespace UniGLTF
}
else
{
Debug.LogWarningFormat(
"May be partial primitive has blendShape. Require separate mesh or extend blend shape, but not implemented: {0}",
blendShape.Name);
UniGLTFLogger.Warning($"May be partial primitive has blendShape. Require separate mesh or extend blend shape, but not implemented: {blendShape.Name}");
}
}
else
@@ -91,8 +89,6 @@ namespace UniGLTF
MeshData data,
Func<int?, Task<Material>> materialFromIndex)
{
//Debug.Log(prims.ToJson());
var mesh = new Mesh
{
name = data.Name

View File

@@ -13,7 +13,7 @@ namespace UniGLTF
var nodeName = node.name;
if (!string.IsNullOrEmpty(nodeName) && nodeName.Contains("/"))
{
Debug.LogWarningFormat("node {0} contains /. replace _", node.name);
UniGLTFLogger.Warning($"node {node.name} contains /. replace _");
nodeName = nodeName.Replace("/", "_");
}
if (string.IsNullOrEmpty(nodeName))

View File

@@ -254,7 +254,6 @@ namespace UniGLTF
var extraName = parsed["images"][i]["extra"]["name"].Value.GetString();
if (!string.IsNullOrEmpty(extraName))
{
//Debug.LogFormat("restore texturename: {0}", extraName);
GLTF.images[i].name = extraName;
}
}

View File

@@ -31,7 +31,7 @@ namespace UniGLTF
// System.ArgumentException: not readable, the texture memory can not be accessed from scripts. You can make the texture readable in the Texture Import Settings.
// Failed, because texture is not readable.
Debug.LogWarning(ex);
UniGLTFLogger.Warning($"{ex}");
// 単純に EncodeToPNG できないため、コピーしてから EncodeToPNG する。
return CopyTextureAndGetBytesWithMime(texture, exportColorSpace);

View File

@@ -39,7 +39,7 @@ namespace UniGLTF
}
catch (Exception e)
{
Debug.LogException(e);
UniGLTFLogger.Exception(e);
return null;
}
#else

View File

@@ -26,7 +26,7 @@ namespace UniGLTF
}
catch (Exception e)
{
Debug.LogException(e);
UniGLTFLogger.Exception(e);
return null;
}
}

View File

@@ -28,18 +28,18 @@ namespace UniGLTF
default:
if (string.IsNullOrEmpty(textureInfo.DataMimeType))
{
Debug.Log($"Texture image MIME type is empty.");
UniGLTFLogger.Log($"Texture image MIME type is empty.");
}
else
{
Debug.Log($"Texture image MIME type `{textureInfo.DataMimeType}` is not supported.");
UniGLTFLogger.Log($"Texture image MIME type `{textureInfo.DataMimeType}` is not supported.");
}
break;
}
if (texture == null)
{
Debug.Log($"Failed to load texture from image data.");
UniGLTFLogger.Log($"Failed to load texture from image data.");
texture = new Texture2D(2, 2, TextureFormat.ARGB32, textureInfo.UseMipmap, textureInfo.ColorSpace == ColorSpace.Linear);
}

View File

@@ -495,7 +495,7 @@ namespace UniGLTF
// アセットを作ることができないファイル名だったと仮定。
// 元のファイル名のどこに問題があるか不明なので Guid で置き換える。
var newName = $"{Parent.Value}/{Guid.NewGuid().ToString("N")}{Extension}";
Debug.LogWarning($"rename: {Value} => {newName}");
UniGLTFLogger.Warning($"rename: {Value} => {newName}");
AssetDatabase.CreateAsset(o, newName);
}

View File

@@ -117,7 +117,7 @@ namespace UniGLTF
if (Copy.transform.TryGetComponent<Renderer>(out var r))
{
// should throw ?
Debug.LogError("root mesh is not exported");
UniGLTFLogger.Error("root mesh is not exported");
}
ReportProgress("prepared", 0.1f);

View File

@@ -5,7 +5,7 @@ namespace UniGLTF
{
public const int MAJOR = 0;
public const int MINOR = 128;
public const int PATCH = 1;
public const string VERSION = "0.128.1";
public const int PATCH = 2;
public const string VERSION = "0.128.2";
}
}

View File

@@ -169,7 +169,7 @@ namespace UniGLTF
{
if (oldResource == null || newResource == null || oldResource.GetType() != newResource.GetType())
{
Debug.LogError($"{nameof(RuntimeGltfInstance)} - Could not replace resource: mismatched or null types.");
UniGLTFLogger.Error($"{nameof(RuntimeGltfInstance)} - Could not replace resource: mismatched or null types.");
return;
}

View File

@@ -5,7 +5,7 @@ namespace UniGLTF
{
public const int MAJOR = 2;
public const int MINOR = 64;
public const int PATCH = 1;
public const string VERSION = "2.64.1";
public const int PATCH = 2;
public const string VERSION = "2.64.2";
}
}

View File

@@ -6,6 +6,7 @@ using System;
using System.Linq;
using System.Collections.Generic;
using UniGLTF.Utils;
using UniGLTF;
namespace UniHumanoid
@@ -128,7 +129,7 @@ namespace UniHumanoid
public Avatar CreateAvatar(Transform root)
{
// force unique name
ForceUniqueName.Process(root);
ForceTransformUniqueName.Validate(root);
return AvatarBuilder.BuildHumanAvatar(root.gameObject, ToHumanDescription(root));
}
@@ -252,17 +253,17 @@ namespace UniHumanoid
var importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(target));
if (importer != null)
{
Debug.Log("AssetImporter Type: " + importer.GetType());
UniGLTFLogger.Log("AssetImporter Type: " + importer.GetType());
ModelImporter modelImporter = importer as ModelImporter;
if (modelImporter != null)
{
des = modelImporter.humanDescription;
Debug.Log("## Cool stuff data by ModelImporter ##");
UniGLTFLogger.Log("## Cool stuff data by ModelImporter ##");
return true;
}
else
{
Debug.LogWarning("## Please Select Imported Model in Project View not prefab or other things ##");
UniGLTFLogger.Warning("## Please Select Imported Model in Project View not prefab or other things ##");
}
}
}

View File

@@ -1,6 +1,7 @@
using UnityEngine;
using System.Linq;
using UniGLTF.Utils;
using UniGLTF;
namespace UniHumanoid
{
@@ -46,7 +47,7 @@ namespace UniHumanoid
var hips = Bones[(int)HumanBodyBones.Hips];
if (hips == null)
{
Debug.LogWarning("require hips");
UniGLTFLogger.Warning("require hips");
return;
}

View File

@@ -65,6 +65,15 @@ namespace UniHumanoid
}
HumanPoseHandler m_handler;
public void Dispose()
{
if (m_handler != null)
{
m_handler.Dispose();
m_handler = null;
}
}
public void OnEnable()
{
if (TryGetComponent<Animator>(out var animator))
@@ -75,12 +84,18 @@ namespace UniHumanoid
Setup();
}
void OnDisable()
{
Dispose();
}
public void Setup()
{
if (Avatar == null)
{
return;
}
Dispose();
m_handler = new HumanPoseHandler(Avatar, transform);
}

View File

@@ -9,7 +9,7 @@ namespace UniHumanoid
{
public static Avatar LoadHumanoidAvatar(Transform root, IEnumerable<(Transform, HumanBodyBones)> boneMap)
{
ForceUniqueName.Process(root);
UniGLTF.Utils.ForceTransformUniqueName.Process(root);
var description = new HumanDescription
{

View File

@@ -149,13 +149,13 @@ namespace UniHumanoid
// already exists
if (IsOwn(prefabPath))
{
//Debug.LogFormat("already exist. own: {0}", prefabPath);
//UniGLTFLogger.LogFormat("already exist. own: {0}", prefabPath);
}
else
{
// but unknown prefab
var unique = AssetDatabase.GenerateUniqueAssetPath(prefabPath);
//Debug.LogFormat("already exist: {0} => {1}", prefabPath, unique);
//UniGLTFLogger.LogFormat("already exist: {0} => {1}", prefabPath, unique);
prefabPath = unique;
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UniGLTF;
using UnityEngine;
@@ -254,7 +255,7 @@ namespace UniHumanoid
{
if (Application.isEditor)
{
Debug.LogWarningFormat("{0} not found", headTail.Head);
UniGLTFLogger.Warning($"{headTail.Head} not found");
}
}
}

View File

@@ -120,12 +120,6 @@ namespace UniJSON
break;
}
top.Count += 1;
/*
{
var debug = string.Format("{0} {1} = {2}", m_stack.Count, top.Current, top.Count);
Debug.Log(debug);
}
*/
m_stack.Push(top);
}

View File

@@ -2,16 +2,34 @@ using System;
using System.Collections.Generic;
using UnityEngine;
namespace UniHumanoid
namespace UniGLTF.Utils
{
class ForceUniqueName
public class ForceTransformUniqueName
{
HashSet<string> m_uniqueNameSet = new HashSet<string>();
int m_counter = 1;
public static bool Validate(Transform root)
{
HashSet<string> uniqueNameSet = new HashSet<string>();
var transforms = root.GetComponentsInChildren<Transform>();
foreach (var t in transforms)
{
if (uniqueNameSet.Contains(t.name))
{
UniGLTFLogger.Warning($"duplicate name: {t.name}");
}
else
{
uniqueNameSet.Add(t.name);
}
}
return uniqueNameSet.Count == transforms.Length;
}
public static void Process(Transform root)
{
var uniqueName = new ForceUniqueName();
var uniqueName = new ForceTransformUniqueName();
var transforms = root.GetComponentsInChildren<Transform>();
foreach (var t in transforms)
{
@@ -40,7 +58,7 @@ namespace UniHumanoid
var newName = $"{t.parent.name}-{t.name}";
if (!m_uniqueNameSet.Contains(newName))
{
Debug.LogWarning($"force rename !!: {t.name} => {newName}");
UniGLTFLogger.Warning($"force rename !!: {t.name} => {newName}");
t.name = newName;
m_uniqueNameSet.Add(newName);
return;
@@ -54,7 +72,7 @@ namespace UniHumanoid
var newName = $"{t.name}{m_counter++}";
if (!m_uniqueNameSet.Contains(newName))
{
Debug.LogWarning($"force rename: {t.name} => {newName}", t);
UniGLTFLogger.Warning($"force rename: {t.name} => {newName}", t);
t.name = newName;
m_uniqueNameSet.Add(newName);
return;

View File

@@ -1,3 +1,4 @@
using System;
using UnityEngine;
namespace UniGLTF
@@ -56,5 +57,20 @@ namespace UniGLTF
[HideInCallstack]
#endif
public static void Log(string msg, UnityEngine.Object context = null) => s_logger.LogFormat(LogType.Log, context, msg);
#if UNITY_2022_OR_NEWER
[HideInCallstack]
#endif
public static void Warning(string msg, UnityEngine.Object context = null) => s_logger.LogFormat(LogType.Warning, context, msg);
#if UNITY_2022_OR_NEWER
[HideInCallstack]
#endif
public static void Error(string msg, UnityEngine.Object context = null) => s_logger.LogFormat(LogType.Error, context, msg);
#if UNITY_2022_OR_NEWER
[HideInCallstack]
#endif
public static void Exception(Exception exception, UnityEngine.Object context = null) => s_logger.LogException(exception, context);
}
}

View File

@@ -2,8 +2,8 @@
"name": "GltfViewer",
"rootNamespace": "",
"references": [
"GUID:da3e51d19d51a544fa14d43fee843098",
"GUID:8d76e605759c3f64a957d63ef96ada7c"
"GUID:8d76e605759c3f64a957d63ef96ada7c",
"GUID:1cd941934d098654fa21a13f28346412"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -26,7 +26,7 @@ namespace UniGLTF.GltfViewer
{
return;
}
Debug.Log($"open: {path}");
UniGLTFLogger.Log($"open: {path}");
LoadPathAsync(path);
}
@@ -46,15 +46,15 @@ namespace UniGLTF.GltfViewer
_instance = await GltfUtility.LoadAsync(path.FullPath);
if (_instance == null)
{
Debug.LogWarning("LoadAsync: null");
UniGLTFLogger.Warning("LoadAsync: null");
return;
}
Debug.Log($"LoadAsync: {sw.Elapsed}");
UniGLTFLogger.Log($"LoadAsync: {sw.Elapsed}");
_instance.ShowMeshes();
}
catch (Exception ex)
{
Debug.LogException(ex);
UniGLTFLogger.Exception(ex);
}
}
}

View File

@@ -1,13 +1,16 @@
using UnityEngine;
namespace UniGLTF.GltfViewer
{
public static class OpenFileDialog
{
public static PathObject Show(string title, params string[] extensions)
{
Debug.Log(typeof(UniGLTFLogger));
#if UNITY_STANDALONE_WIN
return PathObject.FromFullPath(FileDialogForWindows.FileDialog(title, extensions));
#else
UnityEngine.Debug.LogWarning("Non-Windows runtime file dialogs are not yet implemented.");
UniGLTFLogger.Warning("Non-Windows runtime file dialogs are not yet implemented.");
return default;
#endif
}

View File

@@ -1,6 +1,6 @@
{
"name": "com.vrmc.gltf",
"version": "0.128.1",
"version": "0.128.2",
"displayName": "UniGLTF",
"description": "GLTF importer and exporter",
"unity": "2021.3",

View File

@@ -2,8 +2,8 @@
"name": "GltfViewer",
"rootNamespace": "",
"references": [
"GUID:da3e51d19d51a544fa14d43fee843098",
"GUID:8d76e605759c3f64a957d63ef96ada7c"
"GUID:8d76e605759c3f64a957d63ef96ada7c",
"GUID:1cd941934d098654fa21a13f28346412"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -26,7 +26,7 @@ namespace UniGLTF.GltfViewer
{
return;
}
Debug.Log($"open: {path}");
UniGLTFLogger.Log($"open: {path}");
LoadPathAsync(path);
}
@@ -46,15 +46,15 @@ namespace UniGLTF.GltfViewer
_instance = await GltfUtility.LoadAsync(path.FullPath);
if (_instance == null)
{
Debug.LogWarning("LoadAsync: null");
UniGLTFLogger.Warning("LoadAsync: null");
return;
}
Debug.Log($"LoadAsync: {sw.Elapsed}");
UniGLTFLogger.Log($"LoadAsync: {sw.Elapsed}");
_instance.ShowMeshes();
}
catch (Exception ex)
{
Debug.LogException(ex);
UniGLTFLogger.Exception(ex);
}
}
}

View File

@@ -1,13 +1,16 @@
using UnityEngine;
namespace UniGLTF.GltfViewer
{
public static class OpenFileDialog
{
public static PathObject Show(string title, params string[] extensions)
{
Debug.Log(typeof(UniGLTFLogger));
#if UNITY_STANDALONE_WIN
return PathObject.FromFullPath(FileDialogForWindows.FileDialog(title, extensions));
#else
UnityEngine.Debug.LogWarning("Non-Windows runtime file dialogs are not yet implemented.");
UniGLTFLogger.Warning("Non-Windows runtime file dialogs are not yet implemented.");
return default;
#endif
}

View File

@@ -1,6 +1,7 @@
using System.IO;
using System.Reflection;
using System.Text;
using UniGLTF;
using UnityEditor;
using UnityEngine;
@@ -25,7 +26,7 @@ namespace VRM
public static void GenerateCode()
{
var info = new UniGLTF.ObjectSerialization(typeof(glTF_VRM_extensions), "vrm", "_Deserialize");
Debug.Log(info);
UniGLTFLogger.Log($"{info}");
using (var s = File.Open(OutPath, FileMode.Create))
using (var w = new StreamWriter(s, Encoding.UTF8))
@@ -53,7 +54,7 @@ public static class VrmDeserializer
} // VRM
");
Debug.LogFormat("write: {0}", OutPath);
UniGLTFLogger.Log($"write: {OutPath}");
}
}
}

View File

@@ -44,7 +44,7 @@ namespace VRM {
public static void GenerateCode()
{
var info = new ObjectSerialization(typeof(glTF_VRM_extensions), "vrm", "Serialize_");
Debug.Log(info);
UniGLTFLogger.Log($"{info}");
using (var s = File.Open(OutPath, FileMode.Create))
using (var w = new StreamWriter(s, new UTF8Encoding(false)))
@@ -54,7 +54,7 @@ namespace VRM {
w.Write(End);
}
Debug.LogFormat("write: {0}", OutPath);
UniGLTFLogger.Log($"write: {OutPath}");
UnityPath.FromFullpath(OutPath).ImportAsset();
}
}

View File

@@ -80,7 +80,6 @@ namespace VRM
{
if (m_scene != null)
{
//Debug.Log("Bake");
m_scene.Bake(GetBakeValue());
}
}

View File

@@ -1,6 +1,6 @@
using UnityEditor;
namespace VRM
namespace VRM.DevOnly
{
public static class BuildClass
{
@@ -15,7 +15,7 @@ namespace VRM
var report = BuildPipeline.BuildPlayer(
scenes,
"./Build/DummyBuild.exe",
"./Build/DummyBuild/DummyBuild.exe",
BuildTarget.StandaloneWindows,
BuildOptions.Development
);
@@ -25,5 +25,34 @@ namespace VRM
throw new System.Exception(report.summary.ToString());
}
}
public static void SwitchBuiltinPipeline()
{
#if UNITY_6000_0_OR_NEWER
UnityEngine.Rendering.GraphicsSettings.defaultRenderPipeline = null;
#else
UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset = null;
#endif
}
public static void BuildWebGL_SimpleViewer()
{
var scenes = new string[]{
"./Assets/VRM_Samples/SimpleViewer/SimpleViewer.unity",
};
var report = BuildPipeline.BuildPlayer(new BuildPlayerOptions
{
scenes = scenes,
locationPathName = "Build/SimpleViewer",
target = BuildTarget.WebGL,
}
);
if (report.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
{
throw new System.Exception(report.summary.ToString());
}
}
}
}

View File

@@ -33,7 +33,7 @@ namespace VRM
foreach (var x in destroy)
{
// エラーを引き起こす場合がある
// Debug.LogFormat("destroy: {0}", x.name);
// UniGLTFLogger.LogFormat("destroy: {0}", x.name);
GameObject.DestroyImmediate(x);
}
}
@@ -133,7 +133,7 @@ namespace VRM
var newName = sb.ToString();
if (!nameCount.ContainsKey(newName))
{
Debug.LogWarningFormat("force rename {0} => {1}", transform.name, newName);
UniGLTFLogger.Warning($"force rename {transform.name} => {newName}");
transform.name = newName;
nameCount.Add(newName, 1);
return;
@@ -245,7 +245,7 @@ namespace VRM
exporter.Export();
}
var bytes = data.ToGlbBytes();
Debug.LogFormat("Export elapsed {0}", sw.Elapsed);
UniGLTFLogger.Log($"Export elapsed {sw.Elapsed}");
return bytes;
}
}

View File

@@ -119,7 +119,7 @@ namespace VRM
if (Symbols.VRM_DEVELOP)
{
// 来ない?
Debug.LogWarning($"{o} already exists. skip write");
UniGLTFLogger.Warning($"{o} already exists. skip write");
}
return;
}

View File

@@ -222,7 +222,7 @@ namespace VRM
}
else
{
Debug.LogWarning("not found");
UniGLTFLogger.Warning("not found");
}
}
}

View File

@@ -26,7 +26,7 @@ namespace VRM
// import vrm to asset
if (path.StartsWithUnityAssetPath())
{
Debug.LogWarningFormat("disallow import from folder under the Assets");
UniGLTFLogger.Warning("disallow import from folder under the Assets");
return;
}

View File

@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Linq;
using UniGLTF;
using UnityEngine;
namespace VRM
@@ -57,14 +58,13 @@ namespace VRM
Directory.Delete(dstDir, recursive: true);
}
_Copy(srcDir, dstDir);
Debug.Log($"copy {srcDir} \n => {dstDir}");
UniGLTFLogger.Log($"copy {srcDir} \n => {dstDir}");
}
static void _Copy(string src, string dst)
{
if (Directory.Exists(src))
{
// Debug.Log($"CreateDirectory({dst})");
Directory.CreateDirectory(dst);
foreach (var child in Directory.EnumerateFileSystemEntries(src))
{
@@ -73,7 +73,6 @@ namespace VRM
}
else if (File.Exists(src))
{
// Debug.Log($"Copy {src} => {dst}");
File.Copy(src, dst);
}
else
@@ -93,7 +92,7 @@ namespace VRM
{
if (!Directory.Exists(dst))
{
Debug.LogError($"{dst} not exists");
UniGLTFLogger.Error($"{dst} not exists");
return false;
}
@@ -110,7 +109,7 @@ namespace VRM
if (list.Count > 0)
{
var remain = string.Join(",", list);
Debug.LogError($"only dst: {remain}");
UniGLTFLogger.Error($"only dst: {remain}");
return false;
}
return true;
@@ -120,12 +119,12 @@ namespace VRM
// same file
if (!File.Exists(dst))
{
Debug.LogError($"{dst} not exists");
UniGLTFLogger.Error($"{dst} not exists");
return false;
}
if (!File.ReadAllBytes(src).SequenceEqual(File.ReadAllBytes(dst)))
{
Debug.LogError($"{src} != {dst}");
UniGLTFLogger.Error($"{src} != {dst}");
return false;
}
return true;
@@ -133,7 +132,7 @@ namespace VRM
else
{
// throw new FileNotFoundException(src);
Debug.LogError($"dir nor file");
UniGLTFLogger.Error($"dir nor file");
return false;
}
}

View File

@@ -7,24 +7,24 @@ using System;
namespace VRM
{
/// <summary>
/// VersionDialog
///
/// v0.81.0: com.vrmc.unigltf to com.vrmc.gltf and same version with univrm.
///
/// Major = 2
/// Minor = VRMVersion.MINOR - 64
/// Patch = VRMVersion.PATCH
///
/// </summary>
public class VRMVersionMenu : EditorWindow
{
/// <summary>
/// VersionDialog
///
/// v0.81.0: com.vrmc.unigltf to com.vrmc.gltf and same version with univrm.
///
/// Major = 2
/// Minor = VRMVersion.MINOR - 64
/// Patch = VRMVersion.PATCH
///
/// UNIGLTF
/// </summary>
public class VRMVersionMenu : EditorWindow
{
/// <summary>
/// UNIGLTF
/// </summary>
static string UniGltfVersionPath = "Assets/UniGLTF/Runtime/UniGLTF/UniGLTFVersion.cs";
static string UniGltfVersionPath = "Assets/UniGLTF/Runtime/UniGLTF/UniGLTFVersion.cs";
const string UniGltfVersionTemplate = @"
const string UniGltfVersionTemplate = @"
namespace UniGLTF
{{
public static partial class UniGLTFVersion
@@ -37,11 +37,11 @@ namespace UniGLTF
}}
";
/// <summary>
/// VRM
/// </summary>
const string VrmVersionPath = "Assets/UniGLTF/Runtime/UniGLTF/PackageVersion.cs";
const string VrmVersionTemplate = @"
/// <summary>
/// VRM
/// </summary>
const string VrmVersionPath = "Assets/UniGLTF/Runtime/UniGLTF/PackageVersion.cs";
const string VrmVersionTemplate = @"
namespace UniGLTF
{{
public static partial class PackageVersion
@@ -54,20 +54,20 @@ namespace UniGLTF
}}
";
struct UpmPackage
{
public readonly string Path;
public readonly string Template;
struct UpmPackage
{
public readonly string Path;
public readonly string Template;
public UpmPackage(string path, string template)
{
Path = path;
Template = template;
}
}
public UpmPackage(string path, string template)
{
Path = path;
Template = template;
}
}
UpmPackage[] Packages = new UpmPackage[]
{
UpmPackage[] Packages = new UpmPackage[]
{
new UpmPackage("Assets/VRM/package.json",
@"{{
""name"": ""com.vrmc.univrm"",
@@ -142,14 +142,19 @@ namespace UniGLTF
""displayName"": ""VRM10FirstPersonSample"",
""description"": ""First Person layer sample with multi camera"",
""path"": ""Samples~/VRM10FirstPersonSample""
}},
{{
""displayName"": ""ClothSample"",
""description"": ""Experimental cloth implementation"",
""path"": ""Samples~/ClothSample""
}}
]
}}
"),
};
};
UpmPackage UniGLTFPackage = new UpmPackage("Assets/UniGLTF/package.json",
UpmPackage UniGLTFPackage = new UpmPackage("Assets/UniGLTF/package.json",
@"{{
""name"": ""com.vrmc.gltf"",
""version"": ""{0}"",
@@ -174,137 +179,137 @@ namespace UniGLTF
]
}}");
[SerializeField]
string m_vrmVersion;
[SerializeField]
string m_vrmVersion;
(int, int, int) m_uniGltfVersion
(int, int, int) m_uniGltfVersion
{
get
{
if (TryGetVersion(m_vrmVersion, out (int, int, int) vrmVersion))
{
get
{
if (TryGetVersion(m_vrmVersion, out (int, int, int) vrmVersion))
{
return (2, vrmVersion.Item2 - 64, vrmVersion.Item3);
}
else
{
return (0, 0, 0);
}
}
return (2, vrmVersion.Item2 - 64, vrmVersion.Item3);
}
static bool TryGetVersion(string src, out (int, int, int) version)
else
{
try
{
if (string.IsNullOrEmpty(src))
{
version = default;
return false;
}
var splitted = src.Split('.');
if (splitted.Length != 3)
{
version = default;
return false;
}
version = (
int.Parse(splitted[0]),
int.Parse(splitted[1]),
int.Parse(splitted[2])
);
return true;
}
catch (Exception)
{
version = default;
return false;
}
}
/// <summary>
/// バージョン管理ダイアログ
/// </summary>
void OnGUI()
{
GUILayout.Label("VRM");
GUILayout.Label($"Current version: {PackageVersion.VERSION}");
m_vrmVersion = EditorGUILayout.TextField("Major.Minor.Patch", m_vrmVersion);
GUILayout.Space(30);
GUILayout.Label("UniGLTF");
GUILayout.Label($"Current version: {UniGLTFVersion.VERSION}");
{
var enabled = GUI.enabled;
GUI.enabled = false;
EditorGUILayout.TextField("Major.Minor.Patch", $"{m_uniGltfVersion}");
GUI.enabled = enabled;
}
GUILayout.Space(30);
if (GUILayout.Button("Apply"))
{
if (TryGetVersion(m_vrmVersion, out (int, int, int) vrmVersion))
{
UpdateVrmVersion(vrmVersion);
UpdateUniGLTFVersion(m_uniGltfVersion, vrmVersion);
AssetDatabase.Refresh();
Debug.Log($"{m_uniGltfVersion}, {vrmVersion}");
}
else
{
Debug.LogWarning($"InvalidFormat: {m_vrmVersion}");
}
// COPY
VRMSampleCopy.Execute();
}
if (GUILayout.Button("Close"))
{
Close();
}
}
void UpdateUniGLTFVersion((int, int, int) uniGltf, (int, int, int) vrm)
{
var utf8 = new UTF8Encoding(false);
File.WriteAllText(UniGltfVersionPath, string.Format(UniGltfVersionTemplate,
uniGltf.Item1,
uniGltf.Item2,
uniGltf.Item3), utf8);
File.WriteAllText(UniGLTFPackage.Path, string.Format(UniGLTFPackage.Template,
$"{vrm.Item1}.{vrm.Item2}.{vrm.Item3}",
$"{vrm.Item1}.{vrm.Item2}.{vrm.Item3}"
), utf8);
}
void UpdateVrmVersion((int, int, int) vrm)
{
// generate
var utf8 = new UTF8Encoding(false);
File.WriteAllText(VrmVersionPath, string.Format(VrmVersionTemplate,
vrm.Item1,
vrm.Item2,
vrm.Item3), utf8);
// UPM
foreach (var upm in Packages)
{
File.WriteAllText(upm.Path, string.Format(upm.Template,
$"{vrm.Item1}.{vrm.Item2}.{vrm.Item3}",
$"{vrm.Item1}.{vrm.Item2}.{vrm.Item3}"
), utf8);
}
}
public static void ShowVersionDialog()
{
var window = ScriptableObject.CreateInstance<VRMVersionMenu>();
window.m_vrmVersion = PackageVersion.VERSION;
// window.m_uniGltfVersion = UniGLTFVersion.VERSION;
window.ShowUtility();
return (0, 0, 0);
}
}
}
static bool TryGetVersion(string src, out (int, int, int) version)
{
try
{
if (string.IsNullOrEmpty(src))
{
version = default;
return false;
}
var splitted = src.Split('.');
if (splitted.Length != 3)
{
version = default;
return false;
}
version = (
int.Parse(splitted[0]),
int.Parse(splitted[1]),
int.Parse(splitted[2])
);
return true;
}
catch (Exception)
{
version = default;
return false;
}
}
/// <summary>
/// バージョン管理ダイアログ
/// </summary>
void OnGUI()
{
GUILayout.Label("VRM");
GUILayout.Label($"Current version: {PackageVersion.VERSION}");
m_vrmVersion = EditorGUILayout.TextField("Major.Minor.Patch", m_vrmVersion);
GUILayout.Space(30);
GUILayout.Label("UniGLTF");
GUILayout.Label($"Current version: {UniGLTFVersion.VERSION}");
{
var enabled = GUI.enabled;
GUI.enabled = false;
EditorGUILayout.TextField("Major.Minor.Patch", $"{m_uniGltfVersion}");
GUI.enabled = enabled;
}
GUILayout.Space(30);
if (GUILayout.Button("Apply"))
{
if (TryGetVersion(m_vrmVersion, out (int, int, int) vrmVersion))
{
UpdateVrmVersion(vrmVersion);
UpdateUniGLTFVersion(m_uniGltfVersion, vrmVersion);
AssetDatabase.Refresh();
UniGLTFLogger.Log($"{m_uniGltfVersion}, {vrmVersion}");
}
else
{
UniGLTFLogger.Warning($"InvalidFormat: {m_vrmVersion}");
}
// COPY
VRMSampleCopy.Execute();
}
if (GUILayout.Button("Close"))
{
Close();
}
}
void UpdateUniGLTFVersion((int, int, int) uniGltf, (int, int, int) vrm)
{
var utf8 = new UTF8Encoding(false);
File.WriteAllText(UniGltfVersionPath, string.Format(UniGltfVersionTemplate,
uniGltf.Item1,
uniGltf.Item2,
uniGltf.Item3), utf8);
File.WriteAllText(UniGLTFPackage.Path, string.Format(UniGLTFPackage.Template,
$"{vrm.Item1}.{vrm.Item2}.{vrm.Item3}",
$"{vrm.Item1}.{vrm.Item2}.{vrm.Item3}"
), utf8);
}
void UpdateVrmVersion((int, int, int) vrm)
{
// generate
var utf8 = new UTF8Encoding(false);
File.WriteAllText(VrmVersionPath, string.Format(VrmVersionTemplate,
vrm.Item1,
vrm.Item2,
vrm.Item3), utf8);
// UPM
foreach (var upm in Packages)
{
File.WriteAllText(upm.Path, string.Format(upm.Template,
$"{vrm.Item1}.{vrm.Item2}.{vrm.Item3}",
$"{vrm.Item1}.{vrm.Item2}.{vrm.Item3}"
), utf8);
}
}
public static void ShowVersionDialog()
{
var window = ScriptableObject.CreateInstance<VRMVersionMenu>();
window.m_vrmVersion = PackageVersion.VERSION;
// window.m_uniGltfVersion = UniGLTFVersion.VERSION;
window.ShowUtility();
}
}
}

View File

@@ -23,7 +23,7 @@ namespace VRM
if (unityPath.IsStreamingAsset)
{
Debug.LogFormat("Skip StreamingAssets: {0}", path);
UniGLTFLogger.Log($"Skip StreamingAssets: {path}");
continue;
}
@@ -59,7 +59,7 @@ namespace VRM
{
if (!prefabPath.IsUnderWritableFolder)
{
Debug.LogWarningFormat("out of Asset or writable Packages folder: {0}", prefabPath);
UniGLTFLogger.Warning($"out of Asset or writable Packages folder: {prefabPath}");
return;
}

View File

@@ -327,7 +327,6 @@ namespace VRM
{
var r = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(EditorGUIUtility.singleLineHeight));
var (left, right) = FixedRight(r, 64);
// Debug.Log($"{left}, {right}");
EditorGUI.LabelField(left, label);
EditorGUI.PropertyField(right, prop, new GUIContent(""), false);
}

View File

@@ -71,12 +71,12 @@ namespace VRM
};
if (used.Contains(binding))
{
Debug.LogWarning($"duplicated: {binding}");
UniGLTFLogger.Warning($"duplicated: {binding}");
}
else
{
#if VRM_DEVELOP
Debug.Log($"{val} >> {binding}");
UniGLTFLogger.Log($"{val} >> {binding}");
#endif
used.Add(binding);
yield return binding;
@@ -86,7 +86,7 @@ namespace VRM
else
{
// skip
Debug.LogWarning($"SkinnedMeshRenderer not found: {val.RelativePath}");
UniGLTFLogger.Warning($"SkinnedMeshRenderer not found: {val.RelativePath}");
}
}
}

View File

@@ -95,7 +95,7 @@ namespace VRM
{
if (index < 0 || index >= nodes.Count)
{
Debug.LogWarning($"nodes[{index}] is not found !");
UniGLTFLogger.Warning($"nodes[{index}] is not found !");
node = default;
return false;
}

View File

@@ -3,6 +3,8 @@ using System.Linq;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UniGLTF;
#if UNITY_2018_1_OR_NEWER
using UnityEditor.Build.Reporting;
#endif
@@ -145,20 +147,20 @@ namespace VRM.DevOnly.PackageExporter
{
try
{
Debug.Log($"[{nameof(VRMExportUnityPackage)}] Start CreateUnityPackageWithBuild...");
UniGLTFLogger.Log($"[{nameof(VRMExportUnityPackage)}] Start CreateUnityPackageWithBuild...");
var folder = GetProjectRoot();
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
Debug.Log($"[{nameof(VRMExportUnityPackage)}] Try to build test scenes...");
UniGLTFLogger.Log($"[{nameof(VRMExportUnityPackage)}] Try to build test scenes...");
BuildTestScene();
Debug.Log($"[{nameof(VRMExportUnityPackage)}] Create UnityPackages...");
UniGLTFLogger.Log($"[{nameof(VRMExportUnityPackage)}] Create UnityPackages...");
CreateUnityPackages(folder);
Debug.Log($"[{nameof(VRMExportUnityPackage)}] Finish CreateUnityPackageWithBuild");
UniGLTFLogger.Log($"[{nameof(VRMExportUnityPackage)}] Finish CreateUnityPackageWithBuild");
if (Application.isBatchMode)
{
EditorApplication.Exit(0);
@@ -166,7 +168,7 @@ namespace VRM.DevOnly.PackageExporter
}
catch (Exception e)
{
Debug.LogException(e);
UniGLTFLogger.Exception(e);
if (Application.isBatchMode)
{
EditorApplication.Exit(1);
@@ -262,8 +264,8 @@ namespace VRM.DevOnly.PackageExporter
{
var targetFileNames = package.List.SelectMany(x => x.Files).ToArray();
Debug.LogFormat("Package '{0}' will include {1} files...", package.Name, targetFileNames.Count());
Debug.LogFormat("{0}", string.Join("", targetFileNames.Select((x, i) => string.Format("[{0:##0}] {1}\n", i, x)).ToArray()));
UniGLTFLogger.Log($"Package '{package.Name}' will include {targetFileNames.Count()} files...");
UniGLTFLogger.Log($"{string.Join("", targetFileNames.Select((x, i) => string.Format("[{0:##0}] {1}\n", i, x)).ToArray())}");
var path = MakePackagePathName(outputDir, package.Name);
AssetDatabase.ExportPackage(targetFileNames, path, ExportPackageOptions.Default);
@@ -283,7 +285,7 @@ namespace VRM.DevOnly.PackageExporter
private static void Build(string[] levels)
{
var buildPath = Path.GetFullPath(Application.dataPath + "/../build/build.exe");
Debug.LogFormat("BuildPath: {0}", buildPath);
UniGLTFLogger.Log($"BuildPath: {buildPath}");
var build = BuildPipeline.BuildPlayer(levels,
buildPath,
BuildTarget.StandaloneWindows,

View File

@@ -53,9 +53,15 @@ namespace VRM
private static void ShowVersionDialog() => VRMVersionMenu.ShowVersionDialog();
[MenuItem(DevelopmentMenuPrefix + "/Build dummy for CI", false, 93)]
private static void BuildDummyForCi() => BuildClass.Build();
private static void BuildDummyForCi() => DevOnly.BuildClass.Build();
[MenuItem(DevelopmentMenuPrefix + "/Create UnityPackage", false, 94)]
[MenuItem(DevelopmentMenuPrefix + "/Switch to built-in RenderPipeline", false, 94)]
private static void SwitchToBuiltinPipeline() => DevOnly.BuildClass.SwitchBuiltinPipeline();
[MenuItem(DevelopmentMenuPrefix + "/Build WebGL SimpleViewer for CI", false, 95)]
private static void BuildWebGLForCi0x() => DevOnly.BuildClass.BuildWebGL_SimpleViewer();
[MenuItem(DevelopmentMenuPrefix + "/Create UnityPackage", false, 99)]
private static void CreateUnityPackage() => VRMExportUnityPackage.CreateUnityPackageWithoutBuild();
#endif
}

View File

@@ -1,12 +1,16 @@
{
"name": "MToon",
"references": [],
"optionalUnityReferences": [],
"rootNamespace": "",
"references": [
"GUID:1cd941934d098654fa21a13f28346412"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": false,
"defineConstraints": []
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -1,5 +1,6 @@
using System;
using UnityEngine;
using UniGLTF;
namespace MToon
{
@@ -119,7 +120,7 @@ namespace MToon
case DisabledIntValue:
return RenderMode.Transparent;
default:
Debug.LogWarning("Invalid ZWrite Int Value.");
UniGLTFLogger.Warning("Invalid ZWrite Int Value.");
return RenderMode.Transparent;
}
}
@@ -140,7 +141,7 @@ namespace MToon
case CullMode.Back:
return CullMode.Back;
default:
Debug.LogWarning("Invalid CullMode.");
UniGLTFLogger.Warning("Invalid CullMode.");
return CullMode.Back;
}
}

View File

@@ -65,13 +65,13 @@ namespace VRM
}
else
{
Debug.LogWarningFormat("Invalid blendshape binding: {0}: {1}", target.name, binding);
UniGLTFLogger.Warning($"Invalid blendshape binding: {target.name}: {binding}");
}
}
else
{
Debug.LogWarningFormat("SkinnedMeshRenderer: {0} not found", binding.RelativePath);
UniGLTFLogger.Warning($"SkinnedMeshRenderer: {binding.RelativePath} not found");
}
}
}

View File

@@ -107,7 +107,7 @@ namespace VRM
private void OnDisable()
{
Debug.Log("StopCoroutine");
UniGLTFLogger.Log("StopCoroutine");
if (m_coroutine != null)
{
StopCoroutine(m_coroutine);

View File

@@ -123,7 +123,7 @@ namespace VRM
}
else
{
Debug.LogWarningFormat("material: {0} not found", binding.MaterialName);
UniGLTFLogger.Warning($"material: {binding.MaterialName} not found");
}
}
}
@@ -158,7 +158,7 @@ namespace VRM
}
else
{
Debug.LogWarningFormat("{0} not found", y.MaterialName);
UniGLTFLogger.Warning($"{y.MaterialName} not found");
}
}
}

View File

@@ -176,10 +176,7 @@ namespace VRM
}
else
{
Debug.LogWarningFormat("Out of range {0}: 0 <= {1} < {2}",
SkinnedMeshRenderer.name,
x.Index,
SkinnedMeshRenderer.sharedMesh.blendShapeCount);
UniGLTFLogger.Warning($"Out of range {SkinnedMeshRenderer.name}: 0 <= {x.Index} < {SkinnedMeshRenderer.sharedMesh.blendShapeCount}");
}
}
}

View File

@@ -40,7 +40,6 @@ namespace VRM
GameObject.DestroyImmediate(x.gameObject);
}
//Debug.Log("new prefab. instanciate");
// no previous instance detected, so now let's make a fresh one
// very important: this loads the PreviewInstance prefab and temporarily instantiates it into PreviewInstance
var go = GameObject.Instantiate(prefab,
@@ -246,7 +245,6 @@ namespace VRM
{
if (m_materialMap.TryGetValue(x.MaterialName, out var item))
{
//Debug.Log("set material");
if (item.PropMap.TryGetValue(x.ValueName, out _))
{
var offsetValue = x.TargetValue - x.BaseValue;

View File

@@ -25,7 +25,7 @@ namespace VRM
}
if (string.IsNullOrEmpty((binding.RelativePath)))
{
Debug.LogWarning("binding.RelativePath is null");
UniGLTFLogger.Warning("binding.RelativePath is null");
return null;
}
var found = root.transform.Find(binding.RelativePath);
@@ -35,12 +35,12 @@ namespace VRM
found = root.GetComponentsInChildren<Transform>().FirstOrDefault(x => x.name == name);
if (found == null)
{
Debug.LogWarning($"{binding.RelativePath} not found");
UniGLTFLogger.Warning($"{binding.RelativePath} not found");
return null;
}
else
{
Debug.LogWarning($"fall back '{binding.RelativePath}' => '{found.RelativePathFrom(root)}'");
UniGLTFLogger.Warning($"fall back '{binding.RelativePath}' => '{found.RelativePathFrom(root)}'");
}
}
if (found.TryGetComponent<SkinnedMeshRenderer>(out var renderer))
@@ -98,7 +98,6 @@ namespace VRM
var bind = Create(exporter.Copy.transform, value, exporter);
if (bind == null)
{
// Debug.LogFormat("{0}: skip blendshapebind", clip.name);
continue;
}
bindList.Add(bind);

View File

@@ -61,12 +61,12 @@ namespace VRM
{
if (x.Renderer == null || x.Renderer.transform == null)
{
Debug.LogWarning("[VRMFirstPerson] Renderer is null", this);
UniGLTFLogger.Warning("[VRMFirstPerson] Renderer is null", this);
return false;
}
if (!map.ContainsKey(x.Renderer.transform))
{
Debug.LogWarning("[VRMFirstPerson] Cannot copy. Not found ?", this);
UniGLTFLogger.Warning("[VRMFirstPerson] Cannot copy. Not found ?", this);
return false;
}
return true;
@@ -397,7 +397,6 @@ namespace VRM
{
if (mesh != null)
{
// Debug.LogFormat("[VRMFirstPerson] OnDestroy: {0}", mesh);
UnityEngine.Object.Destroy(mesh);
}
}

View File

@@ -84,7 +84,7 @@ namespace VRM
}
if (value == -1)
{
Debug.LogWarningFormat("not found {0}", texture.name);
UniGLTFLogger.Warning($"not found {texture.name}");
}
else
{

View File

@@ -43,7 +43,7 @@ namespace VRM
// fallback
if (Symbols.VRM_DEVELOP)
{
Debug.LogWarning($"material: {i} out of range. fallback");
UniGLTFLogger.Warning($"material: {i} out of range. fallback");
}
return GetGltfDefault(GltfMaterialImportUtils.ImportMaterialName(i, null));
}

View File

@@ -167,7 +167,7 @@ namespace VRM
vectors,
actions);
Debug.LogWarning($"fallback: {UnlitTransparentZWriteShaderName} => {MToon.Utils.ShaderName}");
UniGLTFLogger.Warning($"fallback: {UnlitTransparentZWriteShaderName} => {MToon.Utils.ShaderName}");
return true;
}
}

View File

@@ -28,7 +28,7 @@ namespace VRM
// NOTE: Fallback to default material
if (Symbols.VRM_DEVELOP)
{
Debug.LogWarning($"material: {i} out of range. fallback");
UniGLTFLogger.Warning($"material: {i} out of range. fallback");
}
return GetGltfDefault(GltfMaterialImportUtils.ImportMaterialName(i, null));
}

View File

@@ -45,7 +45,7 @@ namespace VRM
if (exportSettings.InverseAxis != Vrm0xSpecificationInverseAxis)
{
// migration 用に reverseX を許す
Debug.LogWarning($"VRM specification requires InverseAxis settings as {Vrm0xSpecificationInverseAxis}");
UniGLTFLogger.Warning($"VRM specification requires InverseAxis settings as {Vrm0xSpecificationInverseAxis}");
}
_gltf.extensionsUsed.Add(glTF_VRM_extensions.ExtensionName);
@@ -93,7 +93,7 @@ namespace VRM
var nodeIndex = nodes.IndexOf(transform);
if (nodeIndex < 0)
{
Debug.LogError($"ヒューマンボーンが export 対象に含まれていない?", transform);
UniGLTFLogger.Error($"ヒューマンボーンが export 対象に含まれていない?", transform);
}
else
{

View File

@@ -25,7 +25,7 @@ namespace VRM
if (awaitCaller == null)
{
Debug.LogWarning("VrmUtility.LoadAsync: awaitCaller argument is null. ImmediateCaller is used as the default fallback. When playing, we recommend RuntimeOnlyAwaitCaller.");
UniGLTFLogger.Warning("VrmUtility.LoadAsync: awaitCaller argument is null. ImmediateCaller is used as the default fallback. When playing, we recommend RuntimeOnlyAwaitCaller.");
awaitCaller = new ImmediateCaller();
}
@@ -57,7 +57,7 @@ namespace VRM
catch (NotVrm0Exception)
{
// retry
Debug.LogWarning("file extension is vrm. but not vrm ?");
UniGLTFLogger.Warning("file extension is vrm. but not vrm ?");
using (var loader = new UniGLTF.ImporterContext(data))
{
return await loader.LoadAsync(awaitCaller);
@@ -84,7 +84,7 @@ namespace VRM
if (awaitCaller == null)
{
Debug.LogWarning("VrmUtility.LoadAsync: awaitCaller argument is null. ImmediateCaller is used as the default fallback. When playing, we recommend RuntimeOnlyAwaitCaller.");
UniGLTFLogger.Warning("VrmUtility.LoadAsync: awaitCaller argument is null. ImmediateCaller is used as the default fallback. When playing, we recommend RuntimeOnlyAwaitCaller.");
awaitCaller = new ImmediateCaller();
}
@@ -118,7 +118,7 @@ namespace VRM
catch (NotVrm0Exception)
{
// retry
Debug.LogWarning("file extension is vrm. but not vrm ?");
UniGLTFLogger.Warning("file extension is vrm. but not vrm ?");
using (var loader = new UniGLTF.ImporterContext(data))
{
return await loader.LoadAsync(awaitCaller);

View File

@@ -61,7 +61,6 @@ namespace VRM
if (target != m_lastTarget)
{
// blink
//Debug.Log("request");
m_lastTarget = target;
m_blinker.Request = true;
}

View File

@@ -58,7 +58,7 @@ namespace VRM
if (m_head == null)
{
enabled = false;
Debug.LogError("[VRMLookAtBoneApplyer]VRMLookAtHead not found");
UniGLTFLogger.Log("[VRMLookAtBoneApplyer]VRMLookAtHead not found");
return;
}
m_head.YawPitchChanged += ApplyRotations;

View File

@@ -83,14 +83,14 @@ namespace VRM
var animator = this.GetComponentOrNull<Animator>();
if (animator == null)
{
Debug.LogWarning("animator is not found");
UniGLTFLogger.Warning("animator is not found");
return;
}
var head = animator.GetBoneTransform(HumanBodyBones.Head);
if (head == null)
{
Debug.LogWarning("head is not found");
UniGLTFLogger.Warning("head is not found");
return;
}

Some files were not shown because too many files have changed in this diff Show More