OK, I have no idea what’s going on here. Here’s the code:
if( s_Instance == null )
{
string assetPathAndName = GeneratePath();
// Check the asset database for an existing instance of the asset
T asset = null;
asset = AssetDatabase.LoadAssetAtPath( assetPathAndName, typeof( ScriptableObject ) ) as T;
// If the asset doesn't exist, create it
if( asset == null )
{
asset = ScriptableObject.CreateInstance<T>();
AssetDatabase.CreateAsset( asset, assetPathAndName );
AssetDatabase.SaveAssets();
}
s_Instance = asset;
}
Basically, this is part of a generic Singleton class that’s supposed to store a single instance of a class as an asset in Unity. The problem is, whenever I restart Unity the if( s_Instance == null ) part fails, even though s_Instance is null when I step through this!
This class derives from ScriptableObject like so:
public class SingletonScriptableObject<T> : ScriptableObject where T : ScriptableObject
{
private static T s_Instance = null;
...
Soooo, what the hell?
-D