Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected CreateResponseLobbyBackendLocalDevelopment() { }
/// Initializes a new instance of the <see cref="CreateResponseLobbyBackendLocalDevelopment" /> class.
/// </summary>
/// <param name="ports">ports (required).</param>
public CreateResponseLobbyBackendLocalDevelopment(Object ports = default(Object))
public CreateResponseLobbyBackendLocalDevelopment(Dictionary<string, CreateResponseLobbyBackendLocalDevelopmentPortsValue> ports = default)
{
// to ensure "ports" is required (not null)
if (ports == null)
Expand All @@ -53,7 +53,7 @@ protected CreateResponseLobbyBackendLocalDevelopment() { }
/// Gets or Sets Ports
/// </summary>
[DataMember(Name = "ports", IsRequired = true, EmitDefaultValue = true)]
public Object Ports { get; set; }
public Dictionary<string, CreateResponseLobbyBackendLocalDevelopmentPortsValue> Ports { get; set; }

/// <summary>
/// Returns the string presentation of the object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected CreateResponseLobbyBackendServer() { }
/// </summary>
/// <param name="serverId">serverId (required).</param>
/// <param name="ports">ports.</param>
public CreateResponseLobbyBackendServer(string serverId = default(string), Object ports = default(Object))
public CreateResponseLobbyBackendServer(string serverId = default(string), Dictionary<string, CreateResponseLobbyBackendServerPortsValue> ports = default)
{
// to ensure "serverId" is required (not null)
if (serverId == null)
Expand All @@ -61,7 +61,7 @@ protected CreateResponseLobbyBackendServer() { }
/// Gets or Sets Ports
/// </summary>
[DataMember(Name = "ports", EmitDefaultValue = false)]
public Object Ports { get; set; }
public Dictionary<string, CreateResponseLobbyBackendServerPortsValue> Ports { get; set; }

/// <summary>
/// Returns the string presentation of the object
Expand Down
95 changes: 95 additions & 0 deletions Assets/Configuration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#nullable enable

using System;
using System.IO;
using Newtonsoft.Json;
using Rivet.Editor;
using UnityEngine;

// TODO: Move in to generated backend
namespace Backend
{
/// <summary>
/// Derive config in order of priority:
/// - Environment variable (if running from deployed server)
/// - Configuration (if running in a client)
/// - Fallback
/// </summary>
public class Configuration
{
public string BackendEndpoint
{
get
{
string env = Environment.GetEnvironmentVariable("BACKEND_ENDPOINT");
if (!string.IsNullOrEmpty(env)) return env;

var prefs = PlayerPrefs.GetString("BackendEndpoint");
if (!string.IsNullOrEmpty(prefs)) return prefs;

var config = LoadRivetConfig();
if (config != null) return config.BackendEndpoint;


Debug.LogWarning("Could not find BackendEndpoint");
return "http://localhost:6420";
}
}

public string GameVersion
{
get
{
string env = Environment.GetEnvironmentVariable("GAME_VERSION");
if (!string.IsNullOrEmpty(env)) return env;

var prefs = PlayerPrefs.GetString("GameVersion");
if (!string.IsNullOrEmpty(prefs)) return prefs;

var config = LoadRivetConfig();
if (config != null) return config.GameVersion;


Debug.LogWarning("Could not find GameVersion");
return "unknown";
}
}

/// <summary>
/// Load the config exported from the build pipeline.
/// </summary>
/// <returns></returns>
private RivetConfig? LoadRivetConfig()
{
string filePath = Path.Combine(Application.streamingAssetsPath, "rivet_config.json");
if (File.Exists(filePath))
{
string json = File.ReadAllText(filePath);
RivetConfig? rivetSettings = JsonConvert.DeserializeObject<RivetConfig>(json);
if (rivetSettings != null)
{
return rivetSettings;
}
else
{
Debug.LogError("Deserialize RivetConfig is null");
return null;
}
}
else
{
Debug.LogError("Config file not found: " + filePath);
return null;
}
}
}

/// <summary>
/// Rivet config that gets loaded at runtime.
/// </summary>
internal class RivetConfig
{
[JsonProperty("backend_endpoint")] public string BackendEndpoint = "";
[JsonProperty("game_version")] public string GameVersion = "";
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Assets/DefaultPrefabObjects.asset
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ MonoBehaviour:
m_Name: DefaultPrefabObjects
m_EditorClassIdentifier:
_prefabs:
- {fileID: -6188795491314734926, guid: 22062943ad9a848f085690a0d5ad35d2, type: 3}
- {fileID: 8475222101369129519, guid: 8cf33e8e99a9b0c4c8f29ff725650de6, type: 3}
- {fileID: 4512293259955182956, guid: 44611030e61220d42ab7c37ba3c0ea92, type: 3}
- {fileID: 4512293259955182956, guid: 0d6d0f48b03b17f49a6340103cd9b9d0, type: 3}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Rivet/Runtime.meta → Assets/Examples.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Examples/LobbiesServers.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Examples/LobbiesServers/Prefabs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

136 changes: 136 additions & 0 deletions Assets/Examples/LobbiesServers/Prefabs/H2.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3077960475918568956
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8346680025563296582}
- component: {fileID: 3120108494724861149}
- component: {fileID: 4694859443562295531}
m_Layer: 5
m_Name: H2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8346680025563296582
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3077960475918568956}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 24}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3120108494724861149
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3077960475918568956}
m_CullTransparentMesh: 1
--- !u!114 &4694859443562295531
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3077960475918568956}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Header
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 20
m_fontSizeBase: 20
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 1
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading