ビルドエラー(runtime への UnityEditor 漏れ出し)を修正

This commit is contained in:
ousttrue
2022-05-31 13:13:03 +09:00
parent bcbd4b9cd4
commit f3ab679da8
4 changed files with 21 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.IO;
using UniGLTF.M17N;
using UnityEditor;
using UnityEngine;
@@ -48,6 +49,21 @@ namespace UniGLTF.MeshUtility
return false;
}
const string ASSET_SUFFIX = ".mesh.asset";
static string GetMeshWritePath(Mesh mesh)
{
if (!string.IsNullOrEmpty((AssetDatabase.GetAssetPath(mesh))))
{
var directory = Path.GetDirectoryName(AssetDatabase.GetAssetPath(mesh)).Replace("\\", "/");
return $"{directory}/{Path.GetFileNameWithoutExtension(mesh.name)}{ASSET_SUFFIX}";
}
else
{
return $"Assets/{Path.GetFileNameWithoutExtension(mesh.name)}{ASSET_SUFFIX}";
}
}
/// <param name="src">GameObject instance in scene or prefab</param>
public static bool Execute(GameObject src, bool onlyBlendShapeRenderers)
{
@@ -75,7 +91,7 @@ namespace UniGLTF.MeshUtility
foreach (var result in results)
{
var mesh = result.IntegratedRenderer.sharedMesh;
var assetPath = MeshIntegratorUtility.GetMeshWritePath(mesh);
var assetPath = GetMeshWritePath(mesh);
Debug.LogFormat("CreateAsset: {0}", assetPath);
AssetDatabase.CreateAsset(mesh, assetPath);
}

View File

@@ -1,14 +1,11 @@
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
namespace UniGLTF.MeshUtility
{
public static class MeshIntegratorUtility
{
const string ASSET_SUFFIX = ".mesh.asset";
/// <summary>
/// go を root としたヒエラルキーから Renderer を集めて、統合された Mesh 作成する
/// </summary>
@@ -183,18 +180,5 @@ namespace UniGLTF.MeshUtility
result.IntegratedRenderer.transform.SetParent(copy.transform, false);
}
}
public static string GetMeshWritePath(Mesh mesh)
{
if (!string.IsNullOrEmpty((AssetDatabase.GetAssetPath(mesh))))
{
var directory = Path.GetDirectoryName(AssetDatabase.GetAssetPath(mesh)).Replace("\\", "/");
return $"{directory}/{Path.GetFileNameWithoutExtension(mesh.name)}{ASSET_SUFFIX}";
}
else
{
return $"Assets/{Path.GetFileNameWithoutExtension(mesh.name)}{ASSET_SUFFIX}";
}
}
}
}

View File

@@ -183,7 +183,9 @@ namespace VRM
Values = src.Values.ToArray();
Preset = src.Preset;
name = src.name;
#if UNITY_EDITOR
Prefab = src.Prefab;
#endif
}
}
}

View File

@@ -78,6 +78,7 @@ namespace VRM.Sample.BlendShapeMenu
return "Assets" + src.Substring(Application.dataPath.Length);
}
#if UNITY_EDITOR
[MenuItem("CONTEXT/BlendShapeAvatar/Add ARKit FaceTracking BlendShapes")]
public static void AddARKitFaceTrackingBlendShapes(MenuCommand command)
{
@@ -176,5 +177,6 @@ namespace VRM.Sample.BlendShapeMenu
Debug.Log($"Assign\n" + sb.ToString());
}
#endif
}
}