Class AssetBindingBuilder<TAsset>
Fluent builder for configuring asset bindings in a Scope.
Allows specifying how to locate UnityEngine.Object assets via direct instance, Resources, or AssetDatabase.
Returned from BindAsset<TAsset>() or BindAssets<TAsset>().
public class AssetBindingBuilder<TAsset> where TAsset : Object
Type Parameters
TAsset
- Inheritance
-
objectAssetBindingBuilder<TAsset>
Constructors
AssetBindingBuilder(AssetBinding)
Initializes a new instance of the AssetBindingBuilder<TAsset> class.
public AssetBindingBuilder(AssetBinding binding)
Parameters
bindingAssetBindingThe Plugins.Saneject.Runtime.Bindings.Asset.AssetBinding to configure.
Methods
FromAssetLoad(string)
Locate the UnityEngine.Object asset at the specified path using UnityEditor.AssetDatabase.LoadAssetAtPath(string, System.Type).
public AssetFilterBuilder<TAsset> FromAssetLoad(string assetPath)
Parameters
assetPathstringThe asset path.
Returns
- AssetFilterBuilder<TAsset>
A AssetFilterBuilder<TAsset> to further configure the binding.
FromFolder(string)
Locate all UnityEngine.Objects of type TAsset in the specified folder
using UnityEditor.AssetDatabase.FindAssets(string, string[]).
public AssetFilterBuilder<TAsset> FromFolder(string folderPath)
Parameters
folderPathstringThe folder path.
Returns
- AssetFilterBuilder<TAsset>
A AssetFilterBuilder<TAsset> to further configure the binding.
FromInstance(TAsset)
Bind to the specified UnityEngine.Object instance.
public AssetFilterBuilder<TAsset> FromInstance(TAsset instance)
Parameters
instanceTAssetThe asset instance.
Returns
- AssetFilterBuilder<TAsset>
A AssetFilterBuilder<TAsset> to further configure the binding.
FromMethod(Func<IEnumerable<TAsset>>)
Locate multiple UnityEngine.Objects using the provided method.
public AssetFilterBuilder<TAsset> FromMethod(Func<IEnumerable<TAsset>> method)
Parameters
methodFunc<IEnumerable<TAsset>>The method to resolve the assets.
Returns
- AssetFilterBuilder<TAsset>
A AssetFilterBuilder<TAsset> to further configure the binding.
FromMethod(Func<TAsset>)
Locate the UnityEngine.Object using the provided method.
public AssetFilterBuilder<TAsset> FromMethod(Func<TAsset> method)
Parameters
methodFunc<TAsset>The method to resolve the asset.
Returns
- AssetFilterBuilder<TAsset>
A AssetFilterBuilder<TAsset> to further configure the binding.
FromResources(string)
Locate the UnityEngine.Object in a UnityEngine.Resources folder at the specified path using UnityEngine.Resources.Load(string).
public AssetFilterBuilder<TAsset> FromResources(string path)
Parameters
pathstringThe resource path.
Returns
- AssetFilterBuilder<TAsset>
A AssetFilterBuilder<TAsset> to further configure the binding.
FromResourcesAll(string)
Locate all UnityEngine.Objects in a UnityEngine.Resources folder at the specified path using UnityEngine.Resources.LoadAll(string, System.Type).
public AssetFilterBuilder<TAsset> FromResourcesAll(string path)
Parameters
pathstringThe resource path.
Returns
- AssetFilterBuilder<TAsset>
A AssetFilterBuilder<TAsset> to further configure the binding.
ToID(params string[])
Qualifies this binding with an ID. Only injection targets annotated with InjectAttribute that specify the same ID will resolve using this binding.
public AssetBindingBuilder<TAsset> ToID(params string[] ids)
Parameters
idsstring[]The identifiers to match against injection targets.
Returns
- AssetBindingBuilder<TAsset>
The builder instance for fluent chaining.
ToMember(params string[])
Qualifies this binding to apply only when the injection target member (field or property) has one of the specified names.
public AssetBindingBuilder<TAsset> ToMember(params string[] memberNames)
Parameters
memberNamesstring[]The field or property names on the injection target that this binding should apply to.
Returns
- AssetBindingBuilder<TAsset>
The builder instance for fluent chaining.
ToTarget(params Type[])
Qualifies this binding to apply only when the injection target is one of the specified types. The injection target is the Plugins.Saneject.Runtime.Bindings.Component that owns the field or property marked with InjectAttribute.
public AssetBindingBuilder<TAsset> ToTarget(params Type[] targetTypes)
Parameters
targetTypesType[]One or more target System.Type objects to match against.
Returns
- AssetBindingBuilder<TAsset>
The builder instance for fluent chaining.
ToTarget<TTarget>()
Qualifies this binding to apply only when the injection target is of the given type. The injection target is the Plugins.Saneject.Runtime.Bindings.Component that owns the field or property marked with InjectAttribute.
public AssetBindingBuilder<TAsset> ToTarget<TTarget>()
Returns
- AssetBindingBuilder<TAsset>
The builder instance for fluent chaining.
Type Parameters
TTargetThe target type this binding applies to.