mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-27 21:34:38 -05:00
how_to_customize_material_import
This commit is contained in:
@@ -97,19 +97,7 @@ async RuntimeGltfInstance Load(GltfData data)
|
||||
|
||||
### materialGenerator で URP 用のマテリアルをロードする
|
||||
|
||||
`materialGenerator` 引き数(省略可能)を指定することで URP マテリアルを生成するようにカスタムできます。
|
||||
|
||||
```csharp
|
||||
async RuntimeGltfInstance Load(GltfData data)
|
||||
{
|
||||
var materialGenerator = new GltfUrpMaterialDescriptorGenerator();
|
||||
using(var loader = new UniGLTF.ImporterContext(data, materialGenerator: materialGenerator)
|
||||
{
|
||||
var instance = await loader.LoadAsync();
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
```
|
||||
{doc}`Import 時に生成される Material をカスタマイズする </gltf/how_to_customize_material_import>`
|
||||
|
||||
## 3. インスタンスを使用する
|
||||
|
||||
|
||||
21
docs/gltf/how_to_customize_material_import.md
Normal file
21
docs/gltf/how_to_customize_material_import.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Import 時に生成される Material をカスタマイズする
|
||||
|
||||
`IMaterialDescriptorGenerator` を実装することで import 時に適用されるマテリアルを差し替えることができます。
|
||||
|
||||
## materialGenerator で URP 用のマテリアルをロードする
|
||||
|
||||
URP マテリアルを生成するようにカスタムする例です。
|
||||
|
||||
<https://github.com/vrm-c/UniVRM/issues/1214>
|
||||
|
||||
```csharp
|
||||
async RuntimeGltfInstance Load(GltfData data)
|
||||
{
|
||||
IMaterialDescriptorGenerator materialGenerator = new GltfUrpMaterialDescriptorGenerator();
|
||||
using(var loader = new UniGLTF.ImporterContext(data, materialGenerator: materialGenerator)
|
||||
{
|
||||
var instance = await loader.LoadAsync();
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -12,7 +12,12 @@
|
||||
:maxdepth: 1
|
||||
|
||||
0_82_glb_import
|
||||
how_to_impl_extension
|
||||
how_to_customize_material_import
|
||||
0_36_update
|
||||
format
|
||||
```
|
||||
|
||||
```{toctree}
|
||||
:maxdepth: 1
|
||||
format
|
||||
how_to_impl_extension
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user