From 2119baf64f4a58d37a58db716c8d6d0544d4133d Mon Sep 17 00:00:00 2001 From: Nathan Flurry Date: Sun, 29 Sep 2024 15:46:17 -0700 Subject: [PATCH] chore: refactor global code in to RivetGlobal --- ...ivet_toolchain_ffi_windows_x86_64.dll.meta | 3 +- Assets/Rivet/Editor/PluginSettings.cs | 14 +- Assets/Rivet/Editor/RivetGlobal.cs | 200 +++++++++++ Assets/Rivet/Editor/RivetGlobal.cs.meta | 11 + Assets/Rivet/Editor/RivetToolchain.cs | 8 +- Assets/Rivet/Editor/Task.cs | 17 +- Assets/Rivet/Editor/Types.cs | 22 +- Assets/Rivet/Editor/UI/Dock/Dock.cs | 121 +------ Assets/Rivet/Editor/UI/Dock/Dock.unity | 316 ------------------ Assets/Rivet/Editor/UI/Dock/Dock.unity.meta | 7 - .../Editor/UI/Dock/Tabs/DevelopController.cs | 82 +++-- .../Editor/UI/Dock/Tabs/ModulesController.cs | 20 -- .../Rivet/Editor/UI/SignIn/LoginController.cs | 104 +++--- scripts/build_dev.ts | 4 +- 14 files changed, 364 insertions(+), 565 deletions(-) create mode 100644 Assets/Rivet/Editor/RivetGlobal.cs create mode 100644 Assets/Rivet/Editor/RivetGlobal.cs.meta delete mode 100644 Assets/Rivet/Editor/UI/Dock/Dock.unity delete mode 100644 Assets/Rivet/Editor/UI/Dock/Dock.unity.meta diff --git a/Assets/Rivet/Editor/Native/rivet_toolchain_ffi_windows_x86_64.dll.meta b/Assets/Rivet/Editor/Native/rivet_toolchain_ffi_windows_x86_64.dll.meta index 5dcbf0a..6da4427 100644 --- a/Assets/Rivet/Editor/Native/rivet_toolchain_ffi_windows_x86_64.dll.meta +++ b/Assets/Rivet/Editor/Native/rivet_toolchain_ffi_windows_x86_64.dll.meta @@ -19,6 +19,7 @@ PluginImporter: Exclude Editor: 0 Exclude Linux64: 1 Exclude OSXUniversal: 1 + Exclude WebGL: 1 Exclude Win: 1 Exclude Win64: 1 - first: @@ -31,7 +32,7 @@ PluginImporter: second: enabled: 1 settings: - CPU: AnyCPU + CPU: x86_64 DefaultValueInitialized: true OS: Windows - first: diff --git a/Assets/Rivet/Editor/PluginSettings.cs b/Assets/Rivet/Editor/PluginSettings.cs index 5deeef8..3131caa 100644 --- a/Assets/Rivet/Editor/PluginSettings.cs +++ b/Assets/Rivet/Editor/PluginSettings.cs @@ -169,18 +169,12 @@ private static void SetAndSave(ref string field, string value, string prefKey) /// public static void UpdateFromPlugin() { - if (Dock.Singleton is { } plugin) + if (RivetGlobal.Singleton is { } plugin) { - BackendEndpoint = plugin.EnvironmentType switch - { - EnvironmentType.Local => $"http://localhost:{plugin.LocalBackendPort}", - EnvironmentType.Remote => plugin.RemoteEnvironmentBackend?.Endpoint ?? "http://localhost:6420", - _ => throw new System.NotImplementedException(), - }; - - GameVersion = plugin.GameVersion ?? "unknown"; + BackendEndpoint = plugin.BackendEndpoint; + GameVersion = plugin.CurrentBuildSlug; - RivetLogger.Log($"Update Shared Settings [BackendEndpoint={BackendEndpoint} GameVersion={GameVersion}]"); + RivetLogger.Log($"Update Shared Settings: BackendEndpoint={BackendEndpoint} GameVersion={GameVersion}"); } } } diff --git a/Assets/Rivet/Editor/RivetGlobal.cs b/Assets/Rivet/Editor/RivetGlobal.cs new file mode 100644 index 0000000..f6f9fd8 --- /dev/null +++ b/Assets/Rivet/Editor/RivetGlobal.cs @@ -0,0 +1,200 @@ +using UnityEditor.Build; +using System.Threading.Tasks; +using UnityEditor.Build.Reporting; +using UnityEngine; +using System.IO; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Rivet.Editor.Types; +using Rivet.Editor.UI.Dock; + +namespace Rivet.Editor +{ + public enum EnvironmentType + { + Local = 0, Remote = 1, + } + + public class RivetGlobal + { + public static RivetGlobal? Singleton; + + // MARK: Bootstrap + // Null if not bootstrapped yet + public BootstrapData? BootstrapData; + + // Null if not authenticated + public CloudData? CloudData + { + get + { + return BootstrapData?.Cloud; + } + } + + // If the user has the credentials required to connect to Rivet Cloud. + public bool IsAuthenticated + { + get + { + return CloudData != null; + } + } + + // MARK: Environment + public EnvironmentType EnvironmentType + { + get { return PluginSettings.EnvironmentType; } + set + { + PluginSettings.EnvironmentType = value; + SharedSettings.UpdateFromPlugin(); + } + } + public string? RemoteEnvironmentId + { + get { return PluginSettings.RemoteEnvironmentId; } + set + { + PluginSettings.RemoteEnvironmentId = value; + SharedSettings.UpdateFromPlugin(); + } + } + public RivetEnvironment? RemoteEnvironment + { + get + { + return RemoteEnvironmentIndex != null ? CloudData?.Environments[RemoteEnvironmentIndex.Value] : null; + } + } + public int? RemoteEnvironmentIndex + { + get + { + if (CloudData is { } data) + { + var idx = data.Environments.FindIndex(x => x.Id == RemoteEnvironmentId); + return idx >= 0 ? idx : 0; + } + else + { + return 0; + } + } + set + { + if (value != null && value >= 0 && value < CloudData?.Environments.Count) + { + RemoteEnvironmentId = CloudData?.Environments[value.Value].Id; + } + } + } + + // MARK: Port + public int LocalBackendPort = 6420; + + public string LocalBackendEndpoint + { + get + { + return $"http://127.0.0.1:{LocalBackendPort}"; + } + } + + public int LocalEditorPort = 6421; + + public string LocalEditorEndpoint + { + get + { + return $"http://127.0.0.1:{LocalEditorPort}"; + } + } + + // Endpoint to connect to + public string BackendEndpoint + { + get + { + switch (EnvironmentType) + { + case EnvironmentType.Local: + return LocalBackendEndpoint; + case EnvironmentType.Remote: + if (CloudData is { } cloudData && RemoteEnvironmentId is { } remoteEnvId) + { + return cloudData.Backends[remoteEnvId].Endpoint; + } + else + { + RivetLogger.Error("BackendEndpoint: unreachable"); + return ""; + } + default: + RivetLogger.Error("BackendEndpoint: unreachable"); + return ""; + } + } + } + + // If the Rivet SDK has been generated. + public bool BackendSdkExists = false; + + // The current deployed build slug. + public string CurrentBuildSlug + { + get + { + switch (EnvironmentType) + { + case EnvironmentType.Local: + return "local"; + case EnvironmentType.Remote: + if (CloudData is { } cloudData && RemoteEnvironmentId is { } remoteEnvId) + { + if (cloudData.CurrentBuilds.TryGetValue(remoteEnvId, out var build) && build.Tags.TryGetValue("version", out var versionTag)) + { + return versionTag; + } + else + { + RivetLogger.Error("CurrentBuildSlug: no current build or version in build"); + return ""; + } + } + else + { + RivetLogger.Error("CurrentBuildSlug: not authenticated"); + return ""; + } + default: + RivetLogger.Error("BackendEndpoint: unreachable"); + return ""; + } + } + } + + // MARK: Local Game Server + public string? LocalGameServerExecutablePath; + + // MARK: Bootstrap + public async Task Bootstrap() + { + var result = await new RivetTask("get_bootstrap_data", new JObject()).RunAsync(); + if (result is ResultErr err) + { + return; + } + + // Save data + var data = result.Data.ToObject(); ; + BootstrapData = data; + + // Update configuration + SharedSettings.UpdateFromPlugin(); + + // Emit event + Dock.Singleton?.OnBootstrap(); + } + } +} \ No newline at end of file diff --git a/Assets/Rivet/Editor/RivetGlobal.cs.meta b/Assets/Rivet/Editor/RivetGlobal.cs.meta new file mode 100644 index 0000000..7d341a4 --- /dev/null +++ b/Assets/Rivet/Editor/RivetGlobal.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6f65e4bc682b14f6ca9eeaac77344a89 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Rivet/Editor/RivetToolchain.cs b/Assets/Rivet/Editor/RivetToolchain.cs index dcb065a..784976b 100644 --- a/Assets/Rivet/Editor/RivetToolchain.cs +++ b/Assets/Rivet/Editor/RivetToolchain.cs @@ -11,20 +11,20 @@ public static class RivetToolchain [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void EventCallback(ulong taskId, IntPtr eventJson); - [DllImport(RustLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "run_task")] + [DllImport(RustLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "rivet_run_task")] private static extern ulong run_task( [MarshalAs(UnmanagedType.LPStr)] string name, [MarshalAs(UnmanagedType.LPStr)] string inputJson, EventCallback callback ); - [DllImport(RustLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "abort_task")] + [DllImport(RustLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "rivet_abort_task")] private static extern bool abort_task(ulong taskId); - [DllImport(RustLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "shutdown")] + [DllImport(RustLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "rivet_shutdown")] private static extern void shutdown(); - [DllImport(RustLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "free_rust_string")] + [DllImport(RustLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "rivet_free_rust_string")] private static extern void free_rust_string(IntPtr str); public static ulong RunTask(string name, string inputJson, EventCallback callback) diff --git a/Assets/Rivet/Editor/Task.cs b/Assets/Rivet/Editor/Task.cs index cd0b6bc..f1ca40a 100644 --- a/Assets/Rivet/Editor/Task.cs +++ b/Assets/Rivet/Editor/Task.cs @@ -45,7 +45,10 @@ public RivetTask(string name, JObject input) private void Run(string name, string inputJson) { + RivetLogger.Log($"starting run"); _taskId = RivetToolchain.RunTask(name, inputJson, OnOutputEvent); + RivetLogger.Log($"run finished"); + RivetLogger.Log($"running {_taskId}"); } private void OnOutputEvent(ulong taskId, IntPtr eventJsonPtr) @@ -56,6 +59,8 @@ private void OnOutputEvent(ulong taskId, IntPtr eventJsonPtr) private void HandleOnOutputEvent(string eventJson) { + RivetLogger.Log($"got event {eventJson}"); + var eventObj = JObject.Parse(eventJson); if (eventObj.ContainsKey("log")) { @@ -63,7 +68,10 @@ private void HandleOnOutputEvent(string eventJson) } else if (eventObj.ContainsKey("result")) { - _logResult = eventObj["result"] as JObject; + RivetLogger.Log("got result"); + // 1st result = event enum type + // 2nd result = result enum type + _logResult = eventObj["result"]["result"] as JObject; OnFinish(); } else if (eventObj.ContainsKey("port_update")) @@ -113,16 +121,21 @@ private void OnFinish() outputResult = _logResult; } + RivetLogger.Log($"[{_name}] Response: {outputResult.ToString(Newtonsoft.Json.Formatting.None)}");; + TaskOutput?.Invoke(outputResult); if (outputResult.ContainsKey("Ok")) { RivetLogger.Log($"[{_name}] Success: {outputResult["Ok"]}"); TaskOk?.Invoke(outputResult["Ok"] as JObject); } - else + else if (outputResult.ContainsKey("Err")) { RivetLogger.Error($"[{_name}] Error: {outputResult["Err"]}"); TaskError?.Invoke(outputResult["Err"].ToString()); + } else { + RivetLogger.Error($"[{_name}] Missing Err or Ok in result: {outputResult.ToString(Newtonsoft.Json.Formatting.None)}"); + } } diff --git a/Assets/Rivet/Editor/Types.cs b/Assets/Rivet/Editor/Types.cs index feb6d1c..57df9a4 100644 --- a/Assets/Rivet/Editor/Types.cs +++ b/Assets/Rivet/Editor/Types.cs @@ -4,12 +4,26 @@ namespace Rivet.Editor.Types { public struct BootstrapData + { + [JsonProperty("cloud")] public CloudData? Cloud; + } + + public struct CloudData { [JsonProperty("token")] public string Token; [JsonProperty("api_endpoint")] public string ApiEndpoint; [JsonProperty("game_id")] public string GameId; [JsonProperty("envs")] public List Environments; [JsonProperty("backends")] public Dictionary Backends; + [JsonProperty("current_builds")] public Dictionary CurrentBuilds; + } + + public struct RivetEnvironment + { + [JsonProperty("id")] public string Id; + [JsonProperty("created_at")] public string CreatedAt; + [JsonProperty("slug")] public string Slug; + [JsonProperty("name")] public string Name; } public struct EnvironmentBackend @@ -21,12 +35,10 @@ public struct EnvironmentBackend [JsonProperty("tier")] public string Tier; } - public struct RivetEnvironment + public struct ServersBuild { - [JsonProperty("id")] public string Id; - [JsonProperty("created_at")] public string CreatedAt; - [JsonProperty("slug")] public string Slug; + [JsonProperty("id")] public string id; [JsonProperty("name")] public string Name; + [JsonProperty("tags")] public Dictionary Tags; } - } \ No newline at end of file diff --git a/Assets/Rivet/Editor/UI/Dock/Dock.cs b/Assets/Rivet/Editor/UI/Dock/Dock.cs index 0f00ecf..0ce41d6 100644 --- a/Assets/Rivet/Editor/UI/Dock/Dock.cs +++ b/Assets/Rivet/Editor/UI/Dock/Dock.cs @@ -17,12 +17,6 @@ public enum MainTab Setup, Develop, Modules, Settings, } - public enum EnvironmentType - { - Local = 0, Remote = 1, - } - - public class Dock : EditorWindow { public static Dock? Singleton; @@ -38,36 +32,6 @@ private VisualElement _root } } - public string ApiEndpoint = "https://api.rivet.gg"; - - // MARK: Local Game Server - public string? LocalGameServerExecutablePath; - - // MARK: Backend - // private int _localBackendPort = 6420; - // public int LocalBackendPort { - // get { return _localBackendPort; } - // set { - // _localBackendPort = value; - // SharedSettings.UpdateFromPlugin(); - // } - // } - public int LocalBackendPort - { - get { return PluginSettings.TEMPBackendLocalPort; } - set - { - PluginSettings.TEMPBackendLocalPort = value; - SharedSettings.UpdateFromPlugin(); - } - } - - // MARK: Deployed Game Version - public string? GameVersion; - - // MARK: Bootstrap - public BootstrapData? BootstrapData; - // MARK: Tabs private MainTab _tab = MainTab.Setup; @@ -87,63 +51,6 @@ public int LocalBackendPort private VisualElement _settingsTabBody; private SettingsController _settingsController; - // MARK: Environment - public EnvironmentType EnvironmentType - { - get { return PluginSettings.EnvironmentType; } - set - { - PluginSettings.EnvironmentType = value; - SharedSettings.UpdateFromPlugin(); - } - } - public string? RemoteEnvironmentId - { - get { return PluginSettings.RemoteEnvironmentId; } - set - { - PluginSettings.RemoteEnvironmentId = value; - SharedSettings.UpdateFromPlugin(); - } - } - public RivetEnvironment? RemoteEnvironment - { - get - { - return RemoteEnvironmentIndex != null ? BootstrapData?.Environments[RemoteEnvironmentIndex.Value] : null; - } - } - public int? RemoteEnvironmentIndex - { - get - { - if (BootstrapData is { } data) - { - var idx = data.Environments.FindIndex(x => x.Id == RemoteEnvironmentId); - return idx >= 0 ? idx : 0; - } - else - { - return 0; - } - } - set - { - if (value != null && value >= 0 && value < BootstrapData?.Environments.Count) - { - RemoteEnvironmentId = BootstrapData?.Environments[value.Value].Id; - } - } - } - - public EnvironmentBackend? RemoteEnvironmentBackend - { - get - { - var remoteEnv = RemoteEnvironment; - return remoteEnv != null ? BootstrapData?.Backends[remoteEnv.Value.Id] : null; - } - } // MARK: Tasks public TaskManager LocalGameServerManager; @@ -198,17 +105,23 @@ public void OnEnable() { RivetLogger.Log("On Enable"); + // Create dock Singleton = this; + // Create global + RivetGlobal.Singleton = new(); + + // Load settings PluginSettings.LoadSettings(); SharedSettings.LoadSettings(); // Task managers + var plugin = RivetGlobal.Singleton; LocalGameServerManager = new( initMessage: "Open \"Develop\" and press \"Start\" to start game server.", getStartConfig: async () => { - if (LocalGameServerExecutablePath != null) + if (plugin.LocalGameServerExecutablePath != null) { return new TaskConfig { @@ -216,13 +129,14 @@ public void OnEnable() Input = new JObject { ["cwd"] = Builder.ProjectRoot(), - ["cmd"] = LocalGameServerExecutablePath, + ["cmd"] = plugin.LocalGameServerExecutablePath, ["args"] = new JArray { "-batchmode", "-nographics", "-server" }, } }; } else { + RivetLogger.Warning("LocalGameServerManager.Start: no local game server executable path"); return null; } }, @@ -270,7 +184,7 @@ public void OnEnable() }; // Bootstrap - _ = GetBootstrapData(); + _ = RivetGlobal.Singleton.Bootstrap(); // Start backend // _ = BackendManager.StartTask(); @@ -310,20 +224,9 @@ void SetTab(MainTab tab) _settingsTabBody.style.display = tab == MainTab.Settings ? DisplayStyle.Flex : DisplayStyle.None; } - public async Task GetBootstrapData() + public void OnBootstrap() { - var result = await new RivetTask("get_bootstrap_data", new JObject()).RunAsync(); - if (result is ResultErr err) - { - return; - } - - var data = result.Data.ToObject(); ; - BootstrapData = data; - - _developController.OnBootstrap(data); - - SharedSettings.UpdateFromPlugin(); + _developController.OnBootstrap(); } /// diff --git a/Assets/Rivet/Editor/UI/Dock/Dock.unity b/Assets/Rivet/Editor/UI/Dock/Dock.unity deleted file mode 100644 index ed813af..0000000 --- a/Assets/Rivet/Editor/UI/Dock/Dock.unity +++ /dev/null @@ -1,316 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!29 &1 -OcclusionCullingSettings: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_OcclusionBakeSettings: - smallestOccluder: 5 - smallestHole: 0.25 - backfaceThreshold: 100 - m_SceneGUID: 00000000000000000000000000000000 - m_OcclusionCullingData: {fileID: 0} ---- !u!104 &2 -RenderSettings: - m_ObjectHideFlags: 0 - serializedVersion: 9 - m_Fog: 0 - m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} - m_FogMode: 3 - m_FogDensity: 0.01 - m_LinearFogStart: 0 - m_LinearFogEnd: 300 - m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} - m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} - m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} - m_AmbientIntensity: 1 - m_AmbientMode: 0 - m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} - m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} - m_HaloStrength: 0.5 - m_FlareStrength: 1 - m_FlareFadeSpeed: 3 - m_HaloTexture: {fileID: 0} - m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} - m_DefaultReflectionMode: 0 - m_DefaultReflectionResolution: 128 - m_ReflectionBounces: 1 - m_ReflectionIntensity: 1 - m_CustomReflection: {fileID: 0} - m_Sun: {fileID: 0} - m_UseRadianceAmbientProbe: 0 ---- !u!157 &3 -LightmapSettings: - m_ObjectHideFlags: 0 - serializedVersion: 12 - m_GIWorkflowMode: 1 - m_GISettings: - serializedVersion: 2 - m_BounceScale: 1 - m_IndirectOutputScale: 1 - m_AlbedoBoost: 1 - m_EnvironmentLightingMode: 0 - m_EnableBakedLightmaps: 1 - m_EnableRealtimeLightmaps: 0 - m_LightmapEditorSettings: - serializedVersion: 12 - m_Resolution: 2 - m_BakeResolution: 40 - m_AtlasSize: 1024 - m_AO: 0 - m_AOMaxDistance: 1 - m_CompAOExponent: 1 - m_CompAOExponentDirect: 0 - m_ExtractAmbientOcclusion: 0 - m_Padding: 2 - m_LightmapParameters: {fileID: 0} - m_LightmapsBakeMode: 1 - m_TextureCompression: 1 - m_FinalGather: 0 - m_FinalGatherFiltering: 1 - m_FinalGatherRayCount: 256 - m_ReflectionCompression: 2 - m_MixedBakeMode: 2 - m_BakeBackend: 1 - m_PVRSampling: 1 - m_PVRDirectSampleCount: 32 - m_PVRSampleCount: 512 - m_PVRBounces: 2 - m_PVREnvironmentSampleCount: 256 - m_PVREnvironmentReferencePointCount: 2048 - m_PVRFilteringMode: 1 - m_PVRDenoiserTypeDirect: 1 - m_PVRDenoiserTypeIndirect: 1 - m_PVRDenoiserTypeAO: 1 - m_PVRFilterTypeDirect: 0 - m_PVRFilterTypeIndirect: 0 - m_PVRFilterTypeAO: 0 - m_PVREnvironmentMIS: 1 - m_PVRCulling: 1 - m_PVRFilteringGaussRadiusDirect: 1 - m_PVRFilteringGaussRadiusIndirect: 5 - m_PVRFilteringGaussRadiusAO: 2 - m_PVRFilteringAtrousPositionSigmaDirect: 0.5 - m_PVRFilteringAtrousPositionSigmaIndirect: 2 - m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ExportTrainingData: 0 - m_TrainingDataDestination: TrainingData - m_LightProbeSampleCountMultiplier: 4 - m_LightingDataAsset: {fileID: 0} - m_LightingSettings: {fileID: 0} ---- !u!196 &4 -NavMeshSettings: - serializedVersion: 2 - m_ObjectHideFlags: 0 - m_BuildSettings: - serializedVersion: 3 - agentTypeID: 0 - agentRadius: 0.5 - agentHeight: 2 - agentSlope: 45 - agentClimb: 0.4 - ledgeDropHeight: 0 - maxJumpAcrossDistance: 0 - minRegionArea: 2 - manualCellSize: 0 - cellSize: 0.16666667 - manualTileSize: 0 - tileSize: 256 - buildHeightMesh: 0 - maxJobWorkers: 0 - preserveTilesOutsideBounds: 0 - debug: - m_Flags: 0 - m_NavMeshData: {fileID: 0} ---- !u!1 &93849972 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 93849974} - - component: {fileID: 93849973} - m_Layer: 0 - m_Name: Directional Light - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!108 &93849973 -Light: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 93849972} - m_Enabled: 1 - serializedVersion: 10 - m_Type: 1 - m_Shape: 0 - m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} - m_Intensity: 1 - m_Range: 10 - m_SpotAngle: 30 - m_InnerSpotAngle: 21.80208 - m_CookieSize: 10 - m_Shadows: - m_Type: 2 - m_Resolution: -1 - m_CustomResolution: -1 - m_Strength: 1 - m_Bias: 0.05 - m_NormalBias: 0.4 - m_NearPlane: 0.2 - m_CullingMatrixOverride: - e00: 1 - e01: 0 - e02: 0 - e03: 0 - e10: 0 - e11: 1 - e12: 0 - e13: 0 - e20: 0 - e21: 0 - e22: 1 - e23: 0 - e30: 0 - e31: 0 - e32: 0 - e33: 1 - m_UseCullingMatrixOverride: 0 - m_Cookie: {fileID: 0} - m_DrawHalo: 0 - m_Flare: {fileID: 0} - m_RenderMode: 0 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingLayerMask: 1 - m_Lightmapping: 4 - m_LightShadowCasterMode: 0 - m_AreaSize: {x: 1, y: 1} - m_BounceIntensity: 1 - m_ColorTemperature: 6570 - m_UseColorTemperature: 0 - m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} - m_UseBoundingSphereOverride: 0 - m_UseViewFrustumForShadowCasterCull: 1 - m_ShadowRadius: 0 - m_ShadowAngle: 0 ---- !u!4 &93849974 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 93849972} - serializedVersion: 2 - m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} - m_LocalPosition: {x: 0, y: 3, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} ---- !u!1 &1619145530 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1619145533} - - component: {fileID: 1619145532} - - component: {fileID: 1619145531} - m_Layer: 0 - m_Name: Main Camera - m_TagString: MainCamera - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!81 &1619145531 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1619145530} - m_Enabled: 1 ---- !u!20 &1619145532 -Camera: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1619145530} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} - m_projectionMatrixMode: 1 - m_GateFitMode: 2 - m_FOVAxisMode: 0 - m_Iso: 200 - m_ShutterSpeed: 0.005 - m_Aperture: 16 - m_FocusDistance: 10 - m_FocalLength: 50 - m_BladeCount: 5 - m_Curvature: {x: 2, y: 11} - m_BarrelClipping: 0.25 - m_Anamorphism: 0 - m_SensorSize: {x: 36, y: 24} - m_LensShift: {x: 0, y: 0} - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 60 - orthographic: 0 - orthographic size: 5 - m_Depth: -1 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingPath: -1 - m_TargetTexture: {fileID: 0} - m_TargetDisplay: 0 - m_TargetEye: 3 - m_HDR: 1 - m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 - m_ForceIntoRT: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 ---- !u!4 &1619145533 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1619145530} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} - 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} ---- !u!1660057539 &9223372036854775807 -SceneRoots: - m_ObjectHideFlags: 0 - m_Roots: - - {fileID: 1619145533} - - {fileID: 93849974} diff --git a/Assets/Rivet/Editor/UI/Dock/Dock.unity.meta b/Assets/Rivet/Editor/UI/Dock/Dock.unity.meta deleted file mode 100644 index da989a0..0000000 --- a/Assets/Rivet/Editor/UI/Dock/Dock.unity.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 04e1230a9fe144f74a6f7af15018088b -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Rivet/Editor/UI/Dock/Tabs/DevelopController.cs b/Assets/Rivet/Editor/UI/Dock/Tabs/DevelopController.cs index 9fe5740..e0b659f 100644 --- a/Assets/Rivet/Editor/UI/Dock/Tabs/DevelopController.cs +++ b/Assets/Rivet/Editor/UI/Dock/Tabs/DevelopController.cs @@ -51,19 +51,20 @@ public DevelopController(Dock dock, VisualElement root) void InitUI() { - return; + var plugin = RivetGlobal.Singleton; + // Query _refreshButton = _root.Q("EnvironmentHeader").Q("Header").Q("Action"); _environmentTypeDropdown = _root.Q("EnvironmentBody").Q("TypeDropdown"); _remoteEnvironmentDropdown = _root.Q("EnvironmentBody").Q("EnvironmentDropdown"); - _lgsStart = _root.Q("LocalGameServerBody").Q("ButtonRow").Q("StartButton").Q public void OnSelectedEnvironmentChange() { - _environmentTypeDropdown.index = (int)_dock.EnvironmentType; - _remoteEnvironmentDropdown.index = _dock.RemoteEnvironmentIndex ?? -1; + var plugin = RivetGlobal.Singleton; + _environmentTypeDropdown.index = (int)plugin.EnvironmentType; + _remoteEnvironmentDropdown.index = plugin.RemoteEnvironmentIndex ?? -1; _remoteEnvironmentDropdown.style.display = _environmentTypeDropdown.index == (int)EnvironmentType.Local ? DisplayStyle.None : DisplayStyle.Flex; } @@ -140,14 +147,17 @@ private void OnLocalGameServerStateChange(bool running) private void OnLocalGameServerStart() { string serverPath; - try { + try + { serverPath = Builder.BuildDevDedicatedServer(); - } catch (Exception e) { + } + catch (Exception e) + { EditorUtility.DisplayDialog("Server Build Failed", e.Message, "Dismiss"); return; } - _dock.LocalGameServerExecutablePath = serverPath; + RivetGlobal.Singleton.LocalGameServerExecutablePath = serverPath; _ = _dock.LocalGameServerManager.StartTask(); } @@ -160,12 +170,14 @@ private void OnPlayerStart() private void OnBuildAndDeploy() { + var plugin = RivetGlobal.Singleton; + // Force to remote env to update testing to correct env - _dock.EnvironmentType = EnvironmentType.Remote; + plugin.EnvironmentType = EnvironmentType.Remote; _dock.OnSelectedEnvironmentChange(); // Get the selected environment ID - string environmentId = _dock.RemoteEnvironmentId; + string environmentId = plugin.RemoteEnvironmentId; if (environmentId == null) { throw new System.Exception("Could not get ID for remote env"); @@ -179,9 +191,12 @@ private void OnBuildAndDeploy() string? serverPath = null; if (deployGameServer) { - try { + try + { serverPath = Builder.BuildReleaseDedicatedServer(); - } catch (Exception e) { + } + catch (Exception e) + { EditorUtility.DisplayDialog("Server Build Failed", e.Message, "Dismiss"); } } @@ -200,14 +215,7 @@ private void OnBuildAndDeploy() { if (output is ResultOk ok) { - var gameServerObj = ok.Data["game_server"]; - if (gameServerObj != null && gameServerObj.Type == JTokenType.Object) - { - var version = gameServerObj["version_name"]?.ToString(); - Rivet.Editor.UI.Dock.Dock.Singleton.GameVersion = version; - SharedSettings.UpdateFromPlugin(); - Debug.Log($"New game version: {Dock.Singleton.GameVersion}"); - } + // TODO: } }; } diff --git a/Assets/Rivet/Editor/UI/Dock/Tabs/ModulesController.cs b/Assets/Rivet/Editor/UI/Dock/Tabs/ModulesController.cs index 6d27d0d..fad489c 100644 --- a/Assets/Rivet/Editor/UI/Dock/Tabs/ModulesController.cs +++ b/Assets/Rivet/Editor/UI/Dock/Tabs/ModulesController.cs @@ -31,25 +31,5 @@ public ModulesController(Dock dock, VisualElement root) void InitUI() { } - - public void OnBootstrap(BootstrapData data) - { - // Add environments - List environments = new(); - foreach (var env in data.Environments) - { - environments.Add(env.Name); - } - environments.Add("+ New Environment"); - _environmentDropdown.choices = environments; - - if (environments.Count > 0) - { - _environmentDropdown.index = 0; - _dock.RemoteEnvironmentIndex = 0; - } - - // OnSelectedEnvironmentChange(); - } } } \ No newline at end of file diff --git a/Assets/Rivet/Editor/UI/SignIn/LoginController.cs b/Assets/Rivet/Editor/UI/SignIn/LoginController.cs index 18c4d45..44badeb 100644 --- a/Assets/Rivet/Editor/UI/SignIn/LoginController.cs +++ b/Assets/Rivet/Editor/UI/SignIn/LoginController.cs @@ -35,11 +35,11 @@ void InitUI() _elSignIn = _root.Q