public void ExportLocation(string locationXmlAssetPath, string locationSoAssetPath, int minimapSize, Camera minimapCamera, float minimapCameraHeight, string _minimapAssetFolder) { //we export as old xml assets, and new so-based assets with the same data #if UNITY_EDITOR materialLinks = new Dictionary <int, NameLinkPath>(); textureLinks = new Dictionary <int, NameLinkPath>(); meshLinks = new Dictionary <int, NameLinkPath>(); shaderLinks = new Dictionary <int, NameLinkPath>(); string locationName = "location_" + u.ToString() + "_" + v.ToString(); string assetPath = locationXmlAssetPath + locationName + ".xml"; //create so LocationDataSO locationSO = ScriptableObjectUtility.CreateAsset <LocationDataSO>(locationSoAssetPath, locationName); locationSO.items = new List <ItemSO>(); LocationData location = new LocationData { transform = new TransformData(gameObject.transform), items = new List <ItemData>() }; ExportOneObject(gameObject, location.items, locationSO.items); string minimapName = "minimap_" + u.ToString() + "_" + v.ToString(); string minimapBundlePath = "minimaps/" + minimapName; if (locationMinimap == null) { minimapAssetFolder = _minimapAssetFolder; CreateMinimap(minimapSize, minimapCamera, minimapCameraHeight); } MinimapData mData = new MinimapData { link = minimapBundlePath, name = locationMinimap.name }; location.minimap = mData; //also to so locationSO.minimapName = locationMinimap.name; locationSO.minimapLink = minimapBundlePath; //and transform locationSO.position = gameObject.transform.position; locationSO.rotation = gameObject.transform.rotation; locationSO.scale = gameObject.transform.lossyScale; //save so EditorUtility.SetDirty(locationSO); location.Save(assetPath); AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate); //add location asset to the bundle AssetImporter.GetAtPath(assetPath).SetAssetBundleNameAndVariant("locations/" + locationName, ""); AssetImporter.GetAtPath(locationSoAssetPath + locationName + ".asset").SetAssetBundleNameAndVariant("locations_so/" + locationName, ""); AssetImporter.GetAtPath(minimapAssetPath).SetAssetBundleNameAndVariant(minimapBundlePath, ""); #endif }
public void ExportLocation(string locationAssetPath, int minimapSize, Camera minimapCamera, float minimapCameraHeight, string _minimapAssetFolder) { #if UNITY_EDITOR materialLinks = new Dictionary <int, NameLinkPath>(); textureLinks = new Dictionary <int, NameLinkPath>(); meshLinks = new Dictionary <int, NameLinkPath>(); shaderLinks = new Dictionary <int, NameLinkPath>(); LocationData location = new LocationData { transform = new TransformData(gameObject.transform), items = new List <ItemData>() }; ExportOneObject(gameObject, location.items); string minimapName = "minimap_" + u.ToString() + "_" + v.ToString(); string minimapBundlePath = "minimaps/" + minimapName; if (locationMinimap == null) { minimapAssetFolder = _minimapAssetFolder; CreateMinimap(minimapSize, minimapCamera, minimapCameraHeight); } MinimapData mData = new MinimapData { link = minimapBundlePath, name = locationMinimap.name }; location.minimap = mData; string locationName = "location_" + u.ToString() + "_" + v.ToString(); string assetPath = locationAssetPath + locationName + ".xml"; location.Save(assetPath); AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate); //add location asset to the bundle AssetImporter.GetAtPath(assetPath).SetAssetBundleNameAndVariant("locations/" + locationName, ""); AssetImporter.GetAtPath(minimapAssetPath).SetAssetBundleNameAndVariant(minimapBundlePath, ""); #endif }