This example scene is located in Assets/Plugins/Weaver/Examples/01 Frame Rate. It demonstrates how you can use Asset Injection to easily create standalone singleton-like systems that can reference assets without needing any scene-specific setup.
- The
Frame Rate.prefab
is simple aCanvas
with aText
object and aFrameRate
component. - The
FrameRate
script uses an[AssetInstance]
attribute on its staticInstance
field to have the Weaver Window show that field in the Injectors Panel. Then on startup (both in Play Mode and in a runtime build) the chosen prefab is automatically instantiated and assigned to the field. - The scene is actually empty (except for a few dummy explanation objects) to demonstrate the fact that the script doesn't require anything to be set up in the scene. Simply having it in the project allows it to function automatically in any scene.
- The name of the prefab follows one of the Asset Naming rules to automatically match up with the script name when you first import Weaver. After the first import the name is unimportant and you can rename it or assign another prefab if you want.