using System; using System.Collections; using System.IO; using GameCult.Eve.UnityScene; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; public sealed class AetheriaUnityClient : MonoBehaviour { private EveUnityCultMeshPlayableWorldProvider _provider; private EveUnityPlayableWorldClientBootstrap _bootstrap; private string _status = "Starting EveUnity..."; private void Awake() { Application.runInBackground = true; var endpoint = Environment.GetEnvironmentVariable("EVEUNITY_RENDEZVOUS_ENDPOINT") ?? "rudp://127.0.0.1:3076"; var surfaceId = Environment.GetEnvironmentVariable("EVEUNITY_SURFACE_ID") ?? "aetheria.pilot"; var replicaPath = Path.Combine(Application.persistentDataPath, "aetheria-unity.cc"); CreateView(); gameObject.AddComponent(); _provider = gameObject.AddComponent(); _provider.Configure( endpoint, replicaPath, surfaceId: surfaceId, requiredSurfaceKind: "interactive-world", clientRuntimeId: "aetheria-unity"); _bootstrap = gameObject.AddComponent(); _bootstrap.ConfigureProvider(_provider); StartCoroutine(ConnectAfterFirstFrame()); } private IEnumerator ConnectAfterFirstFrame() { yield return null; _status = "Connecting to the advertised Eve surface..."; yield return null; var presentation = _bootstrap.Mount(); _status = $"Connected: {_provider.Selection.ProviderId} / {_provider.Selection.SurfaceId} / {presentation.ActiveEntities} entities"; } private static void CreateView() { if (GraphicsSettings.currentRenderPipeline is not UniversalRenderPipelineAsset) throw new InvalidOperationException("Aetheria Unity requires the project-configured Universal Render Pipeline asset."); var cameraObject = new GameObject("Main Camera") { tag = "MainCamera" }; var camera = cameraObject.AddComponent(); cameraObject.AddComponent().renderPostProcessing = true; camera.clearFlags = CameraClearFlags.SolidColor; camera.backgroundColor = new Color(0.025f, 0.035f, 0.055f); camera.nearClipPlane = 0.05f; camera.farClipPlane = 10000f; var lightObject = new GameObject("World Light"); var light = lightObject.AddComponent(); light.type = LightType.Directional; light.intensity = 1.4f; lightObject.transform.rotation = Quaternion.Euler(50f, -35f, 0f); } private void OnGUI() { GUI.Box(new Rect(12, 12, Math.Min(Screen.width - 24, 760), 54), _status + "\nWASD / left stick: move Mouse 1 / controller action: activate"); } }