When wiring up Animation Events to call a Scripts Method, Rider displays these methods as unused.
Below is an image displaying the basic setup:
_The GameObject: LevelComplete has the Script: LevelComplete.cs attached to it. Then the LevelComplete.anim has an Event configured to call the LevelComplete.LoadNextLevel method._
_Note: In order to test this, the Script must be attached to the same GameObject as the Animation._

Example Navigation path details (Scene.GameObject -> Script & -> AnimationController -> Animation -> Event).
_Within the Scene is a GameObject that has an Animator component, which references the Animation Controller file, and has a MonoBehaviour component, which references the C# file that contains the Method the Animation Event triggers._
_Then in the Animation Controller you find the Animation(s) via the Animator State Machine._
_Finally, in the Animation you can have Events that can call Methods from any Script attached to the same GameObject as the Animation Controller._
Scene source:
--- !u!1 &405512269
GameObject:
m_Component:
- component: {fileID: 405512273}
- component: {fileID: 405512274}
m_Name: LevelComplete
--- !u!95 &405512273
Animator:
m_GameObject: {fileID: 405512269}
m_Controller: {fileID: 9100000, guid: 550ca101b7e507741b7d10d6ba8205db, type: 2}
--- !u!114 &405512274
MonoBehaviour:
m_GameObject: {fileID: 405512269}
m_Script: {fileID: 11500000, guid: bfaf5f13a5408ca44998ad75a16385fd, type: 3}
Animation Controller source:
--- !u!91 &9100000
AnimatorController:
m_Name: LevelComplete
m_AnimatorLayers:
m_StateMachine: {fileID: 1107805188659273550}
--- !u!1102 &1102957877984942184
AnimatorState:
m_Name: LevelComplete
m_Motion: {fileID: 7400000, guid: c559b4dac572ed548bc3d371da1dd836, type: 2}
--- !u!1107 &1107805188659273550
AnimatorStateMachine:
m_ChildStates:
m_State: {fileID: 1102957877984942184}
Animation source:
--- !u!74 &7400000
AnimationClip:
m_Name: LevelComplete
m_Events:
functionName: LoadNextLevel
Assumed logic to determine if a Method may be used by an Animation Event:
GameObject has Animator and MonoBehaviour componentsAnimator -> Animation(s) contains Events. _Loop on all States to check for Events_Animation Event function name(s) exist in the Script attached to the GameObject_Note: It may be much easier to determine this, by just the method name, though Events can trigger Unity methods as well, so if those names are the same it would be false positives._
We're looking at a solution, hopefully we can have something in place for Rider 2018.2
Note that a workaround was added for 2018.2, which will mark any method or property that could be used as an event handler, or set by Unity as in use. This means any public static method or property setter in a Unity derived type. This is not very accurate, as it doesn't show if a method is actually being used, but is good enough to remove the false reports. This issue remains open to track a more accurate implementation.
Now that YAML support is added:
.anim to list of asset files being processed for referencesfunctionName and objectReferenceParameter (method usage + class usage respectively)Example .anim file:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Level
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings: []
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_GenerateMotionCurves: 0
m_Events:
- time: 0
functionName: LoadNextLevel
data:
objectReferenceParameter: {fileID: 11500000, guid: 8b3afbb5c1774f8680bd0071afe5267f,
type: 3}
floatParameter: 0
intParameter: 0
messageOptions: 0
@citizenmatt When this is fixed, will this also fix normal Unity Event Handlers? e.g. I've a script with public void HandleClick(). This method is than used in a Button Click Handler (set via Inspector UI). Rider marks this as unused as well.
Oh, I've seen that in this issue #263 that it should be possible, which seems not to be the case anymore?
Standard event handlers should already work. What Rider version are you using, and what file is the handler being referenced from (scene, prefab, etc.)?
Any news about when this is going to be fixed? I'm using Rider 2019.3
Any updates?
Looks like this is still an open ticket. As a sloppy workaround, I denote animation events in a region, but it would be great if Rider can show the anims to which they belong.
Hey folk! It's implemented and it will be available in the closest Rider 2021.1 EAP. Here are all implemented functionality:
https://youtrack.jetbrains.com/issue/RIDER-43464
https://youtrack.jetbrains.com/issue/RIDER-43338
https://youtrack.jetbrains.com/issue/RIDER-17449
PR: https://github.com/JetBrains/resharper-unity/pull/1982
Most helpful comment
Any news about when this is going to be fixed? I'm using Rider 2019.3