Why does "Find References In Scene" return irrelevant results?

Since I started using Unity I have always dreaded using “Find References In Scene” for the particular reason that it always returns piles of apparently unrelated objects.

If I have a single script placed on a single component and then click on “Find References In Scene” for that script I see >35 results returned. I can not for the life of me see any logic behind it all…

Why does “Find References In Scene” not return the objects that have the component directly attached?

What do the other results represent??

How do I filter the results to show only objects that directly reference a component?

3 Likes

Bump - This keeps happening to me. It does not make any sense and I would really like to solve the issue so I can find components in my scene without having to sift through many unrelated objects.

What is the reasoning behind Unity returning objects that do not even reference the component I am searching for? Anyone?

1 Like

Bump - Please can someone help me find an answer as to why “Find References In Scene” is returning hundreds of results when I am sure there is only one gameobject with a specific component in my scene???

I am clueless why Unity’s search is so apparently broken, what is the reasoning for matching hundreds of gameobjects when the desired component is attached to only a single gameobject in the scene??

Are there any alternative search methods which yield the actual gameobjects that “Reference” a component type in the scene, and not include any “reference of reference” or “reference of reference of references” and so on…???

It’s often less difficult for me to just expand an entire hierarchy and manually start digging into each branch!!

1 Like

What version of Unity are you using? What platform? Can you post a screen capture of what the scene and the hierarchy views look like when you use that feature?

Bump - I am encountering the same issue. I do no want any “reference of reference” or “reference of reference of references”.

8951490--1228980--CaptureREFERENCES.JPG

2 Likes

Hi @SI_007 ,

By default Find reference from scene finds all dependencies recursively. Not just the direct reference.

If you want to only find direct references here are 2 workarounds:

1- Use the SearchWindow: (in 21.3, the search window uses textual query, in 22.1++ you can use a Visual query builder)

8962764--1231425--upload_2023-4-20_13-7-20.png

8962764--1231428--upload_2023-4-20_13-7-26.png

The textual corresponding query would be:
h: ref=“Assets/Editor/Content/Cube_42.prefab”

8962764--1231431--upload_2023-4-20_13-8-4.png

Alternatively you can go to Unity preference page, select the Search preferences:
8962764--1231434--upload_2023-4-20_13-9-33.png

Ensure that you scene used the Advanced search engines (which means it will use the same search engine as the Search Window so will will only get direct references).

8962764--1231437--upload_2023-4-20_13-10-43.png

Thanks for your feedback.

8 Likes

@sebastienp_unity what about component references? when I select advanced option, finding references return nothing. Is this intended or a bug?

Thanks, @sebastienp_unity , I was also running into the issue of finding too many search results. However I am not running into a new minor annoyance. When I right click on a component and select “Find References In Scene”, the search terms will have a trailing “:” symbol that causes the search to fail. I need to manually delete the extra character for the search to work.

You can see in the example below, Unity generated the search ref:54322:, but I had to remove the final : to get it to show results.
9181979--1279157--Screenshot 2023-07-30 at 9.30.13 AM.png 9181979--1279160--Screenshot 2023-07-30 at 9.30.21 AM.png

1 Like

That really makes no sense - why by default do you want to see all objects related to the object that ACTUALLY REFERENCES what you searched for?!
Please consider changing the default

2 Likes

A very common use case is for me to want to see if a game object in the hierarchy can be deleted without breaking anything else. Using “find references in scene” with the classic search, I get way too much information and cannot tell whether the results are actually referencing the object or not. With the advanced search, I don’t get any results unless I specifically search for references to the exact component that’s being referenced on the exact child that’s being referenced, which is tricky if the game object has many children. Is there any way to get the actual information I need?

Hi @TharosTheDragon ,

You are right that the Find Reference in Scene FROM the Hierarchy does a search using instance id in hierarchy:

image

You are also right that from the Inspector, you can right click on a specific field and see if there are references to the specific asset in the object field:

image

There might be a way to do what you want using the Dependency Viewer (which is part of a package on public github: GitHub - Unity-Technologies/com.unity.search.extensions: This package contains a bunch of examples, samples and queries to be used with Unity Search.).

Before I suggest a workflow to help with your problem I just want to clarify what you are trying to do:

  • You want to delete an object in your hierarchy
  • You want this deletion to be safe so you want to know if any objects within the Hierarchy itself is using (through a GameObject reference) the object to be deleted (or any of its component).

Is that it?

Also just a clarification: if you run “Find Reference In Scene” on the hierarchy, you were saying that the data you are seeing is not precise enough? Because the results of what is shown should be exactly what you are loking for: a list of GameObject using the RightClicked object or any of its component.

I just want to better understand why you feel the resulting data is not enough to take the decision to delete the object.

Thanks,

Sebastien

  • You want this deletion to be safe so you want to know if any objects within the Hierarchy itself is using (through a GameObject reference) the object to be deleted (or any of its component).

I want to know if any objects within the Hierarchy itself are referencing the object to be deleted or any of its components or any of its children or any of their components.

Also just a clarification: if you run “Find Reference In Scene” on the hierarchy, you were saying that the data you are seeing is not precise enough? Because the results of what is shown should be exactly what you are loking for: a list of GameObject using the RightClicked object or any of its component.

Maybe you haven’t seen this before yourself, but as can be seen in this thread it’s a common experience to get many results that don’t seem relevant. Maybe the objects in the results do reference the object I’m searching about in a roundabout way, but the search does not specify how so I can’t tell how important the reference is.

After I made my reply, I’ve begun dealing with the problem using a package called Asset Usage Detector.

Thanks for the clarification @TharosTheDragon.

Currently the only solution I can propose is for you to try the Dependency Viewer in this package:

This package can be use to track dependencies at multiple depth level. That said, this is still a prototype package, so use it at your own risk. We are evaluating when we should make this a proper Unity workflow.

I will look at Asset Usage Detector. This is a tool I did not know about. Do you feel it is a good Dependency management tool?

Yes, it’s working well so far

Ok, so the functionality that is common sense requires a hacky workaround, and the useless functionality that doesn’t make any sense is the default. Thanks! role model in engineering and customer obsession :smiley: