diff --git a/Assets/Configuration.cs b/Assets/Configuration.cs index 7e850f0..2ba7ecd 100644 --- a/Assets/Configuration.cs +++ b/Assets/Configuration.cs @@ -3,7 +3,6 @@ using System; using System.IO; using Newtonsoft.Json; -using Rivet.Editor; using UnityEngine; // TODO: Move in to generated backend @@ -22,15 +21,17 @@ public string BackendEndpoint get { string env = Environment.GetEnvironmentVariable("BACKEND_ENDPOINT"); + Debug.Log($"Env {env}"); if (!string.IsNullOrEmpty(env)) return env; var prefs = PlayerPrefs.GetString("BackendEndpoint"); + Debug.Log($"Prefs {prefs}"); if (!string.IsNullOrEmpty(prefs)) return prefs; var config = LoadRivetConfig(); + Debug.Log($"Config {config?.BackendEndpoint}"); if (config != null) return config.BackendEndpoint; - Debug.LogWarning("Could not find BackendEndpoint"); return "http://localhost:6420"; } diff --git a/Assets/Examples/LobbiesServers/Prefabs/Player.prefab b/Assets/Examples/LobbiesServers/Prefabs/Player.prefab index 9755080..7f888f9 100644 --- a/Assets/Examples/LobbiesServers/Prefabs/Player.prefab +++ b/Assets/Examples/LobbiesServers/Prefabs/Player.prefab @@ -14,6 +14,7 @@ GameObject: - component: {fileID: 3207584769418723635} - component: {fileID: 3965462004462762662} - component: {fileID: 2786999543623527278} + - component: {fileID: 279330038607539582} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -54,6 +55,7 @@ MonoBehaviour: k__BackingField: {fileID: 0} _networkBehaviours: - {fileID: 1066971944226767979} + - {fileID: 279330038607539582} k__BackingField: {fileID: 0} k__BackingField: [] SerializedTransformProperties: @@ -160,7 +162,7 @@ CapsuleCollider: m_LayerOverridePriority: 0 m_IsTrigger: 0 m_ProvidesContacts: 0 - m_Enabled: 1 + m_Enabled: 0 serializedVersion: 2 m_Radius: 0.25 m_Height: 0.8 @@ -185,13 +187,28 @@ CharacterController: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 3 - m_Height: 2 - m_Radius: 0.5 + m_Height: 0.8 + m_Radius: 0.25 m_SlopeLimit: 45 m_StepOffset: 0.3 m_SkinWidth: 0.08 m_MinMoveDistance: 0.001 - m_Center: {x: 0, y: 0, z: 0} + m_Center: {x: 0, y: 0.4, z: 0} +--- !u!114 &279330038607539582 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8110614861790104705} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6d2c7ecd089cd4323a1f4579441ccfb0, type: 3} + m_Name: + m_EditorClassIdentifier: + _componentIndexCache: 1 + _addedNetworkObject: {fileID: -6188795491314734926} + _networkObjectCache: {fileID: -6188795491314734926} --- !u!1001 &2760826667780921781 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Examples/LobbiesServers/Scenes/Main.unity b/Assets/Examples/LobbiesServers/Scenes/Main.unity index 25f144a..e7905f2 100644 --- a/Assets/Examples/LobbiesServers/Scenes/Main.unity +++ b/Assets/Examples/LobbiesServers/Scenes/Main.unity @@ -122,68 +122,6 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1001 &680299 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 1649994703} - m_Modifications: - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalPosition.x - value: -6.689325 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalPosition.y - value: 3.3436306 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalPosition.z - value: 9.198315 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalRotation.w - value: -0.00000037252897 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalRotation.x - value: -0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalRotation.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalRotation.z - value: -0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 180 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 919132149155446097, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_Name - value: tree (2) - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} ---- !u!4 &680300 stripped -Transform: - m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - m_PrefabInstance: {fileID: 680299} - m_PrefabAsset: {fileID: 0} --- !u!1 &20941946 GameObject: m_ObjectHideFlags: 0 @@ -677,7 +615,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 7bedef3d23b044d99b8cbd5fb9507350, type: 3} propertyPath: m_LocalPosition.y - value: 3.3436306 + value: -0.0019997926 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 7bedef3d23b044d99b8cbd5fb9507350, type: 3} propertyPath: m_LocalPosition.z @@ -1029,7 +967,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 78c1df8e02e0f4c48869c488ba71299d, type: 3} propertyPath: m_LocalPosition.y - value: 3.8236306 + value: 0.47800022 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 78c1df8e02e0f4c48869c488ba71299d, type: 3} propertyPath: m_LocalPosition.z @@ -1185,7 +1123,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: cbbcd3589f8a24a968842ed62694338d, type: 3} propertyPath: m_LocalPosition.y - value: 3.3436303 + value: -0.002000031 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: cbbcd3589f8a24a968842ed62694338d, type: 3} propertyPath: m_LocalPosition.z @@ -1247,7 +1185,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: ed52de206e1504778ba6309609804e08, type: 3} propertyPath: m_LocalPosition.y - value: 3.34363 + value: -0.0020002695 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: ed52de206e1504778ba6309609804e08, type: 3} propertyPath: m_LocalPosition.z @@ -1857,7 +1795,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 65d3eccc9f7454b6586f0bc2dbadb496, type: 3} propertyPath: m_LocalPosition.y - value: 3.3436306 + value: -0.0019997926 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 65d3eccc9f7454b6586f0bc2dbadb496, type: 3} propertyPath: m_LocalPosition.z @@ -2315,68 +2253,6 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} ---- !u!1001 &1060886170 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 1649994703} - m_Modifications: - - target: {fileID: -8679921383154817045, guid: b85046aed1f7a4ee89b7f0630566f7f6, type: 3} - propertyPath: m_LocalPosition.x - value: -4.984533 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: b85046aed1f7a4ee89b7f0630566f7f6, type: 3} - propertyPath: m_LocalPosition.y - value: 3.3436306 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: b85046aed1f7a4ee89b7f0630566f7f6, type: 3} - propertyPath: m_LocalPosition.z - value: 12.537011 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: b85046aed1f7a4ee89b7f0630566f7f6, type: 3} - propertyPath: m_LocalRotation.w - value: -0.00000037252897 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: b85046aed1f7a4ee89b7f0630566f7f6, type: 3} - propertyPath: m_LocalRotation.x - value: -0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: b85046aed1f7a4ee89b7f0630566f7f6, type: 3} - propertyPath: m_LocalRotation.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: b85046aed1f7a4ee89b7f0630566f7f6, type: 3} - propertyPath: m_LocalRotation.z - value: -0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: b85046aed1f7a4ee89b7f0630566f7f6, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: b85046aed1f7a4ee89b7f0630566f7f6, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 180 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: b85046aed1f7a4ee89b7f0630566f7f6, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 919132149155446097, guid: b85046aed1f7a4ee89b7f0630566f7f6, type: 3} - propertyPath: m_Name - value: character-soldier - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: b85046aed1f7a4ee89b7f0630566f7f6, type: 3} ---- !u!4 &1060886171 stripped -Transform: - m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: b85046aed1f7a4ee89b7f0630566f7f6, type: 3} - m_PrefabInstance: {fileID: 1060886170} - m_PrefabAsset: {fileID: 0} --- !u!1001 &1076615968 PrefabInstance: m_ObjectHideFlags: 0 @@ -2391,7 +2267,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: b216882a7300343dda94dca8a34784e8, type: 3} propertyPath: m_LocalPosition.y - value: 3.3436306 + value: -0.0019997926 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: b216882a7300343dda94dca8a34784e8, type: 3} propertyPath: m_LocalPosition.z @@ -2439,6 +2315,60 @@ Transform: m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: b216882a7300343dda94dca8a34784e8, type: 3} m_PrefabInstance: {fileID: 1076615968} m_PrefabAsset: {fileID: 0} +--- !u!1 &1079749278 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1079749279} + - component: {fileID: 1079749280} + m_Layer: 0 + m_Name: Tree + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1079749279 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1079749278} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -9.04, y: 0, z: 11.21} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1496780917} + m_Father: {fileID: 1649994703} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!65 &1079749280 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1079749278} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} --- !u!1001 &1095996538 PrefabInstance: m_ObjectHideFlags: 0 @@ -2453,7 +2383,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: ec39b9e4ebd8d42a2933969ba0870c39, type: 3} propertyPath: m_LocalPosition.y - value: 3.3436306 + value: -0.0019997926 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: ec39b9e4ebd8d42a2933969ba0870c39, type: 3} propertyPath: m_LocalPosition.z @@ -2716,7 +2646,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: f47a64ad077ef4f9994e18a576443236, type: 3} propertyPath: m_LocalPosition.y - value: 3.343631 + value: -0.0019993158 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: f47a64ad077ef4f9994e18a576443236, type: 3} propertyPath: m_LocalPosition.z @@ -2764,68 +2694,6 @@ Transform: m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: f47a64ad077ef4f9994e18a576443236, type: 3} m_PrefabInstance: {fileID: 1201669848} m_PrefabAsset: {fileID: 0} ---- !u!1001 &1205543284 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 1649994703} - m_Modifications: - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalPosition.x - value: -2.2128973 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalPosition.y - value: 3.3436306 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalPosition.z - value: 11.851027 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalRotation.w - value: -0.00000037252897 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalRotation.x - value: -0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalRotation.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalRotation.z - value: -0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 180 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 919132149155446097, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - propertyPath: m_Name - value: tree (1) - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} ---- !u!4 &1205543285 stripped -Transform: - m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} - m_PrefabInstance: {fileID: 1205543284} - m_PrefabAsset: {fileID: 0} --- !u!1 &1246699288 GameObject: m_ObjectHideFlags: 0 @@ -2932,7 +2800,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 6b4bc73b4c9944e7b90f8ec6b5bc07b7, type: 3} propertyPath: m_LocalPosition.y - value: 3.3436303 + value: -0.002 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 6b4bc73b4c9944e7b90f8ec6b5bc07b7, type: 3} propertyPath: m_LocalPosition.z @@ -3461,19 +3329,19 @@ PrefabInstance: serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 1649994703} + m_TransformParent: {fileID: 1079749279} m_Modifications: - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} propertyPath: m_LocalPosition.x - value: -8.937897 + value: 0 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} propertyPath: m_LocalPosition.y - value: 3.3436306 + value: 0.934 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} propertyPath: m_LocalPosition.z - value: 12.011872 + value: 0 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 9bf93f914e99b43fb998a70fbbb308c6, type: 3} propertyPath: m_LocalRotation.w @@ -3652,7 +3520,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: ec39b9e4ebd8d42a2933969ba0870c39, type: 3} propertyPath: m_LocalPosition.y - value: 3.3436306 + value: -0.0019997926 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: ec39b9e4ebd8d42a2933969ba0870c39, type: 3} propertyPath: m_LocalPosition.z @@ -3725,21 +3593,18 @@ Transform: m_GameObject: {fileID: 1649994702} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 4.711085, y: -3.3436306, z: -12.32556} + m_LocalPosition: {x: 4.711085, y: 0, z: -12.32556} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: - {fileID: 490211728} - - {fileID: 1060886171} - {fileID: 2093922429} - {fileID: 1392980477} - {fileID: 545691797} - {fileID: 1095996539} - {fileID: 1604177533} - {fileID: 206563240} - - {fileID: 1496780917} - - {fileID: 1205543285} - - {fileID: 680300} + - {fileID: 1079749279} - {fileID: 1982095669} - {fileID: 1076615969} - {fileID: 1201669849} @@ -3974,15 +3839,15 @@ PrefabInstance: m_Modifications: - target: {fileID: -8679921383154817045, guid: bd107a9f43ca74f75b809c451171bd27, type: 3} propertyPath: m_LocalPosition.x - value: -2.3533633 + value: -2.322 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: bd107a9f43ca74f75b809c451171bd27, type: 3} propertyPath: m_LocalPosition.y - value: 4.343631 + value: 0.99800044 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: bd107a9f43ca74f75b809c451171bd27, type: 3} propertyPath: m_LocalPosition.z - value: 10.038383 + value: 10.102 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: bd107a9f43ca74f75b809c451171bd27, type: 3} propertyPath: m_LocalRotation.w @@ -4052,7 +3917,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: e65c1e159650d4f3fb4d08551f3a9efb, type: 3} propertyPath: m_LocalPosition.y - value: 3.3436306 + value: 0 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: e65c1e159650d4f3fb4d08551f3a9efb, type: 3} propertyPath: m_LocalPosition.z @@ -4239,8 +4104,8 @@ SceneRoots: - {fileID: 310468091} - {fileID: 1525569444} - {fileID: 1039461633} - - {fileID: 1246699291} - {fileID: 683020469} + - {fileID: 1246699291} - {fileID: 1968372014} - {fileID: 640839997} - {fileID: 1649994703} diff --git a/Assets/Examples/LobbiesServers/Scripts/GameManager.cs b/Assets/Examples/LobbiesServers/Scripts/GameManager.cs new file mode 100644 index 0000000..d9bed93 --- /dev/null +++ b/Assets/Examples/LobbiesServers/Scripts/GameManager.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using Backend.Modules.Lobbies; +using FishNet.Object; +using FishNet.Object.Synchronizing; +using UnityEngine; + +namespace Examples.LobbiesServers +{ + public class GameManager : NetworkBehaviour + { + public float MoveSpeed = 3.0f; + + } +} \ No newline at end of file diff --git a/Assets/Rivet/Editor/UI/Screens/MainOld.cs.meta b/Assets/Examples/LobbiesServers/Scripts/GameManager.cs.meta similarity index 83% rename from Assets/Rivet/Editor/UI/Screens/MainOld.cs.meta rename to Assets/Examples/LobbiesServers/Scripts/GameManager.cs.meta index 275eec8..eb68e0e 100644 --- a/Assets/Rivet/Editor/UI/Screens/MainOld.cs.meta +++ b/Assets/Examples/LobbiesServers/Scripts/GameManager.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: eab40917f63af4e008a47dd59a7d6693 +guid: 3c906f446b2014d9bb12fd4aa8e35f54 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Examples/LobbiesServers/Scripts/Player.cs b/Assets/Examples/LobbiesServers/Scripts/Player.cs index e656129..c1a0921 100644 --- a/Assets/Examples/LobbiesServers/Scripts/Player.cs +++ b/Assets/Examples/LobbiesServers/Scripts/Player.cs @@ -9,13 +9,14 @@ namespace Examples.LobbiesServers public class Player : NetworkBehaviour { private CharacterController _cc; - // private LobbyConfig _lc; + private GameManager _gm; void Start() { _cc = GetComponent(); - // _lc = FindObjectOfType(); + _gm = FindObjectOfType(); } + void Update() { Move(); @@ -24,12 +25,9 @@ void Update() [Client(Logging = LoggingType.Off, RequireOwnership = true)] void Move() { - // TODO: - var moveSpeed = 10; var horizontalInput = Input.GetAxisRaw("Horizontal"); var verticalInput = Input.GetAxisRaw("Vertical"); - // var offset = new Vector3(horizontalInput, Physics.gravity.y, verticalInput) * _lc.moveSpeed * Time.deltaTime; - var offset = new Vector3(horizontalInput, Physics.gravity.y, verticalInput) * moveSpeed * Time.deltaTime; + var offset = new Vector3(horizontalInput, Physics.gravity.y, verticalInput) * _gm.MoveSpeed * Time.deltaTime; _cc.Move(offset); } } diff --git a/Assets/Examples/LobbiesServers/Scripts/UI.cs b/Assets/Examples/LobbiesServers/Scripts/UI.cs index c8c15fa..ec98445 100644 --- a/Assets/Examples/LobbiesServers/Scripts/UI.cs +++ b/Assets/Examples/LobbiesServers/Scripts/UI.cs @@ -147,9 +147,10 @@ public void UpdateConnectionInfo() var lobbyCreate = "?"; if (_lobby is { } lobby) { + Debug.Log($"created at {lobby.CreatedAt}"); connConfig = BackendMultiplayerManager.Instance.GetConnectionConfig(lobby, _player); lobbyTags = string.Join(", ", lobby.Tags.Select(kv => $"{kv.Key}: {kv.Value}")); - lobbyCreate = DateTimeOffset.FromUnixTimeSeconds((int)lobby.CreatedAt).ToString("yyyy-MM-dd HH:mm:ss"); + lobbyCreate = DateTimeOffset.FromUnixTimeMilliseconds((long)lobby.CreatedAt).ToString("yyyy-MM-dd HH:mm:ss"); } connectionInfoText.text = $"Lobby ID: {_lobby?.Id ?? "?"}\n" + diff --git a/Assets/Rivet/Editor/PluginSettings.cs b/Assets/Rivet/Editor/PluginSettings.cs index 9217a42..60a4042 100644 --- a/Assets/Rivet/Editor/PluginSettings.cs +++ b/Assets/Rivet/Editor/PluginSettings.cs @@ -60,6 +60,15 @@ internal static SerializedObject GetSerializedSettings() return new SerializedObject(GetOrCreateSettings()); } + private static void SaveSettings() + { + if (Settings != null) + { + EditorUtility.SetDirty(Settings); + AssetDatabase.SaveAssets(); + } + } + // MARK: Settings [SerializeField] private bool enableDebugLogs = false; @@ -68,6 +77,24 @@ public static bool EnableDebugLogs { get { return Settings != null && Settings.enableDebugLogs; } } + + + [SerializeField] + private int tempBackendLocalPort = 6420; + + public static int TEMPBackendLocalPort + { + get { return Settings?.tempBackendLocalPort ?? 6420; } + set + { + if (Settings != null) + { + Settings.tempBackendLocalPort = value; + SaveSettings(); + } + } + + } } /// @@ -92,6 +119,11 @@ public static string GameVersion set => SetAndSave(ref gameVersion, value, "GameVersion"); } + public static void LoadSettings() { + backendEndpoint = PlayerPrefs.GetString("BackendEndpoint"); + gameVersion = PlayerPrefs.GetString("GameVersion"); + } + private static void SetAndSave(ref string field, string value, string prefKey) { field = value; diff --git a/Assets/Rivet/Editor/UI/RivetPlugin.cs b/Assets/Rivet/Editor/UI/RivetPlugin.cs index 2c58bca..8150007 100644 --- a/Assets/Rivet/Editor/UI/RivetPlugin.cs +++ b/Assets/Rivet/Editor/UI/RivetPlugin.cs @@ -32,11 +32,18 @@ public class RivetPlugin : EditorWindow public string? LocalGameServerExecutablePath; // MARK: Backend - private int _localBackendPort = 6420; + // private int _localBackendPort = 6420; + // public int LocalBackendPort { + // get { return _localBackendPort; } + // set { + // _localBackendPort = value; + // SharedSettings.UpdateFromPlugin(); + // } + // } public int LocalBackendPort { - get { return _localBackendPort; } + get { return PluginSettings.TEMPBackendLocalPort; } set { - _localBackendPort = value; + PluginSettings.TEMPBackendLocalPort = value; SharedSettings.UpdateFromPlugin(); } } @@ -63,10 +70,6 @@ public static void ShowPlugin() public void CreateGUI() { - Singleton = this; - - PluginSettings.LoadSettings(); - m_VisualTreeAsset.CloneTree(rootVisualElement); var screens = rootVisualElement.Q(name: "Screens"); @@ -97,6 +100,11 @@ public void OnEnable() { RivetLogger.Log("On Enable"); + Singleton = this; + + PluginSettings.LoadSettings(); + SharedSettings.LoadSettings(); + // Task managers LocalGameServerManager = new( initMessage: "Open \"Develop\" and press \"Start\" to start game server.", diff --git a/Assets/Rivet/Editor/UI/Screens/MainOld.cs b/Assets/Rivet/Editor/UI/Screens/MainOld.cs deleted file mode 100644 index 219ec61..0000000 --- a/Assets/Rivet/Editor/UI/Screens/MainOld.cs +++ /dev/null @@ -1,506 +0,0 @@ -using UnityEngine; -using UnityEditor; -using Newtonsoft.Json.Linq; -using System.Linq; -using Newtonsoft.Json; -using System.Collections.Generic; -using System.Threading.Tasks; -using System; -using System.Runtime.InteropServices; -using System.IO; -using UnityEditor.Build.Reporting; - -// namespace Rivet.Editor.UI.Screens.Main -// { -// enum SelectedTab -// { -// Setup = 0, Develop = 1, Deploy = 2, Settings = 3, -// } - -// enum EnvironmentType -// { -// Local = 0, Remote = 1, -// } - -// enum DeploySteps -// { -// Both = 0, GameServer = 1, Backend = 2, -// } - -// public class Window : RivetPluginWindow.IState -// { -// private RivetPluginWindow _pluginWindow; -// private BootstrapData _bootstrapData; -// private SelectedTab _selectedTab = SelectedTab.Setup; - -// // MARK: Develop (Environment) -// private bool _environmentFoldout = true; -// private EnvironmentType _environmentType = EnvironmentType.Local; -// private string? _remoteEnvironmentId; -// private BackendEnvironment? _remoteEnvironment -// { -// get -// { -// return _bootstrapData.BackendEnvironments[_remoteEnvironmentIndex]; -// } -// } -// private int _remoteEnvironmentIndex -// { -// get -// { -// var idx = _bootstrapData.BackendEnvironments.FindIndex(x => x.EnvironmentId == _remoteEnvironmentId); - -// // Default to 0 if not found -// return idx >= 0 ? idx : 0; -// } -// set -// { -// if (value >= 0 && value < _bootstrapData.BackendEnvironments.Count) -// { -// _remoteEnvironmentId = _bootstrapData.BackendEnvironments[value].EnvironmentId; -// } -// } -// } - -// // MARK: Develop (Local Game Server) -// private bool _localGameServerFoldout = true; - -// // MARK: Develop (Backend) -// private bool _backendFoldout = true; - -// // MARK: Deploy -// private DeploySteps _deploySteps = DeploySteps.Both; - -// public void OnEnter(RivetPluginWindow pluginWindow) -// { -// _pluginWindow = pluginWindow; -// _ = GetBootstrapData(); -// } - -// private async Task GetBootstrapData() -// { -// var result = await new ToolchainTask("get_bootstrap_data", new JObject()).RunAsync(); -// if (result is ResultOk) -// { -// _bootstrapData = result.Data.ToObject(); -// ExtensionData.ApiEndpoint = _bootstrapData.ApiEndpoint; -// } -// } - -// public void OnGUI() -// { -// GUILayout.BeginVertical(); - -// // Tabs -// string[] toolbarStrings = { "Setup", "Develop", "Deploy", "Settings" }; -// _selectedTab = (SelectedTab)GUILayout.Toolbar((int)_selectedTab, toolbarStrings); - -// // Draw body -// GUILayout.BeginVertical(); -// switch (_selectedTab) -// { -// case SelectedTab.Setup: -// DrawSetup(); -// break; -// case SelectedTab.Develop: -// DrawDevelop(); -// break; -// case SelectedTab.Deploy: -// DrawDeploy(); -// break; -// case SelectedTab.Settings: -// DrawSettings(); -// break; -// default: -// throw new System.Exception("unreachable"); -// } -// GUILayout.EndVertical(); - -// GUILayout.EndVertical(); -// } - -// // MARK: Tab: Setup -// private void DrawSetup() -// { -// GUILayout.Label("Setup"); -// GUILayout.Label("TODO: Check DGS is installed"); -// GUILayout.Label("TODO: Check Docker is installed"); -// GUILayout.Label("TODO: Check scenes are added to build settings"); -// } - -// // MARK: Tab: Develop -// private void DrawDevelop() -// { -// // MARK: Environment -// _environmentFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(_environmentFoldout, "Environment"); -// if (_environmentFoldout) -// { -// EditorGUILayout.LinkButton("Reload"); - -// GUILayout.Label("Configure which backend to connect to. [Learn More]"); - -// string[] envTypes = { "Local", "Remote" }; -// _environmentType = (EnvironmentType)EditorGUILayout.Popup("Type", (int)_environmentType, envTypes); - -// if (_environmentType == EnvironmentType.Remote) -// { -// var options = _bootstrapData.BackendEnvironments.Select(x => x.DisplayName).ToList(); -// options.Add("+ Create Environment"); -// var newEnvIndex = EditorGUILayout.Popup("Environment", _remoteEnvironmentIndex, options.ToArray()); - -// // Open create new env -// if (newEnvIndex == _bootstrapData.BackendEnvironments.Count) -// { -// Application.OpenURL($"https://hub.rivet.gg/games/{_bootstrapData.GameId}/backend?modal=create-environment"); -// } -// else -// { -// _remoteEnvironmentIndex = newEnvIndex; -// } -// } - - -// EditorGUILayout.HelpBox("Make sure you've deployed your game server. Using different versions can cause unexpected errors. [Go to deploy]", MessageType.Warning); -// } -// EditorGUILayout.EndFoldoutHeaderGroup(); - -// // MARK: Local Game Server -// _localGameServerFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(_localGameServerFoldout, "Local Game Server"); -// if (_localGameServerFoldout) -// { -// GUILayout.Label("Requires restart when game edited."); -// GUILayout.Label("TODO: Will take a long time to build the first time it runs"); - -// EditorGUILayout.BeginHorizontal(); -// if (GUILayout.Button("Start")) _ = OnLocalGameServerStart(); -// if (GUILayout.Button("Stop")) _ = OnLocalGameServerStop(); -// if (GUILayout.Button("Restart")) _ = OnLocalGameServerStart(); -// EditorGUILayout.EndHorizontal(); - -// EditorGUILayout.LinkButton("Show Logs"); -// } -// EditorGUILayout.EndFoldoutHeaderGroup(); - -// // MARK: Backend -// _backendFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(_backendFoldout, "Backend"); -// if (_backendFoldout) -// { -// if (GUILayout.Button("Generate SDK")) _ = OnBackendGenerateSDK(); -// if (GUILayout.Button("Edit Config")) OnBackendEditConfig(); -// } -// EditorGUILayout.EndFoldoutHeaderGroup(); -// } - -// private async Task OnLocalGameServerStart() -// { -// BuildAndRunServer(); -// } - -// private async Task OnLocalGameServerStop() -// { -// RivetLogger.Error("UNIMPLEMENTED"); -// } - -// private async Task OnBackendGenerateSDK() { -// // HACK: Show term instead of running inline -// var input = new JObject { ["cwd"] = ProjectRoot(), ["fallback_sdk_path"] = "Assets/Backend", ["target"] = "unity" }; -// await new ToolchainTask("show_term", new JObject -// { -// ["command"] = ToolchainTask.GetRivetCLIPath(), -// ["args"] = new JArray { "task", "run", "--run-config", "{}", "--name", "backend_sdk_gen", "--input", input.ToString(Formatting.None) }, -// }).RunAsync(); -// } - -// private void OnBackendEditConfig() { -// EditorUtility.OpenWithDefaultApp(Path.Combine(ProjectRoot(), "backend.json")); -// } - -// // MARK: Tab: Deploy -// private void DrawDeploy() -// { -// // Environment -// var options = _bootstrapData.BackendEnvironments.Select(x => x.DisplayName).ToList(); -// options.Add("+ Create Environment"); -// var newEnvIndex = EditorGUILayout.Popup("Environment", _remoteEnvironmentIndex, options.ToArray()); - -// // Open create new env -// if (newEnvIndex == _bootstrapData.BackendEnvironments.Count) -// { -// Application.OpenURL($"https://hub.rivet.gg/games/{_bootstrapData.GameId}/backend?modal=create-environment"); -// } -// else -// { -// _remoteEnvironmentIndex = newEnvIndex; -// } - -// // Steps -// string[] deployStepsOptions = { "Both Game Server & Backend", "Game Server", "Backend" }; -// _deploySteps = (DeploySteps)EditorGUILayout.Popup("Steps", (int)_deploySteps, deployStepsOptions); - -// if (GUILayout.Button("Build & Deploy")) _ = OnBuildAndDeploy(); -// } - -// private async Task OnBuildAndDeploy() -// { -// // // Check if Linux build support is installed -// // if (!BuildPipeline.IsBuildTargetSupported(BuildTargetGroup.Standalone, BuildTarget.StandaloneLinux64)) -// // { -// // RivetLogger.Error("Linux build support is not installed"); -// // return; -// // } - -// // // Set the build settings -// // BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions -// // { -// // scenes = EditorBuildSettings.scenes.Select(scene => scene.path).ToArray(), -// // locationPathName = "builds/LinuxServer/LinuxServer.x86_64", // Output path -// // target = BuildTarget.StandaloneLinux64, // Target platform -// // subtarget = (int)StandaloneBuildSubtarget.Server // Headless mode for server build -// // }; - -// // // Build the player -// // var result = BuildPipeline.BuildPlayer(buildPlayerOptions); - -// // // If the build failed, log an error, and don't continue -// // if (result.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded) -// // { -// // RivetLogger.Error("Build failed: " + result.summary.result); -// // return; -// // } - -// // // Run deploy with CLI -// // new System.Threading.Thread(async () => -// // { -// // var result = await new ToolchainTask( -// // "deploy", -// // new JObject -// // { -// // ["cwd"] = "TODO", -// // ["environment_id"] = _gameData.namespaces[_selectedEnvironment].Item1.name_id, -// // ["game_server"] = true, -// // ["backend"] = true, -// // } -// // ).RunAsync(); -// // }).Start(); -// } - -// // MARK: Tab: Settings -// private void DrawSettings() -// { -// GUILayout.Label("Account"); -// if (GUILayout.Button("Sign Out")) -// { -// _ = OnUnlinkGame(); -// } - -// GUILayout.Label("Plugin"); -// GUILayout.BeginHorizontal(); -// GUILayout.Button("Edit User"); -// GUILayout.Button("Edit Project"); -// GUILayout.EndHorizontal(); - -// GUILayout.Label("Local Backend Daemon"); -// GUILayout.Label("Runs your local backend server used for development in the background. Rarely needs to be stopped."); -// GUILayout.BeginHorizontal(); -// if (GUILayout.Button("Start")) _ = OnBackendStart(); -// if (GUILayout.Button("Stop")) _ = OnBackendStop(); -// if (GUILayout.Button("Restart")) _ = OnBackendStart(); -// GUILayout.EndHorizontal(); -// EditorGUILayout.LinkButton("Show Logs"); - -// GUILayout.Label("Source Code"); -// EditorGUILayout.LinkButton("rivet-gg/rivet"); -// EditorGUILayout.LinkButton("rivet-gg/opengb"); -// EditorGUILayout.LinkButton("rivet-gg/plugin-godot"); -// } - - -// private async Task OnBackendStart() -// { -// // HACK: Show term instead of running inline - -// var input = new JObject { ["port"] = 6420, ["cwd"] = ProjectRoot() }; -// await new ToolchainTask("show_term", new JObject -// { -// ["command"] = ToolchainTask.GetRivetCLIPath(), -// ["args"] = new JArray { "task", "run", "--run-config", "{}", "--name", "backend_dev", "--input", input.ToString(Formatting.None) }, -// }).RunAsync(); -// } - - -// private async Task OnBackendStop() -// { -// RivetLogger.Error("UNIMPLEMENTED"); -// } - -// private async Task OnUnlinkGame() -// { -// await new ToolchainTask("unlink", new JObject()).RunAsync(); -// _pluginWindow.TransitionToState(new Screens.Login.Window()); -// } - -// private string GetUnityEditorPath() -// { -// string editorPath = EditorApplication.applicationPath; - -// if (Application.platform == RuntimePlatform.OSXEditor) -// { -// // On macOS point to the actual Unity binary inside the .app -// editorPath = Path.Combine(editorPath, "Contents/MacOS/Unity"); -// } - -// return editorPath; -// } - -// // MARK: Run Game Server -// private BuildTarget GetGameServerBuildTarget() -// { -// // TODO: -// return BuildTarget.StandaloneOSX; -// } - -// private void BuildAndRunServer() -// { -// // Ensure a scene is included -// if (EditorBuildSettings.scenes.Length == 0) -// { -// RivetLogger.Error("No scenes in build settings. Please add at least one scene."); -// return; -// } - -// // Configure build settings -// var buildPlayerOptions = new BuildPlayerOptions -// { -// scenes = GetScenePaths(), -// locationPathName = Path.Combine(ProjectRoot(), "Builds", "DedicatedServer", GetBuildName()), -// target = GetGameServerBuildTarget(), -// subtarget = (int)StandaloneBuildSubtarget.Server -// }; - -// // // Speed up builds for development -// // var devOptimizations = true; -// // if (devOptimizations) -// // { -// // buildPlayerOptions.options |= BuildOptions.Development; -// // buildPlayerOptions.options |= BuildOptions.CompressWithLz4; -// // EditorUserBuildSettings.compressFilesInPackage = false; - -// // // TODO: Is this right? -// // buildPlayerOptions.options &= ~BuildOptions.StrictMode; - -// // // buildPlayerOptions.options |= BuildOptions.BuildScriptsOnly; - -// // // TODO: Is this right? -// // // Disable error checking for faster builds -// // buildPlayerOptions.extraScriptingDefines = new string[] { "DISABLE_IMPLICIT_CHECKS", "DISABLE_WARNINGS" }; -// // } - - -// // Build the server -// RivetLogger.Log("Building dedicated server..."); -// var report = BuildPipeline.BuildPlayer(buildPlayerOptions); -// var result = report.summary.result; - -// if (result == BuildResult.Succeeded) -// { -// RivetLogger.Log("Dedicated server build completed successfully."); -// LaunchServer(buildPlayerOptions.locationPathName); -// } -// else -// { -// RivetLogger.Error("Dedicated server build failed."); -// } -// } - -// private async void LaunchServer(string buildPath) -// { -// // Add path to binary for macOS -// string executablePath = FindExecutablePath(buildPath); - -// // HACK: Show term instead of running inline -// // TODO: Better logs dir -// // string logPath = Path.Combine(Path.GetDirectoryName(executablePath), "server_log.txt"); -// await new ToolchainTask("show_term", new JObject -// { -// ["command"] = executablePath, -// // ["args"] = new JArray { "-batchmode", "-nographics", "-logFile", logPath, "-server" }, -// ["args"] = new JArray { "-batchmode", "-nographics", "-logFile", "-server" }, -// }).RunAsync(); - -// // OLD: -// // string logPath = Path.Combine(Path.GetDirectoryName(serverPath), "server_log.txt"); - -// // ProcessStartInfo startInfo = new ProcessStartInfo -// // { -// // FileName = serverPath, -// // Arguments = $"-batchmode -nographics -logFile \"{logPath}\"", -// // UseShellExecute = false, -// // CreateNoWindow = true -// // }; - -// // RivetLogger.Log($"Launching dedicated server with command: {startInfo.FileName} {startInfo.Arguments}"); - -// // try -// // { -// // using (Process serverProcess = Process.Start(startInfo)) -// // { -// // RivetLogger.Log("Dedicated server launched successfully."); -// // } -// // } -// // catch (System.Exception e) -// // { -// // RivetLogger.Error($"Failed to launch dedicated server: {e.Message}"); -// // } -// } - -// private string FindExecutablePath(string serverPath) -// { -// string productName = Application.productName; -// string executableFile = Path.Combine(serverPath, productName); - -// if (!File.Exists(executableFile)) -// { -// throw new Exception($"Executable {productName} not found in {serverPath}"); -// } - -// return executableFile; -// } - -// private string[] GetScenePaths() -// { -// string[] scenes = new string[EditorBuildSettings.scenes.Length]; -// for (int i = 0; i < scenes.Length; i++) -// { -// scenes[i] = EditorBuildSettings.scenes[i].path; -// } -// return scenes; -// } - -// private string GetBuildName() -// { -// // TODO: Check that we don't need .exe for Windows -// var serverName = "DedicatedServer"; -// return serverName; -// // switch (GetGameServerBuildTarget()) -// // { -// // case BuildTarget.StandaloneWindows: -// // case BuildTarget.StandaloneWindows64: -// // return $"{serverName}.exe"; -// // case BuildTarget.StandaloneOSX: -// // return $"{serverName}.app"; -// // case BuildTarget.StandaloneLinux64: -// // return $"{serverName}"; -// // default: -// // return serverName; -// // } -// } - -// // MARK: Utils -// // TODO: move to utils file -// private string ProjectRoot() -// { -// var dataPath = Application.dataPath; -// return Directory.GetParent(dataPath).FullName; -// } -// } -// } \ No newline at end of file diff --git a/Assets/Rivet/Editor/UI/Tabs/DevelopController.cs b/Assets/Rivet/Editor/UI/Tabs/DevelopController.cs index db1cc85..858316b 100644 --- a/Assets/Rivet/Editor/UI/Tabs/DevelopController.cs +++ b/Assets/Rivet/Editor/UI/Tabs/DevelopController.cs @@ -130,8 +130,22 @@ private void OnLocalGameServerStateChange(bool running) private void OnLocalGameServerStart() { - _pluginWindow.LocalGameServerExecutablePath = Builder.BuildDevServer(); - _ = _pluginWindow.LocalGameServerManager.StartTask(); + var serverPath = Builder.BuildDevServer(); + if (serverPath != null) + { + _pluginWindow.LocalGameServerExecutablePath = serverPath; + // _ = _pluginWindow.LocalGameServerManager.StartTask(); + _ = new RivetTask("show_term", new JObject + { + ["command"] = _pluginWindow.LocalGameServerExecutablePath, + // ["args"] = new JArray { "-batchmode", "-nographics", "-logFile", logPath, "-server" }, + ["args"] = new JArray { "-batchmode", "-nographics", "-server" }, + }).RunAsync(); + } + else + { + EditorUtility.DisplayDialog("Game Server Build Failed", "See Unity console for details.", "Dismiss"); + } } private void OnBackendGenerateSDK() @@ -149,4 +163,4 @@ private void OnBackendEditConfig() EditorUtility.OpenWithDefaultApp(Path.Combine(Builder.ProjectRoot(), "backend.json")); } } -} \ No newline at end of file +} diff --git a/Assets/Rivet/Editor/UI/Tabs/SettingsController.cs b/Assets/Rivet/Editor/UI/Tabs/SettingsController.cs index a35a882..022096a 100644 --- a/Assets/Rivet/Editor/UI/Tabs/SettingsController.cs +++ b/Assets/Rivet/Editor/UI/Tabs/SettingsController.cs @@ -48,12 +48,43 @@ void InitUI() _root.Q("AccountBody").Q("SignOutButton").RegisterCallback(ev => { _ = OnUnlinkGame(); }); - _backendStart.RegisterCallback(ev => { _ = _pluginWindow.BackendManager.StartTask(); }); - _backendStop.RegisterCallback(ev => _pluginWindow.BackendManager.StopTask()); - _backendRestart.RegisterCallback(ev => { _ = _pluginWindow.BackendManager.StartTask(); }); + // _backendStart.RegisterCallback(ev => { _ = _pluginWindow.BackendManager.StartTask(); }); + // _backendStop.RegisterCallback(ev => _pluginWindow.BackendManager.StopTask()); + // _backendRestart.RegisterCallback(ev => { _ = _pluginWindow.BackendManager.StartTask(); }); + _backendStart.RegisterCallback(ev => { _ = OnStartBackend(); }); // TODO: Remove _backendShowLogs.RegisterCallback(ev => BackendWindow.ShowBackend()); } + private async Task OnStartBackend() + { + // Choose port to run on. This is to avoid potential conflicts with + // multiple projects running at the same time. + var chooseRes = await new RivetTask("backend_choose_local_port", new JObject()).RunAsync(); + int port; + switch (chooseRes) + { + case ResultOk ok: + port = (int)ok.Data["port"]; + RivetPlugin.Singleton.LocalBackendPort = port; + break; + case ResultErr err: + RivetLogger.Error($"Failed to choose port: {err}"); + return; + default: + return; + } + + var input = new JObject { + ["port"] = port, + ["cwd"] = Builder.ProjectRoot() + }; + await new RivetTask("show_term", new JObject + { + ["command"] = RivetTask.GetRivetCLIPath(), + ["args"] = new JArray { "task", "run", "--run-config", "{}", "--name", "backend_dev", "--input", input.ToString(Formatting.None) }, + }).RunAsync(); + } + private async Task OnUnlinkGame() { await new RivetTask("unlink", new JObject()).RunAsync(); @@ -67,4 +98,4 @@ private void OnBackendStateChange(bool running) _backendRestart.style.display = running ? DisplayStyle.Flex : DisplayStyle.None; } } -} \ No newline at end of file +} diff --git a/Assets/StreamingAssets/rivet_config.json b/Assets/StreamingAssets/rivet_config.json new file mode 100644 index 0000000..680b9aa --- /dev/null +++ b/Assets/StreamingAssets/rivet_config.json @@ -0,0 +1 @@ +{"backend_endpoint":"http://localhost:20338","game_version":"TODO"} \ No newline at end of file diff --git a/Assets/StreamingAssets/rivet_config.json.meta b/Assets/StreamingAssets/rivet_config.json.meta new file mode 100644 index 0000000..c301f0f --- /dev/null +++ b/Assets/StreamingAssets/rivet_config.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d9e4c0231c9c34e97849db3c4a60b564 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: