Skip to content

Instantly share code, notes, and snippets.

@fwal
Created November 20, 2013 12:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fwal/7562518 to your computer and use it in GitHub Desktop.
Save fwal/7562518 to your computer and use it in GitHub Desktop.
A simple post processor for copying files from the assets/data folder to the player data folder in Unity3D
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System.Collections;
using System.IO;
public class DataCopyProcessor {
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) {
string sourceFolder = Path.Combine(Application.dataPath, "Data/");
string targetFolder = Path.Combine(pathToBuiltProject, "Data/");
Debug.Log("Copying files from " + sourceFolder + " to " + targetFolder);
string[] files = Directory.GetFiles(sourceFolder);
foreach(string file in files)
{
string filename = Path.GetFileName(file);
if(Path.GetExtension(filename) != ".meta")
{
Debug.Log("Copying " + filename + " to data folder...");
File.Copy(Path.Combine(sourceFolder, filename), Path.Combine(targetFolder, filename));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment