非対応のテクスチャタイプをエラーにする

This commit is contained in:
ousttrue
2021-07-16 15:49:09 +09:00
parent 51b2c48561
commit da4eff1318
2 changed files with 38 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using UniGLTF.M17N;
using UnityEditor;
using UnityEngine;
namespace UniGLTF
@@ -118,9 +119,42 @@ namespace UniGLTF
{
yield return Validation.Warning($"{m}: unknown shader: {m.shader.name} => export as gltf default");
}
}
yield break;
var count = ShaderUtil.GetPropertyCount(m.shader);
for (int i = 0; i < count; ++i)
{
var propType = ShaderUtil.GetPropertyType(m.shader, i);
if (propType == ShaderUtil.ShaderPropertyType.TexEnv)
{
var propName = ShaderUtil.GetPropertyName(m.shader, i);
var tex = m.GetTexture(propName);
if (tex != null)
{
var assetPath = AssetDatabase.GetAssetPath(tex);
if (!string.IsNullOrEmpty(assetPath))
{
if (AssetImporter.GetAtPath(assetPath) is TextureImporter textureImporter)
{
switch (textureImporter.textureType)
{
case TextureImporterType.Default:
case TextureImporterType.NormalMap:
break;
default:
// EditorTextureSerializer throw Exception
// エクスポート未実装
yield return Validation.Error($"{tex}: unknown texture type: {textureImporter.textureType}", ValidationContext.Create(tex));
break;
}
}
}
}
}
}
yield break;
}
}
}
}

View File

@@ -32,14 +32,14 @@ namespace UniGLTF
/// Messageの発生個所にジャンプするための情報
/// </summary>
public Type Type;
public UnityEngine.Component Context;
public UnityEngine.Object Context;
/// <summary>
/// DrawGUIから呼び出す。追加のGUIボタンなどを実装する
/// </summary>
public Action Extended;
public static ValidationContext Create<T>(T c) where T : UnityEngine.Component
public static ValidationContext Create<T>(T c) where T : UnityEngine.Object
{
return new ValidationContext
{