-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
222 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
**/.DS_Store | ||
|
||
.gradle/ | ||
.idea/ | ||
.vscode/ | ||
bin/ | ||
build/ | ||
*.iml | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"files.exclude": { | ||
"**/.DS_Store": true, | ||
"**/.git": true, | ||
"**/.gitmodules": true, | ||
"**/*.booproj": true, | ||
"**/*.pidb": true, | ||
"**/*.suo": true, | ||
"**/*.user": true, | ||
"**/*.userprefs": true, | ||
"**/*.unityproj": true, | ||
"**/*.dll": true, | ||
"**/*.exe": true, | ||
"**/*.pdf": true, | ||
"**/*.mid": true, | ||
"**/*.midi": true, | ||
"**/*.wav": true, | ||
"**/*.gif": true, | ||
"**/*.ico": true, | ||
"**/*.jpg": true, | ||
"**/*.jpeg": true, | ||
"**/*.png": true, | ||
"**/*.psd": true, | ||
"**/*.tga": true, | ||
"**/*.tif": true, | ||
"**/*.tiff": true, | ||
"**/*.3ds": true, | ||
"**/*.3DS": true, | ||
"**/*.fbx": true, | ||
"**/*.FBX": true, | ||
"**/*.lxo": true, | ||
"**/*.LXO": true, | ||
"**/*.ma": true, | ||
"**/*.MA": true, | ||
"**/*.obj": true, | ||
"**/*.OBJ": true, | ||
"**/*.asset": true, | ||
"**/*.cubemap": true, | ||
"**/*.flare": true, | ||
"**/*.mat": true, | ||
"**/*.meta": true, | ||
"**/*.prefab": true, | ||
"**/*.unity": true, | ||
"build/": true, | ||
"Build/": true, | ||
"Library/": true, | ||
"library/": true, | ||
"obj/": true, | ||
"Obj/": true, | ||
"ProjectSettings/": true, | ||
"temp/": true, | ||
"Temp/": true | ||
}, | ||
"dotnet.defaultSolution": "TestGoogleSignIn.sln" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#if UNITY_EDITOR | ||
using System.IO; | ||
|
||
using UnityEngine; | ||
|
||
using UnityEditor.AssetImporters; | ||
|
||
[ScriptedImporter(1, "plist")] | ||
public class PListImporter : ScriptedImporter | ||
{ | ||
public override void OnImportAsset(AssetImportContext ctx) | ||
{ | ||
if(ctx.mainObject is TextAsset) | ||
return; | ||
|
||
var subAsset = new TextAsset(File.ReadAllText(ctx.assetPath)); | ||
ctx.AddObjectToAsset("text", subAsset); | ||
ctx.SetMainObject(subAsset); | ||
} | ||
} | ||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#if UNITY_EDITOR | ||
using UnityEngine; | ||
|
||
using UnityEditor; | ||
using UnityEditor.iOS.Xcode; | ||
|
||
using UnityEditor.Build; | ||
using UnityEditor.Build.Reporting; | ||
|
||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
|
||
public class PListProcessor : IPostprocessBuildWithReport | ||
{ | ||
public int callbackOrder => 99999; | ||
|
||
public void OnPostprocessBuild(BuildReport report) | ||
{ | ||
#if UNITY_IOS | ||
string projectBundleId = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.iOS); | ||
var plistFiles = AssetDatabase.FindAssets("glob:\"**/*.plist\"").Select((guid) => { | ||
var doc = new PlistDocument(); | ||
doc.ReadFromFile(AssetDatabase.GUIDToAssetPath(guid)); | ||
return doc; | ||
}).Where((doc) => { | ||
return doc.root.values.TryGetValue("BUNDLE_ID",out var element) && element.AsString() == projectBundleId; | ||
}).ToArray(); | ||
|
||
if(!(plistFiles?.Length > 0)) | ||
return; | ||
|
||
var google = plistFiles.FirstOrDefault(); | ||
|
||
if(!(google.root.values.TryGetValue("CLIENT_ID",out var CLIENT_ID) && CLIENT_ID?.AsString() is string clientID && clientID.EndsWith("googleusercontent.com"))) | ||
throw new KeyNotFoundException("CLIENT_ID"); | ||
if(!(google.root.values.TryGetValue("REVERSED_CLIENT_ID",out var REVERSED_CLIENT_ID) && REVERSED_CLIENT_ID?.AsString() is string reversedClientID && reversedClientID.StartsWith("com.googleusercontent"))) | ||
throw new KeyNotFoundException("REVERSED_CLIENT_ID"); | ||
|
||
string plistPath = Path.Combine( report.summary.outputPath, "Info.plist" ); | ||
|
||
var info = new PlistDocument(); | ||
info.ReadFromFile(plistPath); | ||
|
||
info.root.SetString("GIDClientID",clientID); | ||
var CFBundleURLTypes = (info.root.values.TryGetValue("CFBundleURLTypes",out var element) ? element.AsArray() : null) ?? info.root.CreateArray("CFBundleURLTypes"); | ||
if(!(CFBundleURLTypes?.values?.Count > 0 && CFBundleURLTypes.values.OfType<PlistElementDict>().Select((dict) => dict.values.TryGetValue("CFBundleURLSchemes",out var value) ? value?.AsArray() : null).OfType<PlistElementArray>().SelectMany((array) => array.values).Any((item) => item?.AsString() == reversedClientID))) | ||
{ | ||
var dict = CFBundleURLTypes.AddDict(); | ||
dict.SetString("CFBundleTypeRole","Editor"); | ||
dict.CreateArray("CFBundleURLSchemes").AddString(reversedClientID); | ||
} | ||
|
||
if(google.root.values.TryGetValue("WEB_CLIENT_ID",out var WEB_CLIENT_ID) && WEB_CLIENT_ID?.AsString() is string webClientID && !string.IsNullOrWhiteSpace(webClientID)) | ||
{ | ||
if(webClientID.EndsWith("googleusercontent.com")) | ||
info.root.SetString("GIDServerClientID",webClientID); | ||
else throw new ArgumentException("WebClientID"); | ||
} | ||
|
||
info.WriteToFile(plistPath); | ||
#endif | ||
} | ||
} | ||
|
||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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