mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-10-02 15:53:30 -05:00
ScriptedImporter のメモ書き
This commit is contained in:
1
.github/workflows/sphinx.yml
vendored
1
.github/workflows/sphinx.yml
vendored
@@ -17,6 +17,7 @@ jobs:
|
||||
- run: pip install sphinx-rtd-theme
|
||||
- run: sudo apt install gettext
|
||||
- run: pip install sphinx-intl
|
||||
- run: pip install gitinclude
|
||||
- name: sphinx build(ja)
|
||||
working-directory: ./docs
|
||||
run: sphinx-build . ../public/ja
|
||||
|
||||
3
docs/_static/custom.css
vendored
Normal file
3
docs/_static/custom.css
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.wy-nav-content {
|
||||
max-width: 1200px !important;
|
||||
}
|
||||
@@ -25,7 +25,7 @@ author = 'VRM Consortium'
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = ['myst_parser']
|
||||
extensions = ['myst_parser', 'gitinclude']
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
@@ -8,4 +8,5 @@ texture_manipulation
|
||||
coordinate
|
||||
fast_spring_bone
|
||||
first_person
|
||||
scripted_importer
|
||||
```
|
||||
|
||||
39
docs/implementation/scripted_importer.md
Normal file
39
docs/implementation/scripted_importer.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# ScriptedImporter の実装
|
||||
|
||||
`v0.68.0` 以降 の `glb/gltf editor importer` と `VRM-1.0 editor importer` の実装で使用している [ScriptedImporter](https://docs.unity3d.com/ja/2019.4/ScriptReference/Experimental.AssetImporters.ScriptedImporter.html) に関して。
|
||||
|
||||
> `VRM-1.0` の実装と拡張子がぶつかってしまうので `VRM-0.x` への `ScriptedImporter` 実装はしません
|
||||
|
||||
## ScriptedImporter 採用の利点
|
||||
|
||||
### Texture の Asset化 が楽
|
||||
|
||||
`AssetPostprocessor` だと普通の方法では実装できない Texture のバイト列を出力して Asset 化して、
|
||||
これを参照する Material をアセット化するということが、
|
||||
`ScriptedImporter.GetExternalObjectMap` により無理をせずに実装できます。
|
||||
|
||||
> UniVRM では抜け道として `EditorApplication.delayCall` を使用しています。
|
||||
|
||||
### Import 設定を作れる
|
||||
|
||||
`ScriptedImporter` を継承したクラスの `public member` や `[SerializeField]` に情報を保存できます。
|
||||
|
||||
```cs
|
||||
// 例
|
||||
[ScriptedImporter(1, "cube")]
|
||||
public class CubeImporter : ScriptedImporter
|
||||
{
|
||||
public float m_Scale = 1; // これを Asset の Inspector で変更して Apply すると、新しい設定で再importできる
|
||||
|
||||
// 省略
|
||||
}
|
||||
```
|
||||
|
||||
### ForceText 時に import が低速化するのを回避できる
|
||||
|
||||
`ScriptedImporter` の SubAsset にすることで、 `mesh` などがテキスト(yaml)で Asset 化されることを回避できます。
|
||||
巨大なアセットで差が出ます。
|
||||
|
||||
## ScriptedImporter 実装
|
||||
|
||||
TODO: ExternalObjectMap の扱い
|
||||
@@ -1,3 +1,10 @@
|
||||
# SimpleViewer
|
||||
|
||||
Runtime ローダーのサンプルです。
|
||||
|
||||
```{gitinclude} c89e Assets/VRM_Samples/SimpleViewer/ViewerUI.cs
|
||||
:language: csharp
|
||||
:linenos:
|
||||
:caption:
|
||||
:emphasize-lines" 434-485
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user