Created
November 20, 2013 12:40
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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