Create custom asset and add editor window

Hi,

I’m trying to create custom asset with its own editor window.
I have the following code for creating my asset:

[CreateAssetMenu(fileName = "My new asset.myasset", menuName = "Create My New Asset")]
[System.Serializable]
public class MyAsset : ScriptableObject {
	[SerializeField, Multiline]
	public string description;
}

And the following for opening editor window:

[UnityEditor.Callbacks.OnOpenAsset(1)]
public static bool OnOpenAsset(int instanceID, int line)
{
	if (Selection.activeObject as MyAsset != null)
	{
		ShowEditor();
		return true;
	}
	return false;
}

The problem is Selection.activeObject returns null when converted to MyAsset.
Debugging shows that when I select my asset, it is of type DefaultAsset, but other assets like Animation Controller or a Game Scene have the correct types.

I solved it. The problem was here:

[CreateAssetMenu(fileName = "My new asset**.myasset**", menuName = "Create My New Asset")]

I provided my own custom extension for file, which for some reason doesn’t play well with Unity. It only works without custom ‘.myasset’ extension.