Programming in VRChat

VRChat でのプログラミングについて調べたことの書き溜め

YAML Asset Browser

An editor extension for browse YAML formatted asset of Unity. You can check asset contents comparing with YAML formatted text.

in Japanese: Unity の YAML 形式のアセットを閲覧するエディタ拡張。 YAML 形式のテキストと比較しながらアセットの内容を確認できる。

f:id:naqtn:20190904091825p:plain f:id:naqtn:20190903210742p:plain

README (English)

Open asset file

  • 1: Your project has to use "Force Text" asset serialization setup

    • If you are not sure, check Unity menu > Edit > Project Settings > Editor Settings > Asset Serialization.
    • (Reference: EditorManager in Unity manual ) f:id:naqtn:20190903210843p:plain
  • 2: Open YAML Asset Browser window from Unity menu

    • Unity menu > Window > VRC_Iwsd > Yaml Asset Browser
  • 3: Select an asset object in Project window as usual Unity operation
  • 4: Press "Load" button on toolbar of YAML Asset Browser
    • Then you'll see the tree structure and YAML text of the asset

f:id:naqtn:20190903212508p:plain

  • You can also drag and drop resource file to asset path field
    • You can drag and drop from outside of Unity Editor (using File Explorer on Windows, Finder on Mac (though I don't test it))
    • You can drag scene object from Hierarchy window to see scene asset file
  • If you select a prefab instance in Hierarchy window, YAML Asset Browser loads that prefab
  • If selected object is not related asset, nothing will happen.
  • YAML Asset Browser loads asset file independently from Unity editor. So editing asset doesn't affect to YAML Asset Browser view. To update, you have to reload manually.
  • Each time you select menu, new window will be shown up.
    • Each window does loading independently

Browse

  • Tree view shows asset structure
    • For scene file, you can browse not only GameObject hierarchy but also non-component objects (e.g. LightmapSettings, RenderSettings)
    • TODO: Prefab instances in scene file are not well located in the tree. They are placed in "Others" folder temporarily.
    • TODO: build better hierarchy for animation controller
  • Each tree item has "line xxx" text. This is line number of where the item comes in YAML formatted asset file.
    • If click tree item, then YAML text scrolls to that line
  • Search text input field on toolbar filters tree item by its text matching

f:id:naqtn:20190903215821p:plain

Search

  • Search by fileID (Local Identifier in file)
    • Input "fileID" to search element in the asset
    • Result is shown in text area below
    • If "and select it" is checked, found tree item will be selected.
    • (Hint: You can use double click YAML text to select fileID value and copy from context menu. (parts marked green in following capture))

f:id:naqtn:20190903221902p:plain

  • Search by GUID
    • Input GUID value to search reference target to another asset

f:id:naqtn:20190903223821p:plain

  • Search by fileID and GUID
    • Input fileID and GUID to search reference target in another asset
    • query string format is like "fildID:xxxx guid:xxxx". Extra characters will just be ignored.

f:id:naqtn:20190903225010p:plain

Supported file type and extensions

YAML Asset Browser checks file extension to determine whether it's readable or not. Here's readable asset file type and its extensions.

  • prefab (.prefab)
  • scene (.unity)
  • animation controller (.controller)
  • animation (.anim)
  • material (.mat)
  • render texture (.renderTexture)
  • scriptable object (.asset)
    • You have to drag and drop to load for this type

Known issues

  • Prefab instances (in scene file) are not appears in GameObject hierarchy tree.
  • Stripped prefab in scene file is not handled well
    • (Stripped prefab seems relate to delete child element from prefab. I have to investigate more.)

README (日本語)

アセットファイルを開く

  • 1: プロジェクトの「asset serialization」の設定が「Force Text」になっている必要がある

f:id:naqtn:20190903210843p:plain

  • 2: Unity メニュー から YAML Asset Browser のウィンドウを開く
    • メニュー > Window > VRC_Iwsd > Yaml Asset Browser
  • 3: 通常の Unity 操作と同じように、Project ウィンドウでアセットを選択する
  • 4: YAML Asset Browser のツールバーにある "Load" ボタンを押す
    • アセットの木構造YAML 形式のテキストが表示される

f:id:naqtn:20190903212508p:plain

  • リソースファイルを、アセットパス(path)欄にドロップしてもよい
    • Windowsエクスプローラからのドロップもできる。(Mac の Finder も使えると思うがテストしていない)
    • Hierarchy ウィンドウからシーンをドロップすることもできる
  • Hierarchy ウィンドウでプレハブのインスタンスを選択すると、そのプレハブをロードする
  • 選択したオブジェクトがアセットに関連づいていない場合は何も起きない
  • YAML Asset Browser は Unity エディタとは独立してアセットファイルを読み込む。 このためアセットを編集しても YAML Asset Browser のビューには反映されない。 更新するには手動で再度ロードする必要がある。
  • メニューを選択するたびに新しいウィンドウが表示される。
    • それぞれのウィンドウは独立してロードを行う

閲覧する

  • ツリーはアセットの構造を表示する
    • シーンファイルでは、GameObject だけではなく、LightmapSettings, RenderSettings などの Component ではないオブジェクトも閲覧可能
    • TODO: シーン中のプレハブ・インスタンスはツリーの中で上手く位置づけられていない。"Others" の中に収められている。
    • TODO: アニメーション・コントローラでの適切な木構造作成(は未実装)
  • ツリー中のそれぞれのアイテムには "line xxx" のような表示がされる。これはその要素が YAML 形式のアセットファイルのどの行から来たのかを表示している
    • アイテムをクリックすると、YAML テキストがその行を表示するようにスクロールする
  • ツールバー上の入力欄は、テキスト一致でツリー表示をフィルターする

f:id:naqtn:20190903215821p:plain

検索する

  • fileID での検索 (Local Identifier in file)
    • アセット中の要素を検索するには "fileID" を入力する
    • 検索結果はすぐ下のテキストエリアに表示される
    • "and select it" トグルをオンにしておくと、見つかった要素をツリー中で選択する
    • (ヒント:YAML テキストをダブルクリックすることで fileID の値を選択し、コンテキストメニューからコピーできる。(次のキャプチャで緑の部分))

f:id:naqtn:20190903221902p:plain

  • GUID での検索
    • 他のアセットの参照を検索するには GUID 値を入力する

f:id:naqtn:20190903223821p:plain

  • fileID と GUID での検索
    • 他のアセット中の要素の参照を検索するには fileID と GUID を入力する
    • 検索文字列のフォーマットは "fildID:xxxx guid:xxxx" のようにする。余分な文字は無視される。

f:id:naqtn:20190903225010p:plain

対応ファイル種と拡張子

YAML Asset Browser は拡張子を検査して、読み込めるかどうかを判断している。 以下が対応しているアセットの種類と拡張子である。

  • prefab (.prefab)
  • scene (.unity)
  • animation controller (.controller)
  • animation (.anim)
  • material (.mat)
  • render texture (.renderTexture)
  • scriptable object (.asset)
    • これをロードするにはドラッグ&ドロップの方法を使うこと

既知の問題

  • シーンファイル中のプレハブ・インスタンスが、ツリー上で適切な場所に配置されない
  • シーン中の「Stripped prefab」は上手く扱えていない
    • (「Stripped prefab」はプレハブから子要素を削除することに関係している模様。要調査。)