Skip to content

Commit 074b2ef

Browse files
authored
Update README examples for custom plugins
1 parent 9a811e7 commit 074b2ef

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ The library is designed to be easy to extend with additional extensions to the g
5757
- [Default Importer Selection](#default-importer-selection)
5858
- [Animation Import](#animation-import)
5959
- [Extensibility](#extensibility)
60-
- [Example for custom plugin](#example-for-custom-plugin)
60+
- [Example for custom export plugin](#example-for-custom-export-plugin)
61+
- [Example for custom import plugin](#example-for-custom-import-plugin)
6162
- [Known Issues](#known-issues)
6263
- [Contributing](#contributing)
6364
- [Unity Package](#unity-package)
@@ -457,7 +458,7 @@ If your plugin reads/writes custom extension data, you need to also implement `G
457458
> [!WARNING]
458459
> `ShouldNodeExport` callback: Using this callback requires understanding of how glTF works. For example, if you filter out some bones of a skeleton on export, the result might not be valid glTF or might not display what you expect. Use with caution
459460
460-
### Example for custom plugin
461+
### Example for custom export plugin
461462
```csharp
462463
public class MyExportPlugin : GLTFExportPlugin
463464
{
@@ -480,6 +481,30 @@ public class MyExportPluginContext: GLTFExportPluginContext
480481
}
481482
```
482483

484+
### Example for custom import plugin
485+
```csharp
486+
public class MyImportPlugin: GLTFImportPlugin
487+
{
488+
public override string DisplayName => "My Import Plugin";
489+
public override string Description => "";
490+
491+
public override GLTFImportPluginContext CreateInstance(GLTFImportContext context)
492+
{
493+
return new MyImportPluginContext();
494+
}
495+
}
496+
497+
public class MyImportPluginContext: GLTFImportPluginContext
498+
{
499+
public override void OnAfterImportScene(GLTFScene scene, int sceneIndex, GameObject sceneObject)
500+
{
501+
// Set all to static
502+
var objs = sceneObject.GetComponentsInChildren<Transform>();
503+
foreach (var obj in objs)
504+
obj.gameObject.isStatic = true;
505+
}
506+
}
507+
```
483508

484509
> 🏗️ Under construction. You can take a look at `MaterialVariantsPlugin.cs` for an example.
485510

0 commit comments

Comments
 (0)