t1 / TFDContents / Assets / Standard Assets / Editor / KinectCopyPluginDataHelper.cs @ 10
이력 | 보기 | 이력해설 | 다운로드 (2.51 KB)
| 1 | 3 | KTH | #if !(UNITY_WSA_10_0 && NETFX_CORE) |
|---|---|---|---|
| 2 | using UnityEngine; |
||
| 3 | using UnityEditor; |
||
| 4 | using System; |
||
| 5 | using System.Collections.Generic; |
||
| 6 | using System.IO; |
||
| 7 | |||
| 8 | public static class KinectCopyPluginDataHelper |
||
| 9 | {
|
||
| 10 | private const string DataDirSuffix = "_Data"; |
||
| 11 | private const string PluginsDirName = "Plugins"; |
||
| 12 | |||
| 13 | private static Dictionary<BuildTarget, string> TargetToDirName = new Dictionary<BuildTarget, string>() |
||
| 14 | {
|
||
| 15 | {BuildTarget.StandaloneWindows, "x86"},
|
||
| 16 | {BuildTarget.StandaloneWindows64, "x86_64"}
|
||
| 17 | }; |
||
| 18 | |||
| 19 | public static void CopyPluginData(BuildTarget target, string buildTargetPath, string subDirToCopy) |
||
| 20 | {
|
||
| 21 | string subDirName; |
||
| 22 | if (!TargetToDirName.TryGetValue (target, out subDirName)) |
||
| 23 | {
|
||
| 24 | // No work to do |
||
| 25 | return; |
||
| 26 | } |
||
| 27 | |||
| 28 | // Get Required Paths |
||
| 29 | var buildName = Path.GetFileNameWithoutExtension(buildTargetPath); |
||
| 30 | var targetDir = Directory.GetParent(buildTargetPath); |
||
| 31 | var separator = Path.DirectorySeparatorChar; |
||
| 32 | |||
| 33 | var buildDataDir = targetDir.FullName + separator + buildName + DataDirSuffix + separator; |
||
| 34 | var tgtPluginsDir = buildDataDir + separator + PluginsDirName + separator + subDirToCopy + separator; |
||
| 35 | var srcPluginsDir = Application.dataPath + separator + PluginsDirName + separator + subDirName + separator + subDirToCopy + separator; |
||
| 36 | |||
| 37 | CopyAll (new DirectoryInfo (srcPluginsDir), new DirectoryInfo(tgtPluginsDir)); |
||
| 38 | } |
||
| 39 | |||
| 40 | /// <summary> |
||
| 41 | /// Recursive Copy Directory Method |
||
| 42 | /// </summary> |
||
| 43 | private static void CopyAll(DirectoryInfo source, DirectoryInfo target) |
||
| 44 | {
|
||
| 45 | // Check if the source directory exists, if not, don't do any work. |
||
| 46 | if (!Directory.Exists(source.FullName)) |
||
| 47 | {
|
||
| 48 | return; |
||
| 49 | } |
||
| 50 | |||
| 51 | // Check if the target directory exists, if not, create it. |
||
| 52 | if (!Directory.Exists(target.FullName)) |
||
| 53 | {
|
||
| 54 | Directory.CreateDirectory(target.FullName); |
||
| 55 | } |
||
| 56 | |||
| 57 | // Copy each file into it’s new directory. |
||
| 58 | foreach (var fileInfo in source.GetFiles()) |
||
| 59 | {
|
||
| 60 | fileInfo.CopyTo (Path.Combine (target.ToString (), fileInfo.Name), true); |
||
| 61 | } |
||
| 62 | |||
| 63 | // Copy each subdirectory using recursion. |
||
| 64 | foreach (var subDirInfo in source.GetDirectories()) |
||
| 65 | {
|
||
| 66 | DirectoryInfo nextTargetSubDir = target.CreateSubdirectory(subDirInfo.Name); |
||
| 67 | CopyAll(subDirInfo, nextTargetSubDir); |
||
| 68 | } |
||
| 69 | } |
||
| 70 | |||
| 71 | } |
||
| 72 | #endif |