- Home /
Copy Lightmap Script error meta files
Im having an error while im copying lighmaps to make an animated array. Here is the code:
foreach (FileInfo file in files) {
if (!skip)
file.CopyTo (path + "/AnimLightmaps/" + referance.Label + "/" + sampleValue.ToString () + "/" + file.Name);
//SetIsLightmap( "Assets/AnimLightmaps/" + referance.Label + "/" + sampleValue.ToString() + "/" + file.Name);
//AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
if (file.Extension == ".exr" || file.Extension == "exr") {
string[] parts = file.Name.Split (new char[] { '-' });
int num = int.Parse (parts [1].Split (new char[]{'.'}) [0]);
if (referance.animationFrames [pos].lightmaps [num] == null) {
referance.animationFrames [pos].lightmaps [num] = new DualLightmaps ();
}
if (parts [0].Contains ("Far") || parts [0].Contains ("Color"))
{
AssetDatabase.ImportAsset("Assets/AnimLightmaps/" + referance.Label + "/" + sampleValue.ToString () + "/" + file.Name);
referance.animationFrames [pos].lightmaps [num].far = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/AnimLightmaps/" + referance.Label + "/" + sampleValue.ToString () + "/" + file.Name, typeof(Texture2D));
}
else if (parts [0].Contains ("Near") || parts [0].Contains ("Scale"))
{
AssetDatabase.ImportAsset("Assets/AnimLightmaps/" + referance.Label + "/" + sampleValue.ToString () + "/" + file.Name);
referance.animationFrames [pos].lightmaps [num].near = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/AnimLightmaps/" + referance.Label + "/" + sampleValue.ToString () + "/" + file.Name, typeof(Texture2D));
}
}
}
And this is the error I do not understand (meta file already exists):
IOException: C:\Users\Public\Documents\Unity Projects\PSMTest\Assets\AnimLightmaps\Animated Lightmaps\0\LightmapFar-0.exr.meta already exists System.IO.File.Copy (System.String sourceFileName, System.String destFileName, Boolean overwrite) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.IO/File.cs:115) System.IO.File.Copy (System.String sourceFileName, System.String destFileName) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.IO/File.cs:86) System.IO.FileInfo.CopyTo (System.String destFileName, Boolean overwrite) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.IO/FileInfo.cs:259) System.IO.FileInfo.CopyTo (System.String destFileName) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.IO/FileInfo.cs:244) (wrapper remoting-invoke-with-check) System.IO.FileInfo:CopyTo (string) LightmapManager.CopyLightmapsToDirectoryforAnimation (.RecordAnimatedLightmaps referance, Single sampleValue) (at Assets/LM2/MXDLightmapManager/Scripts/Editor/LightmapManager.cs:2205) System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.