mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-12 13:59:21 -05:00
MaterialName
This commit is contained in:
@@ -156,19 +156,13 @@ namespace UniGLTF
|
||||
}
|
||||
}
|
||||
|
||||
public static Material CreateMaterial(int index, glTFMaterial src, string shaderName)
|
||||
public static string MaterialName(int index, glTFMaterial src)
|
||||
{
|
||||
var material = new Material(Shader.Find(shaderName));
|
||||
#if UNITY_EDITOR
|
||||
// textureImporter.SaveAndReimport(); may destroy this material
|
||||
material.hideFlags = HideFlags.DontUnloadUnusedAsset;
|
||||
#endif
|
||||
material.name = (src == null || string.IsNullOrEmpty(src.name))
|
||||
? string.Format("material_{0:00}", index)
|
||||
: src.name
|
||||
;
|
||||
|
||||
return material;
|
||||
if(src!=null && !string.IsNullOrEmpty(src.name))
|
||||
{
|
||||
return src.name;
|
||||
}
|
||||
return $"material_{index:00}";
|
||||
}
|
||||
|
||||
public static void SetTextureOffsetAndScale(Material material, glTFTextureInfo textureInfo, string propertyName)
|
||||
|
||||
@@ -77,13 +77,15 @@ namespace UniGLTF
|
||||
getTexture = (IAwaitCaller _awaitCaller, glTF _gltf, TextureImportParam _param) => Task.FromResult<Texture2D>(null);
|
||||
}
|
||||
|
||||
var material = new Material(Shader.Find(ShaderName));
|
||||
if (i < 0 || i >= parser.GLTF.materials.Count)
|
||||
{
|
||||
return MaterialFactory.CreateMaterial(i, null, ShaderName);
|
||||
material.name = MaterialFactory.MaterialName(i, null);
|
||||
return material;
|
||||
}
|
||||
|
||||
var src = parser.GLTF.materials[i];
|
||||
var material = MaterialFactory.CreateMaterial(i, src, ShaderName);
|
||||
material.name = MaterialFactory.MaterialName(i, src);
|
||||
var standardParam = default(TextureImportParam);
|
||||
if (src.pbrMetallicRoughness != null || src.occlusionTexture != null)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,8 @@ namespace UniGLTF
|
||||
}
|
||||
|
||||
var src = parser.GLTF.materials[i];
|
||||
var material = MaterialFactory.CreateMaterial(i, src, ShaderName);
|
||||
var material = new Material(Shader.Find(ShaderName));
|
||||
material.name = MaterialFactory.MaterialName(i, src);
|
||||
|
||||
// texture
|
||||
if (src.pbrMetallicRoughness.baseColorTexture != null)
|
||||
|
||||
Reference in New Issue
Block a user