UnityEvent does
How do I make it show in the inspector?
You unfortunately need to do this:
[Serializable]
public class UnityStringEvent : UnityEvent<string> {}
Then declare your variable as a UnityStringEvent
.
Similar to the issue with AssetReference if you’ve ever used Addressables.
Oh good to know thanks.
Is it possible to have something like public class AssetReferenceScene : AssetReferenceT<Scene>
?
I’d like to get the scene name but assetreference return the runtime guid
That’s a good question. Worst case I think you can at least get the address of the addressable (the one you can set in the inspector). Best case… there seems to be a new property in recent versions of Addressables called subObjectName:
https://docs.unity3d.com/Packages/com.unity.addressables@1.13/api/UnityEngine.AddressableAssets.AssetReference.html#UnityEngine_AddressableAssets_AssetReference_SubObjectName
That might give the actual asset name? Haven’t tried it.
subObjectName is always empty
how do I get the address at runtime?
Try the runtimeKey property.
nah, runtimekey is ToString()
public virtual object RuntimeKey
{
get
{
if (m_AssetGUID == null)
m_AssetGUID = string.Empty;
if (!string.IsNullOrEmpty(m_SubObjectName))
return string.Format("{0}[{1}]", m_AssetGUID, m_SubObjectName);
return m_AssetGUID;
}
}
I’m not sure it’s actually possible to get the address back from an AssetReference. I think AssetReferences use GUID as the actual serialized value. The only time I’ve seen the ability to use the address is in Addressables.LoadAssetAsync
, but you provide the address there rather than retrieve it.
It’s strange that subName is nill because
looks like it’s setting it to a string no matter way… I wonder if my version of addressable is broken, lemme upgrade to 1.13.1
nope, even AssetReference to a texture… bah I give up
hey, so how would i convert public UnityEvent<string, string> OnChatMessage; into something that is shown in the inspector?
See the example here: https://docs.unity3d.com/ScriptReference/Events.UnityEvent_2.html
thanks for that I got it to work like this minutes after posting that lol
[Serializable]
public class UnityStringEvent : UnityEvent<string, string> {}
public UnityStringEvent OnChatMessage;
public void SetChatter(string pChatter) { chatterName.text = pChatter; }
lmao @okaybj i just came here from pablopoon’s tutorial with the same exact problem, thanks for posting the solution … the internet is just a series of cracks, and we’re just droplets of water i guess.