Table of Contents

Class Scope

Namespace
Plugins.Saneject.Runtime.Scopes
Assembly
Saneject.Runtime.dll

Base class for scopes that declare bindings for a portion of a UnityEngine.GameObject hierarchy. During injection, Saneject resolves each injection site from the nearest scope at the same transform or above, then falls back to parent scopes when needed.

[DisallowMultipleComponent]
[DefaultExecutionOrder(-10000)]
public abstract class Scope : MonoBehaviour
Inheritance
object
Object
Component
Behaviour
MonoBehaviour
Scope

Remarks

At runtime, a Scope registers its serialized global components in GlobalScope and swaps Plugins.Saneject.Runtime.Proxy.RuntimeProxy<TComponent> placeholders on registered proxy swap targets during early startup.

Methods

BindAsset<TConcrete>()

Registers a binding for a single asset of type TConcrete. Use this to inject a specific asset (e.g. UnityEngine.GameObject, UnityEngine.Material, UnityEngine.Texture, etc.) by reference.

protected AssetBindingBuilder<TConcrete> BindAsset<TConcrete>() where TConcrete : Object

Returns

AssetBindingBuilder<TConcrete>

A fluent builder for configuring the asset binding.

Type Parameters

TConcrete

The UnityEngine.Object-derived asset type to bind.

BindAsset<TInterface, TConcrete>()

Registers a binding from interface type TInterface to asset type TConcrete. Use this to inject an asset by interface abstraction (e.g. UnityEngine.ScriptableObject implementing an interface).

protected AssetBindingBuilder<TConcrete> BindAsset<TInterface, TConcrete>() where TInterface : class where TConcrete : Object, TInterface

Returns

AssetBindingBuilder<TConcrete>

A fluent builder for configuring the asset binding.

Type Parameters

TInterface

The interface type to inject.

TConcrete

The concrete asset type that implements the interface.

BindAssets<TConcrete>()

Registers a collection binding for all assets of type TConcrete. Use this to inject multiple assets (e.g. from a folder) as a collection. Shorthand for BindMultipleAssets<TConcrete>().

protected AssetBindingBuilder<TConcrete> BindAssets<TConcrete>() where TConcrete : Object

Returns

AssetBindingBuilder<TConcrete>

A fluent builder for configuring the asset collection binding.

Type Parameters

TConcrete

The UnityEngine.Object-derived asset type to bind as a collection.

BindAssets<TInterface, TConcrete>()

Registers a collection binding from interface type TInterface to asset type TConcrete. Use this to inject multiple assets implementing the interface as a collection. Shorthand for BindMultipleAssets<TInterface, TConcrete>().

protected AssetBindingBuilder<TConcrete> BindAssets<TInterface, TConcrete>() where TInterface : class where TConcrete : Object, TInterface

Returns

AssetBindingBuilder<TConcrete>

A fluent builder for configuring the asset collection binding.

Type Parameters

TInterface

The interface type to inject.

TConcrete

The concrete asset type that implements the interface.

BindComponent<T>()

Registers a binding for a single T component or interface type in this scope. Use this for concrete UnityEngine.Component or interface you wish to inject.

protected ComponentBindingBuilder<T> BindComponent<T>() where T : class

Returns

ComponentBindingBuilder<T>

A fluent builder for configuring the component binding.

Type Parameters

T

The concrete component or interface type to bind.

BindComponent<TInterface, TConcrete>()

Registers a binding from interface type TInterface to concrete component type TConcrete. Use this to inject components via an interface abstraction.

protected ComponentBindingBuilder<TConcrete> BindComponent<TInterface, TConcrete>() where TInterface : class where TConcrete : Component, TInterface

Returns

ComponentBindingBuilder<TConcrete>

A fluent builder for configuring the component binding.

Type Parameters

TInterface

The interface type to inject.

TConcrete

The concrete component type that implements the interface.

BindComponents<T>()

Registers a collection binding for T component type in this scope. Use this to inject all matching components or interfaces as a collection. Shorthand for BindMultipleComponents<T>().

protected ComponentBindingBuilder<T> BindComponents<T>() where T : class

Returns

ComponentBindingBuilder<T>

A fluent builder for configuring the component collection binding.

Type Parameters

T

The concrete component or interface type to bind as a collection.

BindComponents<TInterface, TConcrete>()

Registers a collection binding from interface type TInterface to concrete component type TConcrete. Use this to inject multiple components implementing the interface as a collection. Shorthand for BindMultipleComponents<TInterface, TConcrete>().

protected ComponentBindingBuilder<TConcrete> BindComponents<TInterface, TConcrete>() where TInterface : class where TConcrete : Component, TInterface

Returns

ComponentBindingBuilder<TConcrete>

A fluent builder for configuring the component collection binding.

Type Parameters

TInterface

The interface type to inject.

TConcrete

The concrete component type that implements the interface.

BindGlobal<TConcrete>()

Registers a component for runtime global registration through GlobalScope.

protected GlobalComponentBindingBuilder<TConcrete> BindGlobal<TConcrete>() where TConcrete : Component

Returns

GlobalComponentBindingBuilder<TConcrete>

A fluent builder for configuring the global component binding.

Type Parameters

TConcrete

The UnityEngine.Component type to bind globally.

Remarks

During editor-time injection, Saneject resolves the target TConcrete and serializes it on the declaring scope. During Plugins.Saneject.Runtime.Scopes.Scope.Awake(), the scope registers that component in GlobalScope before runtime proxy swapping runs. This is commonly used so Plugins.Saneject.Runtime.Proxy.RuntimeProxy<TComponent> can resolve the component through Plugins.Saneject.Runtime.Proxy.RuntimeProxyResolveMethod.FromGlobalScope.

BindMultipleAssets<TConcrete>()

Registers a collection binding for all assets of type TConcrete. Use this to inject multiple assets (e.g. from a folder) as a collection.

protected AssetBindingBuilder<TConcrete> BindMultipleAssets<TConcrete>() where TConcrete : Object

Returns

AssetBindingBuilder<TConcrete>

A fluent builder for configuring the asset collection binding.

Type Parameters

TConcrete

The UnityEngine.Object-derived asset type to bind as a collection.

BindMultipleAssets<TInterface, TConcrete>()

Registers a collection binding from interface type TInterface to asset type TConcrete. Use this to inject multiple assets implementing the interface as a collection.

protected AssetBindingBuilder<TConcrete> BindMultipleAssets<TInterface, TConcrete>() where TInterface : class where TConcrete : Object, TInterface

Returns

AssetBindingBuilder<TConcrete>

A fluent builder for configuring the asset collection binding.

Type Parameters

TInterface

The interface type to inject.

TConcrete

The concrete asset type that implements the interface.

BindMultipleComponents<T>()

Registers a collection binding for T component type in this scope. Use this to inject all matching components or interfaces as a collection.

protected ComponentBindingBuilder<T> BindMultipleComponents<T>() where T : class

Returns

ComponentBindingBuilder<T>

A fluent builder for configuring the component collection binding.

Type Parameters

T

The concrete component or interface type to bind as a collection.

BindMultipleComponents<TInterface, TConcrete>()

Registers a collection binding from interface type TInterface to concrete component type TConcrete. Use this to inject multiple components implementing the interface as a collection.

protected ComponentBindingBuilder<TConcrete> BindMultipleComponents<TInterface, TConcrete>() where TInterface : class where TConcrete : Component, TInterface

Returns

ComponentBindingBuilder<TConcrete>

A fluent builder for configuring the component collection binding.

Type Parameters

TInterface

The interface type to inject.

TConcrete

The concrete component type that implements the interface.

DeclareBindings()

Set up your bindings in this method.

protected abstract void DeclareBindings()