#OnOpenAsset

1 messages · Page 1 of 1 (latest)

latent merlin
#

You didn't fully read the example code, or at least understand it.

OnOpenAsset goes on static methods. It does not matter what class they are in.

Why would you do anything in InitializeOnLoad?

feral abyss
#

last post

latent merlin
#

As the example code shows, you would get the object that is being opened with
var targetObject = EditorUtility.InstanceIDToObject(instanceID);
Then check the type
bool isMyType = targetObject.GetType() == typeof(MyType);

feral abyss
#

ah so that function is called when any asset is opened?

latent merlin
#

Yes

feral abyss
#

oh i get it now

#

that makes everythign much easier. thank you so much!