Skip to content

Commit c656358

Browse files
author
andrew
committed
Merge branch 'release-2.1.7' into stable
2 parents 1769184 + d000f00 commit c656358

File tree

57 files changed

+2721
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2721
-59
lines changed

Assets/Plugins/Android/EOSManager_Android.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040

4141

42-
#if UNITY_ANDROID && !UNITY_EDITOR && EOS_PREVIEW_PLATFORM
42+
#if UNITY_ANDROID && !UNITY_EDITOR
4343
namespace PlayEveryWare.EpicOnlineServices
4444
{
4545
//-------------------------------------------------------------------------

Assets/Plugins/Android/gradleTemplate.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
unityStreamingAssets=.unity3d**STREAMING_ASSETS**
12
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
23
org.gradle.parallel=true
34
android.enableR8=**MINIFY_WITH_R_EIGHT**

Assets/Plugins/Android/mainTemplate.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ android {
3333
}
3434

3535
aaptOptions {
36+
// Double check this works with other versions of unity?
37+
noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
38+
3639
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
3740
}**PACKAGING_OPTIONS**
3841
}**REPOSITORIES**
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
/*
2+
* Copyright (c) 2022 PlayEveryWare
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*/
22+
23+
using UnityEditor;
24+
using UnityEditor.Build;
25+
using UnityEditor.Build.Reporting;
26+
using UnityEngine;
27+
using System.IO;
28+
using System.Linq;
29+
using PlayEveryWare.EpicOnlineServices;
30+
using System.Collections.Generic;
31+
32+
public class EOSOnPreprocessBuild_android : IPreprocessBuildWithReport
33+
{
34+
public int callbackOrder { get { return 3; } }
35+
36+
//-------------------------------------------------------------------------
37+
private static string GetAndroidEOSValuesConfigPath()
38+
{
39+
string assetsPathname = Path.Combine(Application.dataPath, "Plugins/Android/EOS/");
40+
return Path.Combine(assetsPathname, "eos_dependencies.androidlib/res/values/eos_values.xml");
41+
}
42+
43+
//-------------------------------------------------------------------------
44+
private static string GetPackageName()
45+
{
46+
return "com.playeveryware.eos";
47+
}
48+
49+
50+
//-------------------------------------------------------------------------
51+
public void OnPreprocessBuild(BuildReport report)
52+
{
53+
if (report.summary.platform == BuildTarget.Android)
54+
{
55+
InstallEOSDependentLibrary();
56+
ConfigureEOSDependentLibrary();
57+
}
58+
}
59+
60+
//-------------------------------------------------------------------------
61+
static private void OverwriteCopy(string fileToInstallPathName, string destPathname)
62+
{
63+
if (File.Exists(destPathname))
64+
{
65+
File.SetAttributes(destPathname, File.GetAttributes(destPathname) & ~FileAttributes.ReadOnly);
66+
}
67+
68+
File.Copy(fileToInstallPathName, destPathname, true);
69+
}
70+
71+
//-------------------------------------------------------------------------
72+
static private void InstallFiles(string[] filenames, string pathToInstallFrom, string pathToInstallTo)
73+
{
74+
75+
if (!EmptyPredicates.IsEmptyOrNull(pathToInstallFrom))
76+
{
77+
foreach (var fileToInstall in filenames)
78+
{
79+
string fileToInstallPathName = Path.Combine(pathToInstallFrom, fileToInstall);
80+
81+
if (File.Exists(fileToInstallPathName))
82+
{
83+
string fileToInstallParentDirectory = Path.GetDirectoryName(Path.Combine(pathToInstallTo, fileToInstall));
84+
85+
if (!Directory.Exists(fileToInstallParentDirectory))
86+
{
87+
Directory.CreateDirectory(fileToInstallParentDirectory);
88+
}
89+
string destPathname = Path.Combine(fileToInstallParentDirectory, Path.GetFileName(fileToInstallPathName));
90+
91+
OverwriteCopy(fileToInstallPathName, destPathname);
92+
}
93+
else
94+
{
95+
Debug.LogError("Missing platform specific file: " + fileToInstall);
96+
}
97+
}
98+
}
99+
}
100+
101+
//-------------------------------------------------------------------------
102+
private string GetPlatformSpecificAssetsPath(string subpath)
103+
{
104+
string packagePathname = Path.GetFullPath("Packages/" + GetPackageName() + "/PlatformSpecificAssets~/" + subpath);
105+
string streamingAssetsSamplesPathname = Path.Combine(Application.dataPath, "../PlatformSpecificAssets/" + subpath);
106+
string pathToInstallFrom = "";
107+
108+
if (Directory.Exists(packagePathname))
109+
{
110+
// Install from package path
111+
pathToInstallFrom = packagePathname;
112+
}
113+
else if (Directory.Exists(streamingAssetsSamplesPathname))
114+
{
115+
pathToInstallFrom = streamingAssetsSamplesPathname;
116+
}
117+
return pathToInstallFrom;
118+
}
119+
120+
//-------------------------------------------------------------------------
121+
bool DoesGradlePropertiesContainSetting(string gradleTemplatePathname, string setting)
122+
{
123+
// check if it contains the android.useAndroidX=true
124+
foreach (string line in File.ReadAllLines(gradleTemplatePathname))
125+
{
126+
if (line.Contains(setting) && !line.StartsWith("#"))
127+
{
128+
return true;
129+
}
130+
}
131+
return false;
132+
}
133+
134+
//-------------------------------------------------------------------------
135+
void ReplaceOrSetGradleProperty(string gradleTemplatePathname, string setting, string value)
136+
{
137+
var gradleTemplateToWrite = new List<string>();
138+
bool wasAdded = false;
139+
140+
foreach(string line in File.ReadAllLines(gradleTemplatePathname))
141+
{
142+
if (line.Contains(setting) && !line.StartsWith("#"))
143+
{
144+
gradleTemplateToWrite.Add($"{setting}={value}");
145+
wasAdded = true;
146+
}
147+
else
148+
{
149+
gradleTemplateToWrite.Add(line);
150+
}
151+
}
152+
153+
if (!wasAdded)
154+
{
155+
gradleTemplateToWrite.Add($"{setting}={value}");
156+
}
157+
File.WriteAllLines(gradleTemplatePathname, gradleTemplateToWrite.ToArray());
158+
}
159+
160+
//-------------------------------------------------------------------------
161+
public void InstallEOSDependentLibrary()
162+
{
163+
string packagedPathname = GetPlatformSpecificAssetsPath("EOS/Android/");
164+
165+
if (Directory.Exists(packagedPathname))
166+
{
167+
string assetsPathname = Path.Combine(Application.dataPath, "Plugins/Android/EOS/");
168+
string[] filenames =
169+
{
170+
"eos_dependencies.androidlib/AndroidManifest.xml",
171+
"eos_dependencies.androidlib/build.gradle",
172+
"eos_dependencies.androidlib/project.properties",
173+
"eos_dependencies.androidlib/res/values/eos_values.xml",
174+
"eos_dependencies.androidlib/res/values/styles.xml"
175+
176+
};
177+
InstallFiles(filenames, packagedPathname, assetsPathname);
178+
179+
// Unity has a fixed location for the gradleTemplate.properties file. (as of 2021)
180+
string gradleTemplatePathname = Path.Combine(Application.dataPath, "Plugins/Android/gradleTemplate.properties");
181+
if (File.Exists(gradleTemplatePathname))
182+
{
183+
if (!DoesGradlePropertiesContainSetting(gradleTemplatePathname, "android.useAndroidX=true"))
184+
{
185+
ReplaceOrSetGradleProperty(gradleTemplatePathname, "android.useAndroidX", "true");
186+
}
187+
}
188+
else
189+
{
190+
// Use one we have bundled
191+
string bundledGradleTemplatePathname = GetPlatformSpecificAssetsPath("EOS/Android/gradleTemplate.properties");
192+
File.Copy(bundledGradleTemplatePathname, gradleTemplatePathname);
193+
}
194+
}
195+
}
196+
197+
//-------------------------------------------------------------------------
198+
public void ConfigureEOSDependentLibrary()
199+
{
200+
string configFilePath = Path.Combine(Application.streamingAssetsPath, "EOS", EOSManager.ConfigFileName);
201+
var eosConfigFile = new EOSConfigFile<EOSConfig>(configFilePath);
202+
eosConfigFile.LoadConfigFromDisk();
203+
string clientIDAsLower = eosConfigFile.currentEOSConfig.clientID.ToLower();
204+
205+
var pathToEOSValuesConfig = GetAndroidEOSValuesConfigPath();
206+
var currentEOSValuesConfigAsXML = new System.Xml.XmlDocument();
207+
currentEOSValuesConfigAsXML.Load(pathToEOSValuesConfig);
208+
209+
var node = currentEOSValuesConfigAsXML.DocumentElement.SelectSingleNode("/resources");
210+
211+
if (node != null)
212+
{
213+
string eosProtocolScheme = node.InnerText;
214+
string storedClientID = eosProtocolScheme.Split(".").Last();
215+
216+
if (storedClientID != clientIDAsLower)
217+
{
218+
node.InnerText = $"eos.{clientIDAsLower}";
219+
currentEOSValuesConfigAsXML.Save(pathToEOSValuesConfig);
220+
}
221+
}
222+
}
223+
224+
}

Assets/Plugins/AndroidEditor/Editor/EOSOnPreprocessBuild_android.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins/Linux/EOSManager_Linux.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public string OverrideLibraryPath
9191
{
9292
set
9393
{
94-
if(m_OverrideLibraryPath != null)
94+
if(m_OverrideLibraryPath != IntPtr.Zero)
9595
{
9696
Marshal.FreeHGlobal(m_OverrideLibraryPath);
9797
}
@@ -114,7 +114,7 @@ public string OverrideLibraryPath
114114

115115
public void Dispose()
116116
{
117-
if (m_OverrideLibraryPath != null)
117+
if (m_OverrideLibraryPath != IntPtr.Zero)
118118
{
119119
Marshal.FreeHGlobal(m_OverrideLibraryPath);
120120
}
@@ -294,7 +294,7 @@ public void ConfigureSystemPlatformCreateOptions(ref IEOSCreateOptions createOpt
294294

295295
string SteamDllVersion = DLLHandle.GetVersionForLibrary(SteamDllName);
296296

297-
if (steamIntegratedPlatform.m_OverrideLibraryPath != null)
297+
if (steamIntegratedPlatform.m_OverrideLibraryPath != IntPtr.Zero)
298298
{
299299
SteamOptionsGCHandle = GCHandle.Alloc(steamIntegratedPlatform, GCHandleType.Pinned);
300300
integratedPlatforms[0].InitOptions = SteamOptionsGCHandle.AddrOfPinnedObject();

Assets/Plugins/Source/EOSManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public void Init(IEOSCoroutineOwner coroutineOwner, string configFileName)
528528

529529
string configDataAsString = "";
530530

531-
#if UNITY_ANDROID && EOS_PREVIEW_PLATFORM
531+
#if UNITY_ANDROID
532532

533533
configDataAsString = AndroidFileIOHelper.ReadAllText(eosFinalConfigPath);
534534
#else
@@ -1147,7 +1147,7 @@ public void StartLoginWithLoginOptions(Epic.OnlineServices.Auth.LoginOptions log
11471147

11481148
print("StartLoginWithLoginTypeAndToken");
11491149

1150-
#if UNITY_IOS && !UNITY_EDITOR && EOS_PREVIEW_PLATFORM
1150+
#if UNITY_IOS && !UNITY_EDITOR
11511151
IOSLoginOptions modifiedLoginOptions = (EOSManagerPlatformSpecifics.Instance as EOSPlatformSpecificsiOS).MakeIOSLoginOptionsFromDefualt(loginOptions);
11521152
EOSAuthInterface.Login(ref modifiedLoginOptions, null, (Epic.OnlineServices.Auth.OnLoginCallback)((ref Epic.OnlineServices.Auth.LoginCallbackInfo data) => {
11531153
#else
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using UnityEditor;
2+
using UnityEditor.Build;
3+
using UnityEditor.Build.Reporting;
4+
using UnityEngine;
5+
using System.IO;
6+
using PlayEveryWare.EpicOnlineServices;
7+
8+
public class EOSOnPreprocessBuild : IPreprocessBuildWithReport
9+
{
10+
public int callbackOrder { get { return 0; } }
11+
public void OnPreprocessBuild(BuildReport report)
12+
{
13+
//if (report.summary.platform == BuildTarget.StandaloneWindows || report.summary.platform == BuildTarget.StandaloneWindows64)
14+
15+
Debug.Log("MyCustomBuildProcessor.OnPreprocessBuild for target " + report.summary.platform + " at path " + report.summary.outputPath);
16+
17+
AutoSetProductVersion();
18+
}
19+
20+
public void AutoSetProductVersion()
21+
{
22+
var eosVersionConfigSection = EOSPluginEditorConfigEditor.GetConfigurationSectionEditor<EOSPluginEditorPrebuildConfigSection>();
23+
24+
if (eosVersionConfigSection == null)
25+
{
26+
return;
27+
}
28+
29+
eosVersionConfigSection.Awake();
30+
31+
string configFilePath = Path.Combine(Application.streamingAssetsPath, "EOS", EOSManager.ConfigFileName);
32+
var eosConfigFile = new EOSConfigFile<EOSConfig>(configFilePath);
33+
eosConfigFile.LoadConfigFromDisk();
34+
35+
var previousProdVer = eosConfigFile.currentEOSConfig.productVersion;
36+
var currentSectionConfig = eosVersionConfigSection.GetCurrentConfig();
37+
38+
if (currentSectionConfig == null)
39+
{
40+
return;
41+
}
42+
43+
if (currentSectionConfig.useAppVersionAsProductVersion)
44+
{
45+
eosConfigFile.currentEOSConfig.productVersion = Application.version;
46+
}
47+
48+
if (previousProdVer != eosConfigFile.currentEOSConfig.productVersion)
49+
{
50+
eosConfigFile.SaveToJSONConfig(true);
51+
}
52+
}
53+
}

Assets/Plugins/Source/Editor/EOSOnPreprocessBuild.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)