all green

プログラム、アプリ作成、Web等備忘録が中心です

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

続きを読む

Node.jsのダウングレード(nvmを利用したバージョン切替)と切り替え時のnpmのエラー対応

最新版のNodeJSでは問題があり、ダウングレードを行った際の
手順、問題についての対応メモです。

・環境
Windows 10 Pro
Node.js v18.12.0
npm 8.19.2

続きを読む

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)

続きを読む

Photoshopのスクリプトで書き出したPNGファイルのサイズが大きすぎる場合の対応

スクリプトPNGファイルの書き出しを行っていたところ
あまりにもファイルサイズが大きくなりすぎるため色々調べてみた。


・環境
Photoshop CC v22.3.1

続きを読む