Quantcast
Channel: Questions in topic: "copyasset"
Viewing all articles
Browse latest Browse all 6

Why would AssetDatabase.CopyAsset return false?

$
0
0
I'm trying to set up a build script that will copy a music file to a /Resources folder so that I can use one project that has the ability to do Resources.Load in standalone (i.e. big download) built versions but can do streaming for the web version. My script looks something like this: static void PrepBundledResources() { var baseBundledPath = "/Platform Resources/StandaloneVersions"; var baseResourcesPath = "/Platform Resources/Resources"; var assets = EditorUtils.GetObjectsAtPath( baseBundledPath, null ); VerifyDirectoryExists( Application.dataPath + baseResourcesPath ); AssetDatabase.Refresh( ImportAssetOptions.TryFastReimportFromMetaData ); foreach( var asset in assets ) { var assetPath = AssetDatabase.GetAssetPath( asset ); var destinationPath = "/Assets/Platform Resources/Resources" + assetPath.Substring( assetPath.LastIndexOf( baseBundledPath ) + baseBundledPath.Length ); Debug.Log( "Copying bundled asset " + assetPath + " to " + destinationPath ); if( !AssetDatabase.CopyAsset( assetPath, destinationPath ) ) { Debug.LogError( "Copy asset failed on " + assetPath + " to go to " + destinationPath ); } AssetDatabase.ImportAsset( destinationPath ); } AssetDatabase.Refresh( ImportAssetOptions.TryFastReimportFromMetaData ); } GetObjectsAtPath is a helper method I wrote that gets files recursively. VerifyDirectoryExists just creates the directory if it doesn't exist. The problem I'm running in to is that I'm hitting the error inside the if statement with the copy asset.

Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>