鏡とスイッチの実装方法
手順1
下の記事を参考にして地面(Plane)だけのワールドを作成する。
手順2
「Assets」フォルダ内の「VRChat Examples>Prefabs>VRCMirror」をシーンビューにドラッグ&ドロップする。

手順3
「手順2」で追加した「VRCMirror」をヒエラルキーで選択し、インスペクターの Transform コンポーネントで位置や角度、大きさを調整する。


手順4
ヒエラルキーの空いているスペースで右クリックし、「3D Object」から「Cube」を選択する。


手順5
「手順3」と同じ方法で作成した「Cube」の位置や角度、大きさを調整する。
今回は「手順4」で作成した「Cube」を「MirrorSwitch」に名前を変更している。

手順6
「手順4」で作成した「Cube」をヒエラルキーで選択した状態でインスペクターの下の「Add Component」を押し、検索枠に「Udon」と入力して「Udon Behaviour」コンポーネントを追加する。


手順7
「手順6」で追加した Udon Behaviour コンポーネントの「New Program」を押す。

手順8
数秒ほど待った後、「手順6」で追加した Udon Behaviour コンポーネントの「Create Script」を押す。

手順9
ダイアログボックスが開き、ファイル名を「MirrorSwitchController」等に変更し、保存先が「Main_UdonProgramSources」になっている事を確認したら「保存」を押す。
ファイル名(スクリプト名)は必ず英語にする。

手順10
「Assets」フォルダ内の「Scenes>Main_UdonProgramSources>MirrorSwitchController」をダブルクリックする。

手順11
Visual Studio が開いたら、下記のように記述する。
using UdonSharp;
using UnityEngine;
public class MirrorSwitchController : UdonSharpBehaviour
{
[SerializeField]
private GameObject objMirror;
//このゲームオブジェクトがプレイヤーに
//選択された際に呼び出される
public override void Interact()
{
//鏡の活性化・非活性化を切り替える
objMirror.SetActive(!objMirror.activeSelf);
}
}
手順12
Unity に戻り、「手順4」で作成した「Cube」をヒエラルキーで選択する。

手順13
ヒエラルキーにある「VRCMirror」をインスペクターの Udon Behaviour コンポーネントの「Obj Mirror」にドラッグ&ドロップする。
この操作を「アサイン」と言う。

手順15
- こちらを参考にしてテストプレイする