When you first apply an
AssetInjectionAttribute such as an
[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:
- (highest priority) The optional
FileNameproperty set in the attribute's constructor.
- The full
Namespace.DeclaringType.MemberNameof the attributed member.
- Same as above, but without the
- Just the
MemberName. Only used if no other injection attributed members have the same name.
Namespace.DeclaringType. Only used if the type has no other injection attributed members.
- (lowest priority) Same as above, but without the
- 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
-, or space
MyGame.Player.Prefabcould 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.Instanceis found at Assets/Plugins/Weaver/Examples/01 Frame Rate/Frame Rate.prefab.
TextManagerfinds its prefabs in the Assets/Plugins/Weaver/Examples/02 Floating Text/Text Manager folder.
Building.ProceduralOfficeBuildingis found at Assets/Plugins/Weaver/Examples/03 Building/Procedural Office Building.prefab.
GameOverScreen.Prefabis found at Assets/Plugins/Weaver/Examples/05 Missile Command/Prefabs/Resources/Game Over Screen.prefab.
Score.Textis found at Assets/Plugins/Weaver/Examples/05 Missile Command/Prefabs/Score Text.prefab.
Weaver.Iconsfinds 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.