initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
@ -0,0 +1,14 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Unity.Services.Core.Registration")]
|
||||
[assembly: InternalsVisibleTo("Unity.Services.Core.Configuration.Editor")]
|
||||
[assembly: InternalsVisibleTo("Unity.Services.Core.TestUtils")]
|
||||
|
||||
// Test assemblies
|
||||
#if UNITY_INCLUDE_TESTS
|
||||
[assembly: InternalsVisibleTo("Unity.Services.Core.EditorTests")]
|
||||
[assembly: InternalsVisibleTo("Unity.Services.Core.Tests")]
|
||||
[assembly: InternalsVisibleTo("Unity.Services.Core.TestUtils.Tests")]
|
||||
[assembly: InternalsVisibleTo("Unity.Services.Core.TestUtils.EditorTests")]
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 784151075867944a995c363a19d75790
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,13 @@
|
|||
using UnityEngine;
|
||||
using Unity.Services.Core.Configuration.Internal;
|
||||
|
||||
namespace Unity.Services.Core.Configuration
|
||||
{
|
||||
class CloudProjectId : ICloudProjectId
|
||||
{
|
||||
public string GetCloudProjectId()
|
||||
{
|
||||
return Application.cloudProjectId;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ac89e17024bc24b4dbbc6c7d233b333f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Unity.Services.Core.Internal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.Services.Core.Configuration
|
||||
{
|
||||
static class ConfigurationCollectionHelper
|
||||
{
|
||||
public static void FillWith(
|
||||
this IDictionary<string, ConfigurationEntry> self, SerializableProjectConfiguration config)
|
||||
{
|
||||
for (var i = 0; i < config.Keys.Length; i++)
|
||||
{
|
||||
var entryKey = config.Keys[i];
|
||||
var entryValue = config.Values[i];
|
||||
|
||||
self.SetOrCreateEntry(entryKey, entryValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static void FillWith(
|
||||
this IDictionary<string, ConfigurationEntry> self, InitializationOptions options)
|
||||
{
|
||||
foreach (var option in options.Values)
|
||||
{
|
||||
var optionValue = Convert.ToString(option.Value, CultureInfo.InvariantCulture);
|
||||
self.SetOrCreateEntry(option.Key, optionValue);
|
||||
}
|
||||
}
|
||||
|
||||
static void SetOrCreateEntry(
|
||||
this IDictionary<string, ConfigurationEntry> self, string key, ConfigurationEntry entry)
|
||||
{
|
||||
if (self.TryGetValue(key, out var existingEntry))
|
||||
{
|
||||
if (!existingEntry.TrySetValue(entry))
|
||||
{
|
||||
CoreLogger.LogWarning(
|
||||
$"You are attempting to initialize Operate Solution SDK with an option \"{key}\"" +
|
||||
" which is readonly at runtime and can be modified only through Project Settings." +
|
||||
" The value provided as initialization option will be ignored." +
|
||||
$" Please update {nameof(InitializationOptions)} in order to remove this warning.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self[key] = entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8403e32bfcb112444bcc3a7f9ea043d1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,86 @@
|
|||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.Services.Core.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper for project configuration values.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
class ConfigurationEntry
|
||||
{
|
||||
[JsonRequired]
|
||||
[SerializeField]
|
||||
string m_Value;
|
||||
|
||||
/// <summary>
|
||||
/// Get the stored configuration value.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public string Value => m_Value;
|
||||
|
||||
[JsonRequired]
|
||||
[SerializeField]
|
||||
bool m_IsReadOnly;
|
||||
|
||||
/// <summary>
|
||||
/// If true, <see cref="Value"/> can't be changed.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get => m_IsReadOnly;
|
||||
internal set => m_IsReadOnly = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new instance of the <see cref="ConfigurationEntry"/> class.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Required for serialization.
|
||||
/// </remarks>
|
||||
public ConfigurationEntry() {}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new instance of the <see cref="ConfigurationEntry"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The value to store.
|
||||
/// </param>
|
||||
/// <param name="isReadOnly">
|
||||
/// If true, the value can't be changed after construction.
|
||||
/// </param>
|
||||
public ConfigurationEntry(string value, bool isReadOnly = false)
|
||||
{
|
||||
m_Value = value;
|
||||
m_IsReadOnly = isReadOnly;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set <see cref="Value"/> only if <see cref="IsReadOnly"/> is false.
|
||||
/// Does nothing otherwise.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The new value to store.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// Return true if <see cref="IsReadOnly"/> is false;
|
||||
/// return false otherwise.
|
||||
/// </returns>
|
||||
public bool TrySetValue(string value)
|
||||
{
|
||||
if (IsReadOnly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_Value = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static implicit operator string(ConfigurationEntry entry) => entry.Value;
|
||||
|
||||
public static implicit operator ConfigurationEntry(string value) => new ConfigurationEntry(value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: de9e8083c7ded62419890100100933a1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
|||
namespace Unity.Services.Core.Configuration
|
||||
{
|
||||
static class ConfigurationUtils
|
||||
{
|
||||
public const string ConfigFileName = "UnityServicesProjectConfiguration.json";
|
||||
|
||||
public static IConfigurationLoader ConfigurationLoader { get; internal set; }
|
||||
= new StreamingAssetsConfigurationLoader();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 249a2fdb5bd0534428138ffd827b1db5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using Unity.Services.Core.Configuration.Internal;
|
||||
|
||||
namespace Unity.Services.Core.Configuration
|
||||
{
|
||||
class ExternalUserId : IExternalUserId
|
||||
{
|
||||
public string UserId => UnityServices.ExternalUserIdProperty.UserId;
|
||||
|
||||
public event Action<string> UserIdChanged
|
||||
{
|
||||
add => UnityServices.ExternalUserIdProperty.UserIdChanged += value;
|
||||
remove => UnityServices.ExternalUserIdProperty.UserIdChanged -= value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c23475166c0634642a1feebc28f06c4d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace Unity.Services.Core.Configuration
|
||||
{
|
||||
interface IConfigurationLoader
|
||||
{
|
||||
Task<SerializableProjectConfiguration> GetConfigAsync();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 329750b2a7303a4469bcbd1fa0b517a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace Unity.Services.Core.Configuration
|
||||
{
|
||||
class MemoryConfigurationLoader : IConfigurationLoader
|
||||
{
|
||||
public SerializableProjectConfiguration Config { get; set; }
|
||||
|
||||
Task<SerializableProjectConfiguration> IConfigurationLoader.GetConfigAsync()
|
||||
{
|
||||
var completionSource = new TaskCompletionSource<SerializableProjectConfiguration>();
|
||||
completionSource.SetResult(Config);
|
||||
return completionSource.Task;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 63b177b347759a44592a524a22a1b36f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,72 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Unity.Services.Core.Configuration.Internal;
|
||||
|
||||
namespace Unity.Services.Core.Configuration
|
||||
{
|
||||
class ProjectConfiguration : IProjectConfiguration
|
||||
{
|
||||
string m_JsonCache;
|
||||
readonly IReadOnlyDictionary<string, ConfigurationEntry> m_ConfigValues;
|
||||
|
||||
public ProjectConfiguration(IReadOnlyDictionary<string, ConfigurationEntry> configValues)
|
||||
{
|
||||
m_ConfigValues = configValues;
|
||||
}
|
||||
|
||||
public bool GetBool(string key, bool defaultValue = default)
|
||||
{
|
||||
var stringConfig = GetString(key);
|
||||
if (bool.TryParse(stringConfig, out var parsedValue))
|
||||
{
|
||||
return parsedValue;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public int GetInt(string key, int defaultValue = default)
|
||||
{
|
||||
var stringConfig = GetString(key);
|
||||
if (int.TryParse(stringConfig, out var parsedValue))
|
||||
{
|
||||
return parsedValue;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public float GetFloat(string key, float defaultValue = default)
|
||||
{
|
||||
var stringConfig = GetString(key);
|
||||
if (float.TryParse(stringConfig, NumberStyles.Float, CultureInfo.InvariantCulture, out var parsedValue))
|
||||
{
|
||||
return parsedValue;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public string GetString(string key, string defaultValue = default)
|
||||
{
|
||||
if (m_ConfigValues.TryGetValue(key, out var configValue))
|
||||
{
|
||||
return configValue.Value;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public string ToJson()
|
||||
{
|
||||
if (m_JsonCache == null)
|
||||
{
|
||||
var dict = m_ConfigValues.ToDictionary(pair => pair.Key, pair => pair.Value.Value);
|
||||
m_JsonCache = JsonConvert.SerializeObject(dict);
|
||||
}
|
||||
return m_JsonCache;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2458d7ed2cd22964bb2de41ded78bca8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.Services.Core.Configuration
|
||||
{
|
||||
[Serializable]
|
||||
struct SerializableProjectConfiguration
|
||||
{
|
||||
public static SerializableProjectConfiguration Empty
|
||||
=> new SerializableProjectConfiguration
|
||||
{
|
||||
Keys = Array.Empty<string>(),
|
||||
Values = Array.Empty<ConfigurationEntry>(),
|
||||
};
|
||||
|
||||
[JsonRequired]
|
||||
[SerializeField]
|
||||
internal string[] Keys;
|
||||
|
||||
[JsonRequired]
|
||||
[SerializeField]
|
||||
internal ConfigurationEntry[] Values;
|
||||
|
||||
public SerializableProjectConfiguration(IDictionary<string, ConfigurationEntry> configValues)
|
||||
{
|
||||
Keys = new string[configValues.Count];
|
||||
Values = new ConfigurationEntry[configValues.Count];
|
||||
|
||||
var i = 0;
|
||||
foreach (var configValue in configValues)
|
||||
{
|
||||
Keys[i] = configValue.Key;
|
||||
Values[i] = configValue.Value;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 17c935ca4d9d95048931d5aec5d99d97
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
|||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Unity.Services.Core.Configuration
|
||||
{
|
||||
class StreamingAssetsConfigurationLoader : IConfigurationLoader
|
||||
{
|
||||
public async Task<SerializableProjectConfiguration> GetConfigAsync()
|
||||
{
|
||||
var jsonConfig = await StreamingAssetsUtils.GetFileTextFromStreamingAssetsAsync(
|
||||
ConfigurationUtils.ConfigFileName);
|
||||
var config = JsonConvert.DeserializeObject<SerializableProjectConfiguration>(jsonConfig);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f5d7186a4ae434942afddf441cccaa67
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,3 @@
|
|||
// This file is generated. Do not modify by hand.
|
||||
// XML documentation file not found. To check if public methods have XML comments,
|
||||
// make sure the XML doc file is present and located next to the scraped dll
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3fdb983cd9c6943db94f76b0e6462317
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "Unity.Services.Core.Configuration",
|
||||
"references": [
|
||||
"Unity.Services.Core.Internal",
|
||||
"Unity.Services.Core"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4077802dea91b4b6d878b48b4160bd81
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: abf176c60f5545c4e84eeca86e38a31a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,38 @@
|
|||
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_WEBGL)
|
||||
#define READ_STREMAING_ASSETS_WITH_WEB_REQUEST
|
||||
#endif
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
#if READ_STREMAING_ASSETS_WITH_WEB_REQUEST
|
||||
using Unity.Services.Core.Internal;
|
||||
#endif
|
||||
|
||||
namespace Unity.Services.Core.Configuration
|
||||
{
|
||||
static class StreamingAssetsUtils
|
||||
{
|
||||
public static Task<string> GetFileTextFromStreamingAssetsAsync(string path)
|
||||
{
|
||||
var fullPath = Path.Combine(Application.streamingAssetsPath, path);
|
||||
#if READ_STREMAING_ASSETS_WITH_WEB_REQUEST
|
||||
return UnityWebRequestUtils.GetTextAsync(fullPath);
|
||||
#else
|
||||
var completionSource = new TaskCompletionSource<string>();
|
||||
try
|
||||
{
|
||||
var fileText = File.ReadAllText(fullPath);
|
||||
completionSource.SetResult(fileText);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
completionSource.SetException(e);
|
||||
}
|
||||
|
||||
return completionSource.Task;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3fefd9c9a0e33734aba3b2fc03b44585
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue