|
| 1 | +.. _doc_orphan_resource_explorer: |
| 2 | + |
| 3 | +Orphan Resource Explorer |
| 4 | +======================== |
| 5 | + |
| 6 | +The Orphan Resource Explorer is a tool designed to help optimize the size of your project |
| 7 | +by identifying resources that lack explicit ownership or are not being used. |
| 8 | + |
| 9 | +Explicit ownership refers to a resource being utilized as a sub-resource or node within |
| 10 | +the project. For instance, a script file is not considered orphaned if it is attached |
| 11 | +to a node. Similarly, if a :ref:`Sprite2D <class_Sprite2D>` node uses an image |
| 12 | +from the project files as a texture, the image will have explicit ownership. |
| 13 | +On the other hand, if a script is created using the FileSystem dock's context |
| 14 | +menu but not attached to a node, it will be classified as an orphan resource. |
| 15 | + |
| 16 | +.. warning:: This tool will only search for ownerships set through the interface, |
| 17 | + not through the code. |
| 18 | + |
| 19 | +Usage |
| 20 | +----- |
| 21 | + |
| 22 | +To access the tool, navigate to `Project > Tools > Orphan Resource Explorer...`. |
| 23 | +Depending on the project resources and their usage, the tool will display a window |
| 24 | +similar to the one shown below: |
| 25 | + |
| 26 | +.. image:: img/orphan_resource_explorer.webp |
| 27 | + |
| 28 | +The "Resource" column presents the tree structure of your project, listing only |
| 29 | +the orphaned files. The "Owns" column indicates the number of files that |
| 30 | +a resource uses. If this number is greater than zero, you can click on the |
| 31 | +eye icon to view its dependencies. |
| 32 | + |
| 33 | +.. note:: The tool will only search the files using their saved states |
| 34 | + on the disk, ignoring any unsaved changes. |
| 35 | + |
| 36 | +You can select and delete resources by marking them via checkbox and using the |
| 37 | +"Delete Selected..." button. |
| 38 | + |
| 39 | +It's important to note that deleting a resource that owns items may render those |
| 40 | +files orphaned if they are not used elsewhere. |
| 41 | +If you delete a file using the FileSystem dock that is dependent on another resource, |
| 42 | +a warning will be displayed, showing the list of resources using this file. |
| 43 | + |
| 44 | +If you open the dependencies window, you will see a list of files that the selected |
| 45 | +resource uses, including their relative paths. |
| 46 | +If you have broken dependencies, these will be listed in red. |
| 47 | + |
| 48 | +.. image:: img/orphan_resource_explorer_dep.webp |
| 49 | + |
| 50 | +Normally, renaming or changing the folders of resources is detected automatically |
| 51 | +by the Godot, and the dependencies are updated accordingly. |
| 52 | +However, if you made the changes outside of Godot while it is closed, the Godot will |
| 53 | +not be able to find them. |
| 54 | +In this case, the "Fix Broken" button can help you automatically locate them if you |
| 55 | +just changed the folder structure. |
| 56 | + |
| 57 | + |
| 58 | +Alternatively, in this window, you can click on the folder icon of any item to |
| 59 | +replace a file with another. |
| 60 | +Note that if the scene is currently open in the workspace, the changes will |
| 61 | +take effect only after you close and reopen it. |
| 62 | + |
| 63 | +.. tip:: If you would like to view the owners or dependencies of a file in the project, |
| 64 | + you can also right-click on a file in the FileSystem dock and choose "View Dependencies" or "View Owners". |
0 commit comments