Open5

VRChat UdonSharp

kanonjikanonji

UdonSharpで出来る事、出来ない事

出来る事

  • const
  • C# property
    • 当初は使えなかったはずだけど、使える様になった。
    • 恐らくはOnValueChangedの為に?でもOnValueChanged関係なく使える。
    • public bool IsOk => this.foo ? true: false; こういうのも書ける。
  • private readonly
  • 継承
    • UdonSharpBehaviourを継承した自作クラスを、更に継承出来る様になった。

出来ない事

  • コルーチン
  • Static method
  • struct
  • enum
    • VRChat SDKとかに元からあるenumを使う事は出来る。
  • method overload
  • throw new Exception();
  • RequireComponent(typeof(Foo))
    • Fooをアタッチするとこは機能するが、この記述があるとtypeofでCompile error
  • Awake()
  • new GameObject()
    • UdonSharp 1.1.8
  • this.foo?.bar
    • UdonSharp does not currently support node type 'ConditionalAccessExpression'
    • UdonSharp 1.1.8
  • Action foo = () => this.gameObject.SetActive(true);
    • UdonSharp does not currently support node type 'ParenthesizedLambdaExpression'
    • VRChat SDK - Worlds 3.4.0
kanonjikanonji

UdonSynced関連

  • Late joinerが入るとデシリアライズするが、remoteのownerのとこでシリアライズはしない。
    • つまり、入場時点でシリアライズ済みのものがでシリアライズされる。
    • 入場時に最新を明示的に同期したい場合、owner環境のOnPlayerJoined()でlate joinerが来る度RequestSerialization()を呼ぶ必要があるかも。
  • Late joinerが入ると、late joiner環境では既にワールドに居た人達の分のOnPlayerJoined()と、自分自身の分のOnPlayerJoined()が呼ばれる。
    • 自分自身のOnPlayerJoined()は、入場をトリガーとするOnDeserialization()より1フレーム早いので、まだUdonSyncedが同期されていない。
  • Ownerがワールドを出る際にシリアライズは行われない。
    • Owner環境でUdonSyncedに変更したけどまだシリアライズしてない場合、ownerがワールドを出たら失われる。
  • RequestSerialization()はowner環境で呼んだ場合にのみ機能する。
    • This will only function if the UdonSharpBehaviour is set to Manual sync mode and the person calling RequestSerialization() is the owner of the object.

    • Late joinerが入場した時のOnPlayerJoined(player)で、引数のplayerがownerだとしても、localのプレイヤーがownerでは無いので機能しない。