Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Using Visual Studio to Find Whether a Method is Referenced in Inspector

Discussion in 'Code Editors & IDEs' started by liquify, Feb 6, 2022.

  1. liquify

    liquify

    Joined:
    Dec 9, 2014
    Posts:
    187
    For example, a UnityEvent is used to refer to a public method (e.g. the methodname is OnAlertTriggerChange) in the Inspector:

    upload_2022-2-6_20-40-46.png

    Is there a way to detect that Inspector reference with Visual Studio?

    upload_2022-2-6_20-43-7.png
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,947
    Nope. Visual Studio has no idea about this kind of reference, which is achieved via reflection.
     
    liquify likes this.
  3. Pepn

    Pepn

    Joined:
    Sep 27, 2017
    Posts:
    10
    Honestly one of the biggest downsides of navigating a big project. The more stuff is serialized the harder it is to find where some functionality is. Is there any way this could be improved via some visual studio add-on or smth?
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,947
    I do believe the Rider integration is aware of this kind of reference, and the newest VS integration might be too, it's been a while since I used VS now.
     
  5. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,694
    Rider is not only capable of it but comes with it enabled by default. You can even see that it's tracking the value of the field in my screenshot.

    upload_2023-6-24_13-16-44.png

    I'm less familiar with VS for the same reason but from what I've heard you can't. Of course even if you could you wouldn't be able to do it with the free VS Community. You'd have to pay for VS Professional or VS Enterprise as references shown via CodeLens aren't available in the free tier.

    https://forum.unity.com/threads/visual-studio-get-the-references-of-a-fonction-in-the-scene.1252473/
     
    Last edited: Jun 24, 2023
    liquify likes this.