1行でdelegateをnullチェックする(C# null 条件演算子)
UnityAction等のdelegateのnullチェックをしないで使ってしまいよく発生するエラー
Object reference not set to an instance of an object
null 条件演算子でチェックする
public class ListItem: MonoBehaviour, IPointerClickHandler { public UnityAction<int> OnClick; public int Id { get; private set; } public void OnPointerClick(PointerEventData eventData) { OnClick?.Invoke(Id); } }
null 条件演算子メンバー アクセスと null 条件演算子と式: - C# | Microsoft Learn
・環境
Unity 2022.3.11f1
Project Settings
Api Compatibility Level* : .NET Framework
MessagePipeのイベント登録でRegisterMessageBrokerを使用しない形で実装する
LifetimeScope.Configure内で行うイベントの登録がどうにかならないかなと思って調べたときのメモ
SampleLifetimeScope
protected override void Configure(IContainerBuilder builder) { // MessagePipeの設定 var options = builder.RegisterMessagePipe(); builder.RegisterMessageBroker<EventA>(options); builder.RegisterMessageBroker<EventB>(options); builder.RegisterMessageBroker<EventC>(options); ↑これをなんとかしたい }
・環境
Unity 2022.3.11f1
VContainer 1.13.2
MessagePipe 1.7.4
VSCodeのESLintで発生するキャメルケースのチェックエラーを無効化する(Identifier 'Hoge' is not in camel case.eslint@typescript-eslint/camelcase)
「Identifier 'Hoge' is not in camel case.eslint@typescript-eslint/camelcase」
エディタ上で表示されるエラーを無効化したときのメモ
・環境
Visual Studio Code 1.75.1
ESlint v2.4.0
GitのClone時に発生したエラー「 RPC failed; curl 92 HTTP/2 stream 7 was not closed cleanly before end of the underlying stream」
Cloneした際に発生したエラーの対応
発生したエラー
error: RPC failed; curl 92 HTTP/2 stream 7 was not closed cleanly before end of the underlying stream error: 17554 bytes of body are still expected fetch-pack: unexpected disconnect while reading sideband packet fatal: early EOF fatal: fetch-pack: invalid index-pack output
・環境
Windows10
Fork 1.71.00(https://fork.dev/)
Git(2.33.1.windows.1)