onVehicleRemoved

Description

Triggered every time a vehicle is deactivated inside the scene.

Parameters

NameDescription

vehicleIndex

The index of the vehicle that was disabled.

Example

using Gley.TrafficSystem;
using UnityEngine;
public class Test : MonoBehaviour
{
    //a reference to vehicle pool and player assigned in inspector
    public VehiclePool vehiclePool;
    public Transform player;

    void Start()
    {
        API.Initialize(player, 20, vehiclePool);
        Events.onVehicleRemoved += VehicleRemoved;
    }

    private void VehicleRemoved(int vehicleIndex)
    {
        Debug.Log("Vehicle Removed " + vehicleIndex);
    }

    private void OnDestroy()
    {
        Events.onVehicleRemoved -= VehicleRemoved;
    }
}

Last updated