[Unity] Asset Usage / Event Handler from nested elements not shown in Rider
I happen to notice that when you create a prefab with a monobehaviour that has a public method and then hook it up to a UnityEvent OnClick (UI Button) event that Rider is able to show that it is serialized in one of the prefabs. 1 asset usage is then displayed above the method.
However, whenever I have a prefab where the script is situated at the root but the button as a child and then serialized the method it doesn't show up in Rider as 'asset usage'. It only shows this whenever the script & button are on the same game object.
Is this a bug or intended behaviour? Or can I change the behaviour so it scans the whole prefab for usage.
At this point it confuses me because for any children buttons the method serialized is not shown with any method usage / event handler. I've made mistakes of removing methods / marking them as obsolete even though they're actually in use just Rider not checking the whole prefab for serialized usage.
Looking at the Unity settings "Parse text based asset files for script and event handler usages" is turned on but just doesn't seem to scan the whole prefab. No option to do so either.
Using Rider: 2019.3.2
Please sign in to leave a comment.
Hi Kevin!
Glad to say that nested prefabs are available in Rider EAP. Feel free to try :)
Hi Kevin!
Thank you for contacting us. Could you please provide a small sample solution illustrating issue? You can attach it here or to the new support request via `Help | Contact support`.
Thank you in advance!
It seems the issue lays deeper.
When trying to reproduce there is nothing wrong when the prefab with a child button and a serialized OnClick call to the prefab script holder. Rider does show 1 asset usage. But as soon as the button itself becomes a prefab and then becomes part of another prefab (aka, nested prefabs) then it won't count the nested prefab part.
So it seems that when it is a nested prefab with a serialized OnClick call it won't register because it is an addition and not part of the prefab.
As you can see in this screenshot I have a prefab instantiated with a nested prefab which calls OnChildNestedPrefabClick method, but Rider doesn't show it as 'in use' or 'Event Handler'
For the other cases it does work but it doesn't work with nested prefabs.
Even though opening the prefab as text there is a persistent call value that can be read.
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 2126309945622354628}
- target: {fileID: 5805242741711360226, guid: eabc1867e70aedc418a13cc28ed1a06b,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: OnChildNestedPrefabButtonClick
objectReference: {fileID: 0}
- target: {fileID: 7691123216880206835, guid: eabc1867e70aedc418a13cc28ed1a06b,
type: 3}
propertyPath: m_Name
value: Nested Prefab Button
Here is a link to the Unity project. It is made in Unity 2019.3.1f1
https://maskedmous.stackstorage.com/s/RWLtZcmMtcPupIM
Kevin,
thank you for the details.
Nested prefabs are not supported yet. We have plans to support them in the 2020 release. Please, follow our Rider EAP announcements.
Thank you!