Skip to content

Commit

Permalink
Auto zip Examples and Samples at build time and put into StreamingAss…
Browse files Browse the repository at this point in the history
…ets, at run-time initialization extract Examples and Samples into Persistent Data Directory if the Examples or Samples directory do not exist. No more manual copying of files. Credit goes to https://forum.unity.com/threads/copying-everyhting-under-streamingassets-to-persistentdatapath-on-android.431269/
  • Loading branch information
plaidpants committed Dec 4, 2019
1 parent 56c88ad commit aa998cd
Show file tree
Hide file tree
Showing 14 changed files with 2,096 additions and 1,608 deletions.
8 changes: 8 additions & 0 deletions Assets/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions Assets/Editor/Editor_BuildPreprocess.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#if UNITY_EDITOR

using UnityEngine;
using UnityEditor;
using UnityEditor.Build;
using System.IO;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;


class CustomBuildPreProcess : IPreprocessBuild
{
public int callbackOrder { get { return 0; } }
public void OnPreprocessBuild(BuildTarget target, string path) {

string dataDirectory = Application.dataPath + "/Plugins/Android/assets/Examples/";
string fileToCreate = Application.streamingAssetsPath + "/Examples.tgz";

Utility_SharpZipCommands.CreateTarGZ_FromDirectory (fileToCreate, dataDirectory);

dataDirectory = Application.dataPath + "/Plugins/Android/assets/Samples/";
fileToCreate = Application.streamingAssetsPath + "/Samples.tgz";

Utility_SharpZipCommands.CreateTarGZ_FromDirectory (fileToCreate, dataDirectory);

}
}

#endif
11 changes: 11 additions & 0 deletions Assets/Editor/Editor_BuildPreprocess.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/ICSharpCode.SharpZipLib.dll
Binary file not shown.
33 changes: 33 additions & 0 deletions Assets/Plugins/ICSharpCode.SharpZipLib.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit aa998cd

Please sign in to comment.