diff --git a/Assets/Noble Connect.meta b/Assets/Noble Connect.meta new file mode 100644 index 0000000..fe010b7 --- /dev/null +++ b/Assets/Noble Connect.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 47960fcc1509505478abb826d0ddd57b +folderAsset: yes +timeCreated: 1538747955 +licenseType: Store +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Common.meta b/Assets/Noble Connect/Common.meta new file mode 100644 index 0000000..6c8751f --- /dev/null +++ b/Assets/Noble Connect/Common.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f8b65a10719a36e458516ffd952b1bc7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Common/Config.cs b/Assets/Noble Connect/Common/Config.cs new file mode 100644 index 0000000..c26e8e9 --- /dev/null +++ b/Assets/Noble Connect/Common/Config.cs @@ -0,0 +1,123 @@ +using NobleConnect.Ice; +using System; +using System.Text; +using UnityEngine; + +namespace NobleConnect +{ + [Serializable] + public class Config + { + [NonSerialized] + public ushort IcePort; + [NonSerialized] + public string Username; + [NonSerialized] + public string Password; + [NonSerialized] + public string Origin; + [NonSerialized] + public bool UseSimpleAddressGathering = false; + + public Action OnFatalError; + public Action OnOfferFailed; + + /// The geographic region to use when selecting a relay server. + /// + /// Defaults to AUTO which will automatically select the closest region. + /// This is useful if you would like your players to be able to choose + /// their region at run time. + /// Note that players are not prevented from connecting across regions. + /// That would need to be implementing separately via matchmaking for + /// example, by filtering out matches from undesired regions. + /// + [Tooltip("The geographic region to use when selecting a relay server.")] + public GeographicRegion Region; + + /// You can enable this to force relay connections to be used for testing purposes. + /// + /// Disables punchthrough and direct connections. Forces connections to use the relays. + /// This is useful if you want to test your game with the unavoidable latency that is + /// introduced when the relay servers are used. + /// + [Tooltip("Enable this to force relay connections to be used for testing purposes.")] + public bool ForceRelayOnly = false; + + /// By default IPv6 is enabled, but you can disable it if you're using a transport that does not support IPv6 + [Tooltip("By default IPv6 is enabled, but you can disable it if you're using a transport that does not support IPv6.")] + public bool EnableIPv6 = true; + + /// Request timeout. + /// + /// This effects how long to wait before considering a request to have failed. + /// Requests are used during the punchthrough process and for setting up and maintaining relays. + /// If you are allowing cross-region play or expect high latency you can increase this so that requests won't time out. + /// The drawback is that waiting longer for timeouts causes it take take longer to detect actual failed requests so the + /// connection process may take longer. + /// + [Tooltip("How long to wait before considering a request to have failed.")] + public float RequestTimeout = .2f; + + /// Initial timeout before resending refresh messages. This is doubled for each failed resend. + [Tooltip("Initial timeout before resending refresh messages. This is doubled for each failed resend.")] + public float RelayRequestTimeout = .1f; + + /// Max number of times to try and resend refresh messages before giving up and shutting down the relay connection. + [Tooltip("Max number of times to try and resend refresh messages before giving up and shutting down the relay connection.")] + public int RelayRefreshMaxAttempts = 8; + + /// How long a relay will stay alive without being refreshed + /// + /// Setting this value higher means relays will stay alive longer even if the host temporarily loses connection or otherwise fails to send the refresh request in time. + /// This can be helpful to maintain connection on an undependable network or when heavy application load (such as loading large levels synchronously) temporarily prevents requests from being processed. + /// The drawback is that CCU is used for as long as the relay stays alive, so players that crash or otherwise don't clean up properly can cause lingering CCU usage for up to relayLifetime seconds. + /// + [Tooltip("How long a relay will stay alive without being refreshed.")] + public int RelayLifetime = 60; + + /// How often to send relay refresh requests. + [Tooltip("How often to send relay refresh requests.")] + public int RelayRefreshTime = 30; + + public IceConfig AsIceConfig() + { + // Get a reference to the NobleConnectSettings + var settings = (NobleConnectSettings)Resources.Load("NobleConnectSettings", typeof(NobleConnectSettings)); + + // Parse the username, password, and origin from the game id + string username = "", password = "", origin = ""; + if (!string.IsNullOrEmpty(settings.gameID)) + { + string decodedGameID = Encoding.UTF8.GetString(Convert.FromBase64String(settings.gameID)); + string[] parts = decodedGameID.Split('\n'); + + if (parts.Length == 3) + { + username = parts[1]; + password = parts[2]; + origin = parts[0]; + } + } + + var iceConfig = new IceConfig { + iceServerAddress = RegionURL.FromRegion(Region), + icePort = settings.relayServerPort, + username = username, + password = password, + origin = origin, + useSimpleAddressGathering = (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android) && !Application.isEditor, + onFatalError = OnFatalError, + onOfferFailed = () => OnFatalError("Offer failed"), + forceRelayOnly = ForceRelayOnly, + enableIPv6 = EnableIPv6, + RequestTimeout = RequestTimeout, + RelayRequestTimeout = RelayRequestTimeout, + RelayRefreshMaxAttempts = RelayRefreshMaxAttempts, + RelayLifetime = RelayLifetime, + RelayRefreshTime = RelayRefreshTime + }; + + return iceConfig; + } + } +} \ No newline at end of file diff --git a/Assets/Noble Connect/Common/Config.cs.meta b/Assets/Noble Connect/Common/Config.cs.meta new file mode 100644 index 0000000..963ea09 --- /dev/null +++ b/Assets/Noble Connect/Common/Config.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 959d07654e99fd345a7ae965ae68fad7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Common/Noble Example Player.png b/Assets/Noble Connect/Common/Noble Example Player.png new file mode 100644 index 0000000..dc252ad Binary files /dev/null and b/Assets/Noble Connect/Common/Noble Example Player.png differ diff --git a/Assets/Noble Connect/Common/Noble Example Player.png.meta b/Assets/Noble Connect/Common/Noble Example Player.png.meta new file mode 100644 index 0000000..36ace77 --- /dev/null +++ b/Assets/Noble Connect/Common/Noble Example Player.png.meta @@ -0,0 +1,140 @@ +fileFormatVersion: 2 +guid: 2c0f41f48ef7e7248a5db28d31441b2c +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + applyGammaDecoding: 1 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + - serializedVersion: 3 + buildTarget: Windows Store Apps + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 1 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Common/NobleConnectSettings.cs b/Assets/Noble Connect/Common/NobleConnectSettings.cs new file mode 100644 index 0000000..9c08c7b --- /dev/null +++ b/Assets/Noble Connect/Common/NobleConnectSettings.cs @@ -0,0 +1,19 @@ +using UnityEngine; + +namespace NobleConnect +{ + /// Settings used by Noble Connect to authenticate with the relay and punchthrough services + public class NobleConnectSettings : ScriptableObject + { + /// Used to identify your game and authenticate with the relay servers + /// + /// This is populated for you when you go through the setup wizard but you can also set it manually here. + /// Your game ID is available any time on the dashboard at noblewhale.com + /// + [Tooltip("Used to identify your game and authenticate with the relay servers")] + public string gameID; + + [HideInInspector] + public ushort relayServerPort = 3478; + } +} diff --git a/Assets/Noble Connect/Common/NobleConnectSettings.cs.meta b/Assets/Noble Connect/Common/NobleConnectSettings.cs.meta new file mode 100644 index 0000000..8ee34e2 --- /dev/null +++ b/Assets/Noble Connect/Common/NobleConnectSettings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0154c6ffa997c574c9f0f2680c03e82f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Common/TextFromFile.cs b/Assets/Noble Connect/Common/TextFromFile.cs new file mode 100644 index 0000000..6dc6ae9 --- /dev/null +++ b/Assets/Noble Connect/Common/TextFromFile.cs @@ -0,0 +1,15 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace NobleConnect.Examples +{ + public class TextFromFile : MonoBehaviour + { + public TextAsset TextFile; + + void OnValidate() + { + GetComponent().text = TextFile.text; + } + } +} diff --git a/Assets/Noble Connect/Common/TextFromFile.cs.meta b/Assets/Noble Connect/Common/TextFromFile.cs.meta new file mode 100644 index 0000000..6ce9140 --- /dev/null +++ b/Assets/Noble Connect/Common/TextFromFile.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 35c73af1cf66d43448d976a70078d546 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Common/UnityLogger.cs b/Assets/Noble Connect/Common/UnityLogger.cs new file mode 100644 index 0000000..3094ffb --- /dev/null +++ b/Assets/Noble Connect/Common/UnityLogger.cs @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace NobleConnect +{ + public class UnityLogger + { + public static void Init() + { + Logger.logger = Debug.Log; + Logger.warnLogger = Debug.LogWarning; + Logger.errorLogger = Debug.LogError; + //Logger.logLevel = Logger.Level.Developer; + } + } +} diff --git a/Assets/Noble Connect/Common/UnityLogger.cs.meta b/Assets/Noble Connect/Common/UnityLogger.cs.meta new file mode 100644 index 0000000..cbf85cb --- /dev/null +++ b/Assets/Noble Connect/Common/UnityLogger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 59351c3313ddebb45a3153e4cc90a575 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Common/white.png b/Assets/Noble Connect/Common/white.png new file mode 100644 index 0000000..fd1468e Binary files /dev/null and b/Assets/Noble Connect/Common/white.png differ diff --git a/Assets/Noble Connect/Common/white.png.meta b/Assets/Noble Connect/Common/white.png.meta new file mode 100644 index 0000000..b274911 --- /dev/null +++ b/Assets/Noble Connect/Common/white.png.meta @@ -0,0 +1,77 @@ +fileFormatVersion: 2 +guid: e07dc4a0a043f9b4ab82f3967dcb9a2a +timeCreated: 1551016206 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Editor.meta b/Assets/Noble Connect/Editor.meta new file mode 100644 index 0000000..d13af3d --- /dev/null +++ b/Assets/Noble Connect/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 537f111e71c987b409f64bd60743a6b2 +folderAsset: yes +timeCreated: 1539153299 +licenseType: Store +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Editor/AddNobleConnectScriptingDefine.cs b/Assets/Noble Connect/Editor/AddNobleConnectScriptingDefine.cs new file mode 100644 index 0000000..6561d51 --- /dev/null +++ b/Assets/Noble Connect/Editor/AddNobleConnectScriptingDefine.cs @@ -0,0 +1,52 @@ +#if UNITY_EDITOR +using System.Collections.Generic; +using System.Linq; +using UnityEditor; + +namespace NobleConnect +{ + /// + /// Adds the given define symbols to PlayerSettings define symbols. + /// Just add your own define symbols to the Symbols property at the below. + /// + [InitializeOnLoad] + public class AddNobleConnectScriptingDefine : Editor + { + + /// + /// Symbols that will be added to the editor + /// + public static readonly string[] Symbols = new string[] { + "NOBLE_CONNECT", // Noble Connect exists + "NOBLE_CONNECT_1", // Major version + "NOBLE_CONNECT_1_37" // Major and minor version + }; + + /// + /// Add define symbols as soon as Unity gets done compiling. + /// + static AddNobleConnectScriptingDefine() + { + // Get the current scripting defines + string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup); + // Convert the string to a list + List allDefines = definesString.Split(';').ToList(); + // Remove any old version defines from previous installs + for (int i = allDefines.Count-1; i >= 0; i--) + { + if (allDefines[i].StartsWith("NOBLE_CONNECT") && !Symbols.Contains(allDefines[i])) + { + allDefines.RemoveAt(i); + } + } + // Add any symbols that weren't already in the list + allDefines.AddRange(Symbols.Except(allDefines)); + PlayerSettings.SetScriptingDefineSymbolsForGroup( + EditorUserBuildSettings.selectedBuildTargetGroup, + string.Join(";", allDefines.ToArray()) + ); + } + + } +} +#endif \ No newline at end of file diff --git a/Assets/Noble Connect/Editor/AddNobleConnectScriptingDefine.cs.meta b/Assets/Noble Connect/Editor/AddNobleConnectScriptingDefine.cs.meta new file mode 100644 index 0000000..2e18524 --- /dev/null +++ b/Assets/Noble Connect/Editor/AddNobleConnectScriptingDefine.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b53ae3111803795478bcbb739ad557f1 +timeCreated: 1551018990 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 35ce04e51d0abb847890436754a88096, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Editor/AmazonCertificateHandler.cs b/Assets/Noble Connect/Editor/AmazonCertificateHandler.cs new file mode 100644 index 0000000..31a2ddf --- /dev/null +++ b/Assets/Noble Connect/Editor/AmazonCertificateHandler.cs @@ -0,0 +1,42 @@ +using System; +using UnityEngine.Networking; +using System.Security.Cryptography.X509Certificates; +using UnityEngine; + +namespace NobleConnect.Internal +{ + #if !UNITY_5 && !UNITY_2017 + public class AmazonCertificateHandler : CertificateHandler + { + // Encoded RSAPublicKey + private static readonly string PUB_KEY = "3082010A0282010100CCCC0263917F8002CD937BEDCD06F29" + + "919F82E724EE5012E2C02991AD7FA06603D927975B099FF23" + + "CA94A876ED8F9871051ED81A13D1486534BCF1B07277DC0DA" + + "26C79C03B58590C9B2724917C68E3A10368ABFC214C20D8DF" + + "E3BC8ACE0519C776E9F9EC93FADD6C6A5E1CDA1A24867D67F" + + "EC0AF2B0DB8DD1BBB7D020331B7C0ECF838B57C73E6FF6722" + + "F17A9DF74391CFC4914B44B77655B79223E1E550F715AD6F1" + + "4BF3E755FFF815526C162BB3F379FFB5272D3C0EA59A35D1E" + + "9E49B94872EB768250BA3DBBFFD042015BDD2B1DFD164B950" + + "6D7DA324B63348122CE9EB368DB2FF0E02AD6B7A453A28B11" + + "E67591FC2CC0B74E1C80688C535D32DC692C08ED0203010001"; + + /// + /// Validate the Certificate Against the Amazon public Cert + /// + /// Certifcate to validate + /// + protected override bool ValidateCertificate(byte[] certificateData) + { + X509Certificate2 certificate = new X509Certificate2(certificateData); + string pk = certificate.GetPublicKeyString(); + if (pk.ToLower().Equals(PUB_KEY.ToLower())) + { + return true; + } + + return false; + } + } + #endif +} \ No newline at end of file diff --git a/Assets/Noble Connect/Editor/AmazonCertificateHandler.cs.meta b/Assets/Noble Connect/Editor/AmazonCertificateHandler.cs.meta new file mode 100644 index 0000000..1741b68 --- /dev/null +++ b/Assets/Noble Connect/Editor/AmazonCertificateHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a832db3337d4187499b35f1b02b16042 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Editor/Noble Setup Title Background.png b/Assets/Noble Connect/Editor/Noble Setup Title Background.png new file mode 100644 index 0000000..1d4ab9b Binary files /dev/null and b/Assets/Noble Connect/Editor/Noble Setup Title Background.png differ diff --git a/Assets/Noble Connect/Editor/Noble Setup Title Background.png.meta b/Assets/Noble Connect/Editor/Noble Setup Title Background.png.meta new file mode 100644 index 0000000..3696997 --- /dev/null +++ b/Assets/Noble Connect/Editor/Noble Setup Title Background.png.meta @@ -0,0 +1,77 @@ +fileFormatVersion: 2 +guid: e2718437b8b970d43918120542ad4bcd +timeCreated: 1539817181 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Editor/SetupWizard.cs b/Assets/Noble Connect/Editor/SetupWizard.cs new file mode 100644 index 0000000..8696fd3 --- /dev/null +++ b/Assets/Noble Connect/Editor/SetupWizard.cs @@ -0,0 +1,386 @@ +using System; +using System.Collections; +using System.Text; +using NobleConnect; +using UnityEditor; +using UnityEngine; +using UnityEngine.Networking; + +public class SetupWizard : EditorWindow +{ + const string windowTitle = "Noble Connect"; + const string titleText = "Noble Connect Setup"; + const string bodyText = "\nEnter your game id or email address to enable Noble Connect.\n\n" + + "The service is free to use for development but bandwidth and CCU is limited.\n" + + "Visit noblewhale.com to upgrade to a paid account and remove the bandwidth and CCU limits."; + const string signUpSuccessText = "Successful account signup. \n\n" + + "Load up an example to get started or visit our website to upgrade to a paid account.\n"; + const string accountAlreadyExistsText = "User already exists. \n\n" + + "Log in at noblewhale.com to get your game ID.\n"; + const string otherErrorText = "An error has occurred. \n\n" + + "Log in at noblewhale.com to get your game ID.\n"; + const string enteredGameIDText = "GameID entered. \n\n" + + "Welcome back. Visit noblewhale.com to upgrade to a paid account\n" + + "and remove the bandwidth and CCU limits.\n"; + Texture2D logo, bg; + + GUIStyle headerStyle = new GUIStyle(); + GUIStyle titleStyle = new GUIStyle(); + GUIStyle logoStyle = new GUIStyle(); + GUIStyle bodyStyle = new GUIStyle(); + GUIStyle secondScreenStyle = new GUIStyle(); + + bool clickedActivate = false; + bool accountActivated = false; + bool accountAlreadyExists = false; + bool otherError = false; + bool enteredGameID = false; + + IEnumerator createAccountRequest; + + string emailOrGameID; + + SetupWizard() + { + minSize = new Vector2(530, 300); + } + + void OnEnable() + { + if (logo == null) + { + string[] paths = AssetDatabase.FindAssets("whale_256 t:Texture2D"); + if (paths != null && paths.Length > 0) + { + logo = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(paths[0])); + } + } + if (bg == null) + { + string[] paths = AssetDatabase.FindAssets("Noble Setup Title Background t:Texture2D"); + if (paths != null && paths.Length > 0) + { + bg = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(paths[0])); + } + } + } + + void Update() + { + if (createAccountRequest != null) createAccountRequest.MoveNext(); + } + + void OnGUI() + { + DrawHeader(); + + if (!accountActivated && !accountAlreadyExists && !otherError && !enteredGameID) + { + bodyStyle.padding = new RectOffset(10, 10, 0, 5); + EditorGUILayout.BeginVertical(bodyStyle); + + GUILayout.Label(bodyText); + GUILayout.Label("\nEmail or Game ID"); + emailOrGameID = EditorGUILayout.TextField(emailOrGameID); + + EditorGUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + if (!clickedActivate && GUILayout.Button("Activate")) + { + createAccountRequest = ActivateAccount(); + } + EditorGUILayout.EndHorizontal(); + EditorGUILayout.EndVertical(); + } + // Account creation success. + if (accountActivated) + { + bodyStyle.padding = new RectOffset(15, 10, 15, 5); + EditorGUILayout.BeginVertical(bodyStyle); + GUILayout.Label(signUpSuccessText); + EditorGUILayout.EndVertical(); + EditorGUILayout.BeginVertical(secondScreenStyle); + EditorGUILayout.BeginHorizontal(); + secondScreenStyle.padding = new RectOffset(15, Screen.width, 10, 5); + if (GUILayout.Button("Sign Up for Pro")) + { + Application.OpenURL("http://noblewhale.com"); + } + EditorGUILayout.EndHorizontal(); + EditorGUILayout.EndVertical(); + EditorGUILayout.BeginVertical(secondScreenStyle); + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Close Window")) + { + this.Close(); + } + EditorGUILayout.EndHorizontal(); + EditorGUILayout.EndVertical(); + } + // Found account with this email already. + else if (accountAlreadyExists) + { + bodyStyle.padding = new RectOffset(15, 10, 15, 5); + //GUI.contentColor = Color.red; + //bodyStyle.normal.textColor = Color.red; + EditorGUILayout.BeginVertical(bodyStyle); + GUILayout.Label(accountAlreadyExistsText);// secondScreenStyle); + EditorGUILayout.EndVertical(); + EditorGUILayout.BeginVertical(secondScreenStyle); + EditorGUILayout.BeginHorizontal(); + secondScreenStyle.padding = new RectOffset(15, Screen.width, 10, 5); + if (GUILayout.Button("Go to noblewhale.com")) + { + Application.OpenURL("http://noblewhale.com"); + } + EditorGUILayout.EndHorizontal(); + EditorGUILayout.EndVertical(); + EditorGUILayout.BeginVertical(secondScreenStyle); + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Close Window")) + { + this.Close(); + } + EditorGUILayout.EndHorizontal(); + EditorGUILayout.EndVertical(); + } + else if (otherError) + { + bodyStyle.padding = new RectOffset(15, 10, 15, 5); + //bodyStyle.normal.textColor = new Color(204,0,0); + EditorGUILayout.BeginVertical(); + GUILayout.Label(otherErrorText, bodyStyle); + EditorGUILayout.EndVertical(); + //bodyStyle.normal.textColor = Color.black; + EditorGUILayout.BeginVertical(secondScreenStyle); + EditorGUILayout.BeginHorizontal(); + secondScreenStyle.padding = new RectOffset(15, Screen.width, 10, 5); + if (GUILayout.Button("Go to noblewhale.com")) + { + Application.OpenURL("http://noblewhale.com"); + } + EditorGUILayout.EndHorizontal(); + EditorGUILayout.EndVertical(); + EditorGUILayout.BeginVertical(secondScreenStyle); + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Close Window")) + { + this.Close(); + } + EditorGUILayout.EndHorizontal(); + EditorGUILayout.EndVertical(); + } + else if (enteredGameID) + { + bodyStyle.padding = new RectOffset(15, 10, 15, 5); + //bodyStyle.normal.textColor = new Color(204,0,0); + EditorGUILayout.BeginVertical(); + GUILayout.Label(enteredGameIDText, bodyStyle); + EditorGUILayout.EndVertical(); + //bodyStyle.normal.textColor = Color.black; + EditorGUILayout.BeginVertical(secondScreenStyle); + EditorGUILayout.BeginHorizontal(); + secondScreenStyle.padding = new RectOffset(15, Screen.width, 10, 5); + if (GUILayout.Button("Go to noblewhale.com")) + { + Application.OpenURL("http://noblewhale.com"); + } + EditorGUILayout.EndHorizontal(); + EditorGUILayout.EndVertical(); + EditorGUILayout.BeginVertical(secondScreenStyle); + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Close Window")) + { + this.Close(); + } + EditorGUILayout.EndHorizontal(); + EditorGUILayout.EndVertical(); + } + } + + IEnumerator ActivateAccount() + { + clickedActivate = true; + string gameID = emailOrGameID; + if (emailOrGameID.Contains("@")) + { + gameID = null; + WWWForm form = new WWWForm(); + form.AddField("username", emailOrGameID); + form.AddField("email", emailOrGameID); + +#if UNITY_5 || UNITY_2017 + WWW w = new WWW("https://robot:z3hZAY*1ESiq7ecUR&OxFFNO@noblewhale.com/wp-json/wp/v2/users", form); + + while (!w.isDone) yield return 0; + + if (w.error != null && w.error != "") + { + if (w.text.Contains("existing_user_login")) + { + Debug.LogError("User already exists. Log in at noblewhale.com to get your game ID."); + // TODO: Display error notification window + accountAlreadyExists = true; + } + else + { + Debug.LogError(w.error + " " + w.text); + otherError = true; + } + } + else + { + // Get the newly created game id from the response text + // Manually parsing some json to avoid third party libraries and a bunch of needless overhead + string key = "\"game_id_0\""; + int keyIndex = w.text.IndexOf(key); + int valueStartIndex = w.text.IndexOf("\"", keyIndex + key.Length + 1) + 1; + int valueEndIndex = w.text.IndexOf("\"", valueStartIndex + 1); + string value = w.text.Substring(valueStartIndex, valueEndIndex - valueStartIndex); + gameID = value; + + accountActivated = true; + } + + w.Dispose(); +#else + using (var w = UnityEngine.Networking.UnityWebRequest.Post("https://robot:z3hZAY*1ESiq7ecUR&OxFFNO@noblewhale.com/wp-json/wp/v2/users", form)) + { + var amazonCertificateHandler = new CertificateDisregarder(); + w.certificateHandler = amazonCertificateHandler; + + yield return w.SendWebRequest(); + while (!w.isDone) yield return 0; + + var result = w.downloadHandler.text; +#if UNITY_2020_1_OR_NEWER + if (w.result == UnityEngine.Networking.UnityWebRequest.Result.ConnectionError || w.result == UnityEngine.Networking.UnityWebRequest.Result.ProtocolError) +#else + if (w.isNetworkError || w.isHttpError) +#endif + { + if (result.Contains("existing_user_login")) + { + Debug.LogError("User already exists. Log in at noblewhale.com to get your game ID."); + // TODO: Display error notification window + accountAlreadyExists = true; + } + else + { + Debug.LogError(w.error + " " + result); + otherError = true; + } + } + else + { + // Get the newly created game id from the response text + // Manually parsing some json to avoid third party libraries and a bunch of needless overhead + Debug.Log(result); + + StringBuilder sb = new StringBuilder(); + foreach (var dict in w.GetResponseHeaders()) + { + sb.Append(dict.Key).Append(": \t[").Append(dict.Value).Append("]\n"); + } + + // Print Headers + Debug.Log(sb.ToString()); + + string key = "\"game_id_0\""; + int keyIndex = result.IndexOf(key); + int valueStartIndex = result.IndexOf("\"", keyIndex + key.Length + 1) + 1; + int valueEndIndex = result.IndexOf("\"", valueStartIndex + 1); + string value = result.Substring(valueStartIndex, valueEndIndex - valueStartIndex); + gameID = value; + + accountActivated = true; + } + } +#endif + } + else + { + enteredGameID = true; + // TODO: Test gameID somehow + } + + if (gameID != null) + { + var settings = (NobleConnectSettings)Resources.Load("NobleConnectSettings", typeof(NobleConnectSettings)); + if (!settings) + { + settings = ScriptableObject.CreateInstance(); + if (!AssetDatabase.IsValidFolder("Assets/Noble Connect")) + { + AssetDatabase.CreateFolder("Assets", "Noble Connect"); + } + if (!AssetDatabase.IsValidFolder("Assets/Noble Connect/Resources")) + { + AssetDatabase.CreateFolder("Assets/Noble Connect", "Resources"); + } + AssetDatabase.CreateAsset(settings, "Assets/Noble Connect/Resources/NobleConnectSettings.asset"); + } + settings.gameID = gameID; + EditorUtility.SetDirty(settings); + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + } + } + + void DrawHeader() + { + headerStyle.normal.background = bg; + headerStyle.fixedHeight = 68; + EditorGUILayout.BeginHorizontal(headerStyle); + + titleStyle.fontSize = 22; + titleStyle.fontStyle = FontStyle.Bold; + titleStyle.padding = new RectOffset(10, 10, 20, 10); + GUILayout.Label(titleText, titleStyle); + + GUILayout.FlexibleSpace(); + + logoStyle.fixedWidth = 50; + logoStyle.margin = new RectOffset(0, 11, 7, 7); + GUILayout.Label(logo, logoStyle); + + EditorGUILayout.EndHorizontal(); + } + + [MenuItem("Window/Noble Connect/Setup", false, 0)] + protected static void MenuItemOpenWizard() + { + GetWindow(typeof(SetupWizard), false, windowTitle, true); + } + + [InitializeOnLoad] + public class ShowSetupWizard : EditorWindow + { + static bool hasChecked = false; + static ShowSetupWizard() + { + EditorApplication.update += Update; + } + static void Update() + { + if (EditorApplication.timeSinceStartup > 3.0f && !hasChecked) + { + hasChecked = true; + var settings = (NobleConnectSettings)Resources.Load("NobleConnectSettings", typeof(NobleConnectSettings)); + if (!settings || (settings.gameID == "")) + { + SetupWizard window = (SetupWizard)GetWindow(typeof(SetupWizard)); + window.Show(); + } + } + } + } + + public class CertificateDisregarder : CertificateHandler + { + protected override bool ValidateCertificate(byte[] certificateData) + { + return true; + } + } +} \ No newline at end of file diff --git a/Assets/Noble Connect/Editor/SetupWizard.cs.meta b/Assets/Noble Connect/Editor/SetupWizard.cs.meta new file mode 100644 index 0000000..2feade4 --- /dev/null +++ b/Assets/Noble Connect/Editor/SetupWizard.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 6ed5d5a6469ade6438c50b3489f723a8 +timeCreated: 1551019118 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 35ce04e51d0abb847890436754a88096, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Editor/whale_256.png b/Assets/Noble Connect/Editor/whale_256.png new file mode 100644 index 0000000..dc252ad Binary files /dev/null and b/Assets/Noble Connect/Editor/whale_256.png differ diff --git a/Assets/Noble Connect/Editor/whale_256.png.meta b/Assets/Noble Connect/Editor/whale_256.png.meta new file mode 100644 index 0000000..ca4429f --- /dev/null +++ b/Assets/Noble Connect/Editor/whale_256.png.meta @@ -0,0 +1,117 @@ +fileFormatVersion: 2 +guid: 35ce04e51d0abb847890436754a88096 +timeCreated: 1551018934 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - buildTarget: Standalone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - buildTarget: iPhone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - buildTarget: Android + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - buildTarget: Windows Store Apps + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Mirror.meta b/Assets/Noble Connect/Mirror.meta new file mode 100644 index 0000000..b687291 --- /dev/null +++ b/Assets/Noble Connect/Mirror.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d1429e7cc1a99a1479ef93aac006070c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Mirror/INSTALL.md b/Assets/Noble Connect/Mirror/INSTALL.md new file mode 100644 index 0000000..b0ef41a --- /dev/null +++ b/Assets/Noble Connect/Mirror/INSTALL.md @@ -0,0 +1,3 @@ +Step 1: Download and import Mirror: https://assetstore.unity.com/packages/tools/network/mirror-129321 +Step 2: Import the package "Assets/Noble Connect/Mirror/Mirror Noble Connect.unitypackage" to add Mirror support to Noble Connect. +Step 3: Check out the example scenes in "Assets/Noble Connect/Mirror/Examples" to get started. \ No newline at end of file diff --git a/Assets/Noble Connect/Mirror/INSTALL.md.meta b/Assets/Noble Connect/Mirror/INSTALL.md.meta new file mode 100644 index 0000000..82db2e5 --- /dev/null +++ b/Assets/Noble Connect/Mirror/INSTALL.md.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8efcd80227d51204789cd37b3318fb67 +timeCreated: 1552034575 +licenseType: Store +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Mirror/Mirror Noble Connect.unitypackage.meta b/Assets/Noble Connect/Mirror/Mirror Noble Connect.unitypackage.meta new file mode 100644 index 0000000..550ac36 --- /dev/null +++ b/Assets/Noble Connect/Mirror/Mirror Noble Connect.unitypackage.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4677f09a6725cea43abfebd58f5f6ba7 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/NetCode for GameObjects.meta b/Assets/Noble Connect/NetCode for GameObjects.meta new file mode 100644 index 0000000..244e8c0 --- /dev/null +++ b/Assets/Noble Connect/NetCode for GameObjects.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e51f6bc6724c0df41b0ef45a5cd354f8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/NetCode for GameObjects/INSTALL.md b/Assets/Noble Connect/NetCode for GameObjects/INSTALL.md new file mode 100644 index 0000000..e47e8cb --- /dev/null +++ b/Assets/Noble Connect/NetCode for GameObjects/INSTALL.md @@ -0,0 +1,3 @@ +Step 1: Use the PackageManager to get NetCode for GameObjects +Step 2: Import the package "Assets/Noble Connect/NetCode for GameObjects/NetCode for GameObjects Noble Connect.unitypackage" to add NetCode for GameObjects support to Noble Connect. +Step 3: Check out the example scenes in "Assets/Noble Connect/NetCode for GameObjects/Examples" to get started. \ No newline at end of file diff --git a/Assets/Noble Connect/NetCode for GameObjects/INSTALL.md.meta b/Assets/Noble Connect/NetCode for GameObjects/INSTALL.md.meta new file mode 100644 index 0000000..f70a718 --- /dev/null +++ b/Assets/Noble Connect/NetCode for GameObjects/INSTALL.md.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 06e66bd298fb6824b8c530a0da552ba3 +timeCreated: 1552034575 +licenseType: Store +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/NetCode for GameObjects/NetCode for GameObjects Noble Connect.unitypackage.meta b/Assets/Noble Connect/NetCode for GameObjects/NetCode for GameObjects Noble Connect.unitypackage.meta new file mode 100644 index 0000000..83fd168 --- /dev/null +++ b/Assets/Noble Connect/NetCode for GameObjects/NetCode for GameObjects Noble Connect.unitypackage.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 078540d8d7d4dd644a7466811097da56 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/NobleConnect.dll b/Assets/Noble Connect/NobleConnect.dll new file mode 100644 index 0000000..2bf4436 Binary files /dev/null and b/Assets/Noble Connect/NobleConnect.dll differ diff --git a/Assets/Noble Connect/NobleConnect.dll.meta b/Assets/Noble Connect/NobleConnect.dll.meta new file mode 100644 index 0000000..0488e85 --- /dev/null +++ b/Assets/Noble Connect/NobleConnect.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 272f780a0da55bb43a85079e5ba1969f +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/README.md b/Assets/Noble Connect/README.md new file mode 100644 index 0000000..d8b35c5 --- /dev/null +++ b/Assets/Noble Connect/README.md @@ -0,0 +1,91 @@ +# README +[ +[**Website**](https://noblewhale.com) +| +[**Dashboard**](https://noblewhale.com/dashboard) +| +[**Docs**](https://noblewhale.com/docs) +| +[**FAQ**](https://noblewhale.com/faq) +| +[**Asset Store**](https://assetstore.unity.com/packages/tools/network/noble-connect-140535) +] + +Adds relays and punchthrough to UNet or Mirror. + +Guarantees your players can connect while reducing latency and saving you money by connecting players directly whenever possible. +Your players won't need to worry about forwarding ports or fiddling with router settings, they can just sit back, relax, and enjoy your beautiful game. + +Supports Windows, Linux, OSX, Android, and iOS. +Supports: + * UNet + * Mirror with KCP, LiteNetLib, or Ignorance transports + * NetCode for GameObjects with UnityTransport + +*Note: Web builds are not supported.* + +# How to Use +In order to use the Noble Connect relay and punchthrough services you will need to sign up for an account. You can do this on our +website or through the Unity Engine at Window->Noble Connect->Setup. It is free to sign up but your CCU and bandwidth will be limited. +In order to raise the limits you will either need to purchase the Starter Pack or one of the monthly plans. + +## Step 1 - Set up + 1. You can access the setup window at any time by going to Window->Noble Connect->Setup. + 2. Enter your email address to sign up, or enter your Game ID if you already have an account. + * You can get your Game ID any time from the dashboard at https://noblewhale.com/dashboard + 3. Import the package for your networking system: + * If you are using Mirror, import the "Mirror Noble Connect.unitypackage" + * Make sure you have the correct version of Mirror imported first. Usually this means the latest from the Asset Store, but you can check the description on the [Noble Connect](https://assetstore.unity.com/packages/tools/network/noble-connect-140535) page to confirm. + * If you are using UNet, import the "UNet Noble Connect.unitypackage" + * In 2019.1 or later you must first install the "Multiplayer HLAPI" package from the Unity Package Manager + * If you are using NetCode for Gameobjects, import the "NetCode for GameObjects Noble Connect.unitypackage" + +## Step 2 - Test it + 1. Add the "Noble Connect/[UNet or Mirror or Netcode for GameObjects]/Examples/Network Manager/Network Manager Example.unity" scene to the build settings. + 2. Build for your desired platform and run the build. + 3. Click "Host" in the build. + * Note the IP and port that are displayed, this is the address that clients will use to connect to the host. + 4. Run the Network Manager Example scene in the editor. + 5. Click "Client" and then enter the ip and port from the host. + 6. Click "Connect" to connect to the host. + * When the connection is complete you will see the connection type displayed on the client. + +# Examples +Check out the Example scenes and scripts to see common ways to get connected. Each example includes a README file with more detailed instructions. +If you need any more information don't hesitate to contact us at nobleconnect@noblewhale.com + +# What next? +Generally you should extend from the provided NobleNetworkManager. +If you prefer something a little lower level, you can also use the NobleServer and NobleClient classes directly to Listen() and Connect(). +Most things will work exactly the same as you are used to if you are familiar with UNet, Mirror, or Netcode for GameObjects + +**Note: For most methods that you override in NobleNetworkManager you will want to make sure to call the base method to avoid causing unexpected behaviour.** + +# Notes for UNet / Mirror +The main difference is that you will use the NobleNetworkManager instead of Unity or Mirror's NetworkManager, or the NobleServer and NobleClient instead of Unity's or Mirror's NetworkServer and NetworkClient. + +# Note for Netcode for GameObjects +Just make sure to use the NobleUnityTransport and you should be good to go. + +# General Notes +The host will not know the address that clients should connect to until it has been assigned by the Noble Connect servers. +You will need to override the OnServerPrepared() method or use the OnServerPreparedCallback to know when this has happened and to get the hostAddress and hostPort (collectively known as the HostEndPoint) +that clients should use to connect to the host. This is generally when you would create a match if you're using a matchmaking system. You can also get +the HostEndPoint address any time after it has been assigned via NobleServer.HostEndPoint or NobleNetworkManager.HostEndPoint or NobleUnityTransport.HostRelayEndPoint + +# Regions +By default the closest region will be selected automatically for relays. You can also manually select the region on the NobleNetworkManager or by passing in a GeographicRegion at runtime. +You can see this in any of the example scenes. + +We have servers in the following regions: + * US_EAST - New York + * US_WEST - California + * EUROPE - Amsterdam + * AUSTRALIA - Sydney + * HONG_KONG - Hong Kong + * ASIA_PACIFIC - Singapore + * SOUTH_AMERICA - Brazil + * CHINE - China + +# How it Works +Punchthrough and relays work according to the [ICE](https://tools.ietf.org/html/rfc5245), [TURN](https://tools.ietf.org/html/rfc5766), and [STUN](https://tools.ietf.org/html/rfc5389) specifications. \ No newline at end of file diff --git a/Assets/Noble Connect/README.md.meta b/Assets/Noble Connect/README.md.meta new file mode 100644 index 0000000..6eb6de6 --- /dev/null +++ b/Assets/Noble Connect/README.md.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 662e06548d4295445bb8f66021012d93 +timeCreated: 1552034575 +licenseType: Store +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Resources.meta b/Assets/Noble Connect/Resources.meta new file mode 100644 index 0000000..947cf67 --- /dev/null +++ b/Assets/Noble Connect/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7bfb9e592d151107f81c9cf252361404 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/Resources/NobleConnectSettings.asset b/Assets/Noble Connect/Resources/NobleConnectSettings.asset new file mode 100644 index 0000000..864eac0 --- /dev/null +++ b/Assets/Noble Connect/Resources/NobleConnectSettings.asset @@ -0,0 +1,16 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0154c6ffa997c574c9f0f2680c03e82f, type: 3} + m_Name: NobleConnectSettings + m_EditorClassIdentifier: + gameID: NDk4CmxvZ2Fuc2ltaWM0OUBnbWFpbC5jb20KSm1PNGNOenBFKzlIdC9yOE5pUWpLNGJYMmF5eFZ2N0hUYnJYanFuYUQwZnByaWFYQVg0U3h3V2FwSHFsOU1Lam5DOUQvT2tMVkY5UTRqOXFWODVYUkE9PQ== + relayServerPort: 3478 diff --git a/Assets/Noble Connect/Resources/NobleConnectSettings.asset.meta b/Assets/Noble Connect/Resources/NobleConnectSettings.asset.meta new file mode 100644 index 0000000..3f17670 --- /dev/null +++ b/Assets/Noble Connect/Resources/NobleConnectSettings.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8fa01c579d9dfd963a234ef28ea80a23 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/UNet.meta b/Assets/Noble Connect/UNet.meta new file mode 100644 index 0000000..2d5eea2 --- /dev/null +++ b/Assets/Noble Connect/UNet.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 219fa3c95fcff0b48a9cdbda02f6ad88 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/UNet/INSTALL.md b/Assets/Noble Connect/UNet/INSTALL.md new file mode 100644 index 0000000..6955370 --- /dev/null +++ b/Assets/Noble Connect/UNet/INSTALL.md @@ -0,0 +1,2 @@ +As of 2019.1 if you want to use UNet with Noble Connect you must install the HLAPI package from the Unity package manager +and then extract the "UNet Noble Connect" package to get the examples and scripts. \ No newline at end of file diff --git a/Assets/Noble Connect/UNet/INSTALL.md.meta b/Assets/Noble Connect/UNet/INSTALL.md.meta new file mode 100644 index 0000000..b6c266f --- /dev/null +++ b/Assets/Noble Connect/UNet/INSTALL.md.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2a9d1538892d0bd418a62bf833d4e344 +timeCreated: 1510044594 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Noble Connect/UNet/UNet Noble Connect.unitypackage.meta b/Assets/Noble Connect/UNet/UNet Noble Connect.unitypackage.meta new file mode 100644 index 0000000..81ec476 --- /dev/null +++ b/Assets/Noble Connect/UNet/UNet Noble Connect.unitypackage.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: db127a021d5837b4bbd7d64fc0498550 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 4f93ed4..de1211e 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -616,7 +616,8 @@ PlayerSettings: webGLThreadsSupport: 0 webGLDecompressionFallback: 0 webGLPowerPreference: 2 - scriptingDefineSymbols: {} + scriptingDefineSymbols: + Standalone: NOBLE_CONNECT;NOBLE_CONNECT_1;NOBLE_CONNECT_1_37 additionalCompilerArguments: {} platformArchitecture: {} scriptingBackend: {} diff --git a/UserSettings/Layouts/default-2021.dwlt b/UserSettings/Layouts/default-2021.dwlt index 1806d6a..e51c93e 100644 --- a/UserSettings/Layouts/default-2021.dwlt +++ b/UserSettings/Layouts/default-2021.dwlt @@ -48,7 +48,7 @@ MonoBehaviour: m_MinSize: {x: 300, y: 200} m_MaxSize: {x: 24288, y: 16192} vertical: 0 - controlID: 72 + controlID: 15 --- !u!114 &3 MonoBehaviour: m_ObjectHideFlags: 52 @@ -68,8 +68,8 @@ MonoBehaviour: y: 0 width: 454 height: 928 - m_MinSize: {x: 275, y: 50} - m_MaxSize: {x: 4000, y: 4000} + m_MinSize: {x: 276, y: 71} + m_MaxSize: {x: 4001, y: 4021} m_ActualView: {fileID: 13} m_Panes: - {fileID: 13} @@ -223,7 +223,7 @@ MonoBehaviour: m_MinSize: {x: 200, y: 200} m_MaxSize: {x: 16192, y: 16192} vertical: 1 - controlID: 73 + controlID: 16 --- !u!114 &10 MonoBehaviour: m_ObjectHideFlags: 52 @@ -248,7 +248,7 @@ MonoBehaviour: m_MinSize: {x: 200, y: 100} m_MaxSize: {x: 16192, y: 8096} vertical: 0 - controlID: 74 + controlID: 17 --- !u!114 &11 MonoBehaviour: m_ObjectHideFlags: 52 @@ -330,9 +330,9 @@ MonoBehaviour: m_IsLocked: 0 m_FolderTreeState: scrollPos: {x: 0, y: 0} - m_SelectedIDs: c6660000 - m_LastClickedID: 26310 - m_ExpandedIDs: 000000006c66000000ca9a3b + m_SelectedIDs: 76660000 + m_LastClickedID: 26230 + m_ExpandedIDs: 000000006266000000ca9a3b m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -360,7 +360,7 @@ MonoBehaviour: scrollPos: {x: 0, y: 0} m_SelectedIDs: m_LastClickedID: 0 - m_ExpandedIDs: 000000006c660000 + m_ExpandedIDs: 0000000062660000 m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -387,7 +387,7 @@ MonoBehaviour: m_ListAreaState: m_SelectedInstanceIDs: m_LastClickedInstanceID: 0 - m_HadKeyboardFocusLastEvent: 1 + m_HadKeyboardFocusLastEvent: 0 m_ExpandedInstanceIDs: c623000000000000 m_RenameOverlay: m_UserAcceptedRename: 0 @@ -488,9 +488,9 @@ MonoBehaviour: m_SceneHierarchy: m_TreeViewState: scrollPos: {x: 0, y: 0} - m_SelectedIDs: da670000 - m_LastClickedID: 26586 - m_ExpandedIDs: c8f6ffff08f8ffff38fbffff18670000 + m_SelectedIDs: + m_LastClickedID: 0 + m_ExpandedIDs: 44f4ffff86f4ffffeaf5fffff0f5ffffc4f7ffff06f8ffff6af9ffff70f9ffff38fbffff m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -774,7 +774,7 @@ MonoBehaviour: m_Position: m_Target: {x: 538.4778, y: 250.99454, z: 0} speed: 2 - m_Value: {x: 538.4769, y: 250.99419, z: -0.000012519593} + m_Value: {x: 538.4778, y: 250.99454, z: 0} m_RenderMode: 0 m_CameraMode: drawMode: 0 @@ -805,7 +805,7 @@ MonoBehaviour: m_Fade: m_Target: 0 speed: 2 - m_Value: 1 + m_Value: 0 m_Color: {r: 0.5, g: 0.5, b: 0.5, a: 0.4} m_Pivot: {x: 0, y: 0, z: 0} m_Size: {x: 1, y: 1} @@ -823,11 +823,11 @@ MonoBehaviour: m_Rotation: m_Target: {x: 0, y: 0, z: 0, w: 1} speed: 2 - m_Value: {x: -0.00000023107182, y: 0.0000015522646, z: -0.0000005901495, w: -1} + m_Value: {x: 0, y: 0, z: 0, w: 1} m_Size: m_Target: 674.65393 speed: 2 - m_Value: 674.65283 + m_Value: 674.65393 m_Ortho: m_Target: 1 speed: 2 @@ -845,7 +845,7 @@ MonoBehaviour: m_FarClip: 10000 m_DynamicClip: 1 m_OcclusionCulling: 0 - m_LastSceneViewRotation: {x: -0.12956645, y: 0.87038475, z: -0.33090827, w: -0.34079745} + m_LastSceneViewRotation: {x: -0.08717229, y: 0.89959055, z: -0.21045254, w: -0.3726226} m_LastSceneViewOrtho: 0 m_ReplacementShader: {fileID: 0} m_ReplacementString: