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

C# How to find origin of missing reference?

Discussion in 'Scripting' started by traderain, Aug 5, 2015.

  1. traderain

    traderain

    Joined:
    Jul 7, 2014
    Posts:
    108
    Hi, I would like to know that how can i get the origin of the missing reference exception.
    I know that if i double click on it it shows which object but it only spawns during runtime and due to the size of the project i can't really examine all the work others have done.
    Error:
    Code (CSharp):
    1. Script attached to 'Timers' in scene '  ' is missing or no valid script is attached.
    2. UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
    3.  
    Is there a way to figure out "How" timers spawn? If i use search in files there is no evidence about this so i have no clue.
    Thanks for reading.
     
    Last edited: Aug 6, 2015
  2. traderain

    traderain

    Joined:
    Jul 7, 2014
    Posts:
    108
    Is this possible in unity?
     
  3. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    If it's instantiated through code, probably not. If you're trying to locate which objects like prefabs are missing scripts though, there's an excellent editor extension script called "FindMissingScriptsRecursively" that I've found quite helpful in the past. Maybe you'll get lucky.
     
    DavidZobrist likes this.
  4. traderain

    traderain

    Joined:
    Jul 7, 2014
    Posts:
    108
    Thanks for the reply. I already knew about the extension but its sadly instantiated throught code.
     
  5. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    You can try to use my helper code (check out this post: www.tallior.com/fixing-missing-references/)
    I don't know how it compares to the other one shown, but it can also go over all scenes in your game and analyze them for missing references.

    Of course it cannot handle all edge cases such as things that are dynamically created at runtime (e.g: through code) but it may help you find the issue.