So I have the following asset class defined:
[Serializable]
public class PuzzleAsset : ScriptableObject
{
public byte Width;
public byte Height;
public byte Depth;
public byte Difficulty;
}
I create one using the following code executed from a button click:
private void Save()
{
var assetFilePath = @"Assets\Puzzle\Assets\" + Mesh.name;
var asset = ScriptableObject.CreateInstance<PuzzleAsset>();
asset.name = Mesh.name;
asset.Width = (byte)Width;
asset.Height = (byte)Height;
asset.Depth = (byte)Depth;
asset.Difficulty = 0;
AssetDatabase.CreateAsset(asset, assetFilePath);
AssetDatabase.SaveAssets();
}
This works as there is an asset file created in Unity. My problem is I want to be able to assign one of the assets to a property in another class like so:
public PuzzleAsset Asset;
This field is exposed in the editor but it will not allow me to drag/drop an asset to that property. What am I doing wrong here?
Thanks,
-jeff