以下の内容はhttps://baba-s.hatenablog.com/entry/2024/03/04/202835より取得しました。


【Unity】InvalidOperationException: Could not execute the method because the containing type 'XXXX', is not fully instantiated.

概要

public static class Example<T>
{
#if UNITY_EDITOR
    [UnityEditor.InitializeOnEnterPlayMode]
    public static void InitializeOnEnterPlayMode()
    {
    }
#endif
}

ジェネリックな static クラスで InitializeOnEnterPlayMode を使用すると

InvalidOperationException: Could not execute the method because the containing type 'XXXX', is not fully instantiated.

上記の例外が発生します

using UnityEngine;

public static class Example<T>
{
    [RuntimeInitializeOnLoadMethod]
    private static void RuntimeInitializeOnLoadMethod()
    {
        Debug.Log( typeof( T ).Name );
    }
}

InitializeOnEnterPlayMode の代わりに
RuntimeInitializeOnLoadMethod を使用する場合は、
RuntimeInitializeOnLoadMethod を適用した関数は呼び出されません




以上の内容はhttps://baba-s.hatenablog.com/entry/2024/03/04/202835より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14