-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using UnityEngine; | ||
|
||
namespace Appirater | ||
{ | ||
public class Appirater | ||
{ | ||
|
||
[DllImport("__Internal")] | ||
private static extern void _Init(string appId, int daysUntilPrompt, int usesUntilPrompt, | ||
int significantEventsUntilPrompt, int timeBeforeReminding, bool debug); | ||
|
||
|
||
public static void Init(string appId, int daysUntilPrompt, int usesUntilPrompt, | ||
int significantEventsUntilPrompt, int timeBeforeReminding, bool debug) | ||
{ | ||
_Init(appId, daysUntilPrompt, usesUntilPrompt, significantEventsUntilPrompt, timeBeforeReminding, debug); | ||
} | ||
|
||
[DllImport("__Internal")] | ||
private static extern void _DidSignificantEvent(); | ||
|
||
public static void DidSignificantEvent() | ||
{ | ||
_DidSignificantEvent(); | ||
} | ||
|
||
[DllImport("__Internal")] | ||
private static extern void _AppGoesToBackground(bool idInBackground); | ||
|
||
public void AppGoesToBackground(bool isInBackground) | ||
{ | ||
AppGoesToBackground(isInBackground); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEditor; | ||
using System.IO; | ||
using ChillyRoom.UnityEditor.iOS.Xcode; | ||
|
||
public class NativeLocale | ||
{ | ||
public static void AddLocalizedStringsIOS(string projectPath, string localizedDirectoryPath) | ||
{ | ||
DirectoryInfo dir = new DirectoryInfo(localizedDirectoryPath); | ||
if(!dir.Exists) | ||
return; | ||
|
||
List<string> locales = new List<string>(); | ||
var localeDirs = dir.GetDirectories("*.lproj", SearchOption.TopDirectoryOnly); | ||
|
||
foreach(var sub in localeDirs) | ||
locales.Add(Path.GetFileNameWithoutExtension(sub.Name)); | ||
|
||
AddLocalizedStringsIOS(projectPath, localizedDirectoryPath, locales); | ||
} | ||
|
||
public static void AddLocalizedStringsIOS(string projectPath, string localizedDirectoryPath, List<string> validLocales) | ||
{ | ||
string projPath = projectPath + "/Unity-iPhone.xcodeproj/project.pbxproj"; | ||
PBXProject proj = new PBXProject(); | ||
proj.ReadFromFile(projPath); | ||
|
||
foreach(var locale in validLocales) | ||
{ | ||
// copy contents in the localization directory to project directory | ||
string src = Path.Combine(localizedDirectoryPath, locale + ".lproj"); | ||
string dst = Path.Combine(projectPath, "Unity-iPhone/" + locale + ".lproj"); | ||
if (Directory.Exists(dst)) | ||
{ | ||
Directory.Delete(dst,true); | ||
} | ||
DirectoryCopy(src, dst); | ||
|
||
string fileRelatvePath = string.Format("Unity-iPhone/{0}.lproj/AppiraterLocalizable.strings", locale); | ||
proj.AddLocalization("InfoPlist.strings", locale, fileRelatvePath); | ||
} | ||
|
||
proj.WriteToFile(projPath); | ||
} | ||
|
||
|
||
private static void DirectoryCopy(string sourceDirName, string destDirName) | ||
{ | ||
DirectoryInfo dir = new DirectoryInfo(sourceDirName); | ||
|
||
if (!dir.Exists) | ||
return; | ||
|
||
if (!Directory.Exists(destDirName)) | ||
{ | ||
Directory.CreateDirectory(destDirName); | ||
} | ||
|
||
FileInfo[] files = dir.GetFiles(); | ||
|
||
foreach (FileInfo file in files) | ||
{ | ||
// skip unity meta files | ||
if(file.FullName.EndsWith(".meta")) | ||
continue; | ||
string temppath = Path.Combine(destDirName, file.Name); | ||
file.CopyTo(temppath, false); | ||
} | ||
|
||
DirectoryInfo[] dirs = dir.GetDirectories(); | ||
foreach (DirectoryInfo subdir in dirs) | ||
{ | ||
string temppath = Path.Combine(destDirName, subdir.Name); | ||
DirectoryCopy(subdir.FullName, temppath); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using UnityEngine; | ||
using UnityEditor; | ||
using UnityEditor.Callbacks; | ||
using System.IO; | ||
using ChillyRoom.UnityEditor.iOS.Xcode; | ||
|
||
public class PostProcess: MonoBehaviour | ||
{ | ||
[PostProcessBuildAttribute(9999)] | ||
public static void OnPostProcessBuild(BuildTarget target, string path) | ||
{ | ||
if (target == BuildTarget.iOS) | ||
{ | ||
OnIOSBuild(target, path); | ||
} | ||
} | ||
|
||
private static void OnIOSBuild(BuildTarget target, string path) | ||
{ | ||
NativeLocale.AddLocalizedStringsIOS(path, Path.Combine(Application.dataPath, "Appirater/iOS")); | ||
AddStoreKitFramework(path); | ||
} | ||
|
||
private const string SoreKitFramework = "StoreKit.framework"; | ||
private static void AddStoreKitFramework(string projectPath) | ||
{ | ||
|
||
string projPath = projectPath + "/Unity-iPhone.xcodeproj/project.pbxproj"; | ||
PBXProject proj = new PBXProject(); | ||
proj.ReadFromFile(projPath); | ||
|
||
// if (!proj.ContainsFramework(proj.ProjectGuid(), SoreKitFramework)) | ||
// { | ||
// proj.AddFrameworkToProject(proj.ProjectGuid(), SoreKitFramework, false); | ||
// } | ||
|
||
|
||
foreach (string targetName in new string[] {PBXProject.GetUnityTargetName(), PBXProject.GetUnityTestTargetName()}) | ||
{ | ||
string guid = proj.TargetGuidByName(targetName); | ||
if (!proj.ContainsFramework(guid, SoreKitFramework)) | ||
{ | ||
proj.AddFrameworkToProject(guid, SoreKitFramework, false); | ||
} | ||
} | ||
|
||
|
||
|
||
proj.WriteToFile(projPath); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.