Skip to content

Commit 6bc1626

Browse files
committed
Added AssociatedAsset property to CustomAssetMetadata class
1 parent ca061ba commit 6bc1626

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

Runtime/Baseclass/CustomAssetMetadata.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,21 @@
55
public abstract class CustomAssetMetadata : ScriptableObject
66
{
77
// Keep a reference to our original asset so we can hook them up the moment we find the asset
8-
[HideInInspector, SerializeField] internal LazyLoadReference<UnityEngine.Object> reference;
8+
[HideInInspector, SerializeField] internal LazyLoadReference<UnityEngine.Object> reference;
99

10-
// These methods are to handle creating and destroying metadata in the editor and not leave the asset dangling
11-
[Conditional("UNITY_EDITOR")] private void OnEnable() { if (Application.isEditor && reference.isSet && !reference.isBroken) MetadataLookup.Register(reference, this); }
10+
// These methods are to handle creating and destroying metadata in the editor and not leave the asset dangling
11+
[Conditional("UNITY_EDITOR")] private void OnEnable() { if (Application.isEditor && reference.isSet && !reference.isBroken) MetadataLookup.Register(reference, this); }
1212
[Conditional("UNITY_EDITOR")] private void OnDisable() { if (Application.isEditor && reference.isSet && !reference.isBroken) MetadataLookup.Unregister(reference, this); }
1313

14-
public virtual void OnReset() { }
14+
public UnityEngine.Object AssociatedAsset
15+
{
16+
get
17+
{
18+
if (!reference.isSet || reference.isBroken)
19+
return null;
20+
return reference.asset;
21+
}
22+
}
23+
24+
public virtual void OnReset() { }
1525
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.custom_asset_metadata",
33
"displayName": "Custom Asset Metadata",
4-
"version": "1.2.0",
4+
"version": "1.2.1",
55
"unity": "2020.3",
66
"description": "Adds the ability to store meta data on Assets",
77
"license": "MIT",

0 commit comments

Comments
 (0)