Asset Naming

When you first apply an AssetInjectionAttribute such as an [AssetReference] or [AssetInstance] it uses the AssetPathMatcher class to search through all assets of the appropriate type in your project. This search picks the most appropriate asset to use based the end of its file path using the following criteria:

  1. (highest priority) The optional FileName property set in the attribute's constructor.
  2. The full Namespace.DeclaringType.MemberName of the attributed member.
  3. Same as above, but without the Namespace.
  4. Just the MemberName. Only used if no other injection attributed members have the same name.
  5. The Namespace.DeclaringType. Only used if the type has no other injection attributed members.
  6. (lowest priority) Same as above, but without the Namespace.
  7. All the above options check without the file extension first, then with it if a match wasn't found.

The search is case-insensitive and any separator characters (dot ., comma ,, slash /, plus +, minus -, or space ) are considered interchangeable and skippable. For example:

  • MyGame.Player.Prefab could match against a file path ending with .../My Game/Player.prefab. Note how "My Game" has a space not present in the member name and is a folder while "prefab" is actually the file extension.
  • Weaver itself makes use of this feature to identify the target assets for each of the Example Scripts when it is first imported so that it doesn't need to include the Weaver Settings file (because doing so would overwrite your settings each time you import a new version of Weaver).
    • Weaver.Examples.FrameRate.Instance is found at Assets/Plugins/Weaver/Examples/01 Frame Rate/Frame Rate.prefab.
    • TextManager finds its prefabs in the Assets/Plugins/Weaver/Examples/02 Floating Text/Text Manager folder.
    • Building.ProceduralOfficeBuilding is found at Assets/Plugins/Weaver/Examples/03 Building/Procedural Office Building.prefab.
    • GameOverScreen.Prefab is found at Assets/Plugins/Weaver/Examples/05 Missile Command/Prefabs/Resources/Game Over Screen.prefab.
    • Score.Text is found at Assets/Plugins/Weaver/Examples/05 Missile Command/Prefabs/Score Text.prefab.
    • Weaver.Icons finds its textures in the Assets/Plugins/Weaver/Icons folder.

This search is only conducted once when Weaver first detects you have added the attribute. After that it simply stores a reference to the asset (or remembers that it didn't find one) so the system doesn't have to search through your whole project all the time and doesn't change the target asset unexpectedly when you rename or move assets. You can always re-run the search using the [F] button in the Injectors Panel.