Ejemplo n.º 1
0
        private GameObject LoadObject(AssetBundle bundle, string assetPath)
        {
            var obj = bundle.LoadAsset <GameObject>(assetPath);

            if (obj == null)
            {
                throw new Exception("Object with path: " + assetPath + " in bundle " + bundle.Name + " not found");
            }

            //obj has not collider, add a default one
            if (!obj.GetComponent <Collider>() && !obj.GetComponentsInChildren <Transform>().Any(t => t.GetComponent <Collider>()))
            {
                ObjectUtils.AddDefaultCollider(obj);
            }

            return(obj);
        }