Is there a way to automatically convert 3d cilliders to 2d colliders?

I have a 3d project with 3d colliders on them. However I bought a 2.5d asset which uses 2d colliders. So I was wondering if there was a way to covert the 3d colliders over to 2d. Maybe a script or something. If could even add a 2d collider along side the 3d one as they use different engines.

You can write an editor script that basically goes through all the objects in your scene and remove the box collider component. You can first store the bounds (center and size) of this box collider, then remove it and then add a box collider 2D component and then set the bounds(center and size) to the read value. Hope this helps.

I needed to do this so wrote the required script - this will convert BoxColliders to BoxColliders2D in the current scene and in non scene objects like prefabs - use at your own risk!

Put the script in a folder called Editor anywhere in your project, this will add a menu option under Window / ScaryBee / ConvertBoxCollidersTo2D that you can then click to run it.

using UnityEngine;
using UnityEditor;

public class ConvertBoxCollidersTo2D : MonoBehaviour {

	public static void Convert(){
		BoxCollider[] colliders = Resources.FindObjectsOfTypeAll<BoxCollider>();
		Debug.Log("got colliders: "+colliders.Length);

		foreach(BoxCollider b in colliders){
			GameObject g = b.gameObject;
			Vector3 size = b.size;
			DestroyImmediate(b, true);

			BoxCollider2D b2d = g.AddComponent<BoxCollider2D>();
			b2d.size = new Vector2(size.x, size.y);