Skip to main content

class LayerPrefabPlacementBase

(Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase)

Overview

Base class for all MapLayerComponent s that instantiate objects from a given prefab.

    template <T>
class LayerPrefabPlacementBase: Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.MapLayerComponent {
public:
// methods

PooledObject<T> PlaceInstance(in LatLng position, string instanceName = null);

virtual PooledObject<T> PlaceInstance(
in LatLng position,
in Quaternion rotation,
string instanceName = null
);

PooledObject<T> PlaceInstance(in Vector3 position, string instanceName = null);

PooledObject<T> PlaceInstance(
in Vector3 position,
in Quaternion rotation,
string instanceName = null
);

virtual override void Initialize(
LightshipMapView lightshipMapView,
GameObject parent
);

virtual override void OnMapOriginChanged();

protected:
// methods

virtual abstract Transform GetTransform(T instance) = 0;
virtual abstract GameObject GetGameObject(T instance) = 0;
virtual void OnObjectPoolAcquire(PooledObject<T> pooledObject);
virtual void OnObjectPoolRelease(T instance);
virtual Vector3 GetObjectScale(double mapRadius);
virtual Quaternion GetObjectRotation(in Quaternion rotation);
virtual Vector3 GetObjectPosition(in LatLng location);
};

// direct descendants

template &lt;T&gt;
class LayerMonoBehaviourPlacement;

Inherited Members

public:
// methods

virtual void Initialize(LightshipMapView lightshipMapView, GameObject parent);
virtual abstract void OnMapOriginChanged() = 0;

```cs
protected:
// fields

LightshipMapView LightshipMapView;
GameObject ParentMapLayer;

Detailed Documentation

Base class for all MapLayerComponent s that instantiate objects from a given prefab.

    Parameters:

    T - The prefab's type

Methods

GetTransform

virtual abstract Transform GetTransform(T instance) = 0

Classes derived from LayerPrefabPlacementBase<T> should implement this method by returning the Transform of an object placed by that derived class.

    Parameters:

    instance - An object whose Transform is returned

    Returns:

    The Transform belonging to placed object instance

GetGameObject

virtual abstract GameObject GetGameObject(T instance) = 0

Classes derived from LayerPrefabPlacementBase<T> should implement this method by returning the GameObject of an object placed by that derived class.

    Parameters:

    instance - An object whose GameObject is returned

    Returns:

    The GameObject belonging to placed object instance

OnObjectPoolAcquire

virtual void OnObjectPoolAcquire(PooledObject<T> pooledObject)

Called when an object is acquired from the ObjectPool<T>. This object may be newly instantiated or an instance reused from the pool.

    Parameters:

    pooledObject - The pooled object handle

OnObjectPoolRelease

virtual void OnObjectPoolRelease(T instance)

Called when an object is released into the ObjectPool<T>

    Parameters:

    instance - The instance being released

GetObjectScale

virtual Vector3 GetObjectScale(double mapRadius)

Gets a local scale for object instances. If "scale with map radius" is set, this scale will be based on the LightshipMapView 's viewable map radius.

    Parameters:

    mapRadius - The map's radius

    Returns:

    A local scale that will be applied to placed objects

GetObjectRotation

virtual Quaternion GetObjectRotation(in Quaternion rotation)

Gets an instantiated object's local rotation. This method should be overridden when customizing the orientation of placed object instances.

    Parameters:

    rotation - The local rotation associated with this object

    Returns:

    A new local rotation that will be applied to this object

GetObjectPosition

virtual Vector3 GetObjectPosition(in LatLng location)

Gets an instantiated object's position in the Unity scene's world space. This method should be overridden when customizing the position of placed object instances.

    Parameters:

    location - The location associated with this object

    Returns:

    A world space position applied to this object

PlaceInstance

PooledObject<T> PlaceInstance(in LatLng position, string instanceName = null)

Places an instance of this component's prefab at a given LatLng coordinate.

    Parameters:

    position - The location to place the instance

    instanceName - An optional name to assign to the instance

    Returns:

    An instance placed at the desired LatLng

PlaceInstance

virtual PooledObject<T> PlaceInstance(
in LatLng position,
in Quaternion rotation,
string instanceName = null
)

Places an instance of this component's prefab at a given LatLng coordinate.

    Parameters:

    position - The location to place the instance

    rotation - A local rotation applied to the placed instance

    instanceName - An optional name to assign to the instance

    Returns:

    An instance placed at the desired LatLng

PlaceInstance

PooledObject<T> PlaceInstance(in Vector3 position, string instanceName = null)

Places an instance of this component's prefab at a given point in the Unity scene's world space.

    Parameters:

    position - The location to place the instance

    instanceName - An optional name to assign to the instance

    Returns:

    An instance placed at the desired position

PlaceInstance

PooledObject<T> PlaceInstance(
in Vector3 position,
in Quaternion rotation,
string instanceName = null
)

Places an instance of this component's prefab at a given point in the Unity scene's world space.

    Parameters:

    position - The location to place the instance

    rotation - A local rotation applied to the placed instance

    instanceName - An optional name to assign to the instance

    Returns:

    An instance placed at the desired position

Initialize

virtual override void Initialize(
LightshipMapView lightshipMapView,
GameObject parent
)

Called from the LightshipMapView associated with this component's MapLayer at startup.

OnMapOriginChanged

virtual override void OnMapOriginChanged()

Called from this component's MapLayer when its LightshipMapView has been repositioned to the scene's origin.