Receive Loader instance events in Layer - Katsuya100/SceneLayer-Trial GitHub Wiki

This section explains how to receive data loaded by Loader in a Layer.

Set [LayerInstanceObjectAttribute] to the member of the LayerBehaviour that is to receive the instance.

[LayerInstanceObject]
GameObject _obj;

The type of this member and the type of LoaderBehaviour.InstanceType must be assignable.
*Not supported for "custom implicit casts". Type.IsAssignableFrom` must be true.

Open Layer's Inspector and find the target Loader.
Specify the previously mentioned member in [Advanced Options > Receive Field].
*Note that if the recipient's type is incorrect, it cannot be selected.
image
You can now receive the result at the time of instance creation.

It can also be received via function arguments.

[LayerInstanceObject]
private void OnInstantiatedGameObject(GameObject go)
{
  :
}

In that case, specify the member function described above in [Advanced Options > On Instantiated].
image

It is also possible to receive instances of LoaderBehaviour and its derived classes.

[LayerInstanceObject]
private void OnInstantiatedGameObject(ResourcesPrefabLoader loader)
{
  :
}

The same [LayersInstanceObjectAttribute] can be used to hook the destruction.
Only LoaderBehaviour and its derived classes can be accepted.

[LayerInstanceObject]
private void OnDestroyedGameObject(ResourcesPrefabLoader loader)
{
  :
}

In that case, specify the member function described above in [Advanced Options > On Destroyed].
image