Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. 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:
    172
    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,724
    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:
    9
    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,724
    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:
    20,137
    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.