// MIRROR CHANGE: disable this completely. otherwise InitUIElements can still throw NRE. /* using UnityEditor; using UnityEngine; using UnityEngine.UIElements; using UnityEditor.UIElements; using System.Net.Http; using System.Net.Http.Headers; using System.Collections.Generic; using Newtonsoft.Json; using System.Net; using System.Text; using System; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Threading.Tasks; using IO.Swagger.Model; using UnityEditor.Build.Reporting; using Application = UnityEngine.Application; namespace Edgegap { public class EdgegapWindow : EditorWindow { // MIRROR CHANGE: create HTTPClient in-place to avoid InvalidOperationExceptions when reusing // static readonly HttpClient _httpClient = new HttpClient(); // END MIRROR CHANGE const string EditorDataSerializationName = "EdgegapSerializationData"; const int ServerStatusCronjobIntervalMs = 10000; // Interval at which the server status is updated // MIRROR CHANGE // get the path of this .cs file so we don't need to hardcode paths to // the .uxml and .uss files: // https://forum.unity.com/threads/too-many-hard-coded-paths-in-the-templates-and-documentation.728138/ // this way users can move this folder without breaking UIToolkit paths. internal string StylesheetPath => Path.GetDirectoryName(AssetDatabase.GetAssetPath(MonoScript.FromScriptableObject(this))); // END MIRROR CHANGE readonly System.Timers.Timer _updateServerStatusCronjob = new System.Timers.Timer(ServerStatusCronjobIntervalMs); [SerializeField] string _userExternalIp; [SerializeField] string _apiKey; [SerializeField] ApiEnvironment _apiEnvironment; [SerializeField] string _appName; [SerializeField] string _appVersionName; [SerializeField] string _deploymentRequestId; [SerializeField] string _containerRegistry; [SerializeField] string _containerImageRepo; [SerializeField] string _containerImageTag; [SerializeField] bool _autoIncrementTag = true; VisualTreeAsset _visualTree; bool _shouldUpdateServerStatus = false; // Interactable elements EnumField _apiEnvironmentSelect; TextField _apiKeyInput; TextField _appNameInput; TextField _appVersionNameInput; TextField _containerRegistryInput; TextField _containerImageRepoInput; TextField _containerImageTagInput; Toggle _autoIncrementTagInput; Button _connectionButton; Button _serverActionButton; Button _documentationBtn; Button _buildAndPushServerBtn; // Readonly elements Label _connectionStatusLabel; VisualElement _serverDataContainer; // server data manager StyleSheet _serverDataStylesheet; List _serverDataContainers = new List(); [Obsolete("See EdgegapWindowV2.ShowEdgegapToolWindow()")] // [MenuItem("Edgegap/Server Management")] public static void ShowEdgegapToolWindow() { EdgegapWindow window = GetWindow(); window.titleContent = new GUIContent("Edgegap Hosting"); // MIRROR CHANGE } protected void OnEnable() { // Set root VisualElement and style // BEGIN MIRROR CHANGE _visualTree = AssetDatabase.LoadAssetAtPath($"{StylesheetPath}/EdgegapWindow.uxml"); StyleSheet styleSheet = AssetDatabase.LoadAssetAtPath($"{StylesheetPath}/EdgegapWindow.uss"); _serverDataStylesheet = AssetDatabase.LoadAssetAtPath($"{StylesheetPath}/EdgegapServerData.uss"); // END MIRROR CHANGE rootVisualElement.styleSheets.Add(styleSheet); LoadToolData(); if (string.IsNullOrWhiteSpace(_userExternalIp)) { _userExternalIp = GetExternalIpAddress(); } } protected void Update() { if (_shouldUpdateServerStatus) { _shouldUpdateServerStatus = false; UpdateServerStatus(); } } public void CreateGUI() { rootVisualElement.Clear(); _visualTree.CloneTree(rootVisualElement); InitUIElements(); SyncFormWithObject(); bool hasActiveDeployment = !string.IsNullOrEmpty(_deploymentRequestId); if (hasActiveDeployment) { RestoreActiveDeployment(); } else { DisconnectCallback(); } } protected void OnDestroy() { bool deploymentActive = !string.IsNullOrEmpty(_deploymentRequestId); if (deploymentActive) { EditorUtility.DisplayDialog( "Warning", $"You have an active deployment ({_deploymentRequestId}) that won't be stopped automatically.", "Ok" ); } } protected void OnDisable() { SyncObjectWithForm(); SaveToolData(); DeregisterServerDataContainer(_serverDataContainer); } /// /// Binds the form inputs to the associated variables and initializes the inputs as required. /// Requires the VisualElements to be loaded before this call. Otherwise, the elements cannot be found. /// void InitUIElements() { _apiEnvironmentSelect = rootVisualElement.Q("environmentSelect"); _apiKeyInput = rootVisualElement.Q("apiKey"); _appNameInput = rootVisualElement.Q("appName"); _appVersionNameInput = rootVisualElement.Q("appVersionName"); _containerRegistryInput = rootVisualElement.Q("containerRegistry"); _containerImageRepoInput = rootVisualElement.Q("containerImageRepo"); _containerImageTagInput = rootVisualElement.Q("tag"); _autoIncrementTagInput = rootVisualElement.Q("autoIncrementTag"); _connectionButton = rootVisualElement.Q