using RebootKit.Engine.Main; using RebootKit.Engine.Services.Console; using RebootKit.Engine.UI; using UnityEditor; using UnityEngine; using UnityEngine.UIElements; namespace RebootKitEditor.RebootWindow { public class HomeView : IView { public void Dispose() { } public VisualElement Build() { VisualElement rootContainer = new() { style = { flexGrow = 1, fontSize = 14 } }; Label label = new($"{Application.productName} {Application.version}") { style = { fontSize = 18, unityFontStyleAndWeight = FontStyle.Bold } }; rootContainer.Add(label); VisualElement persistentPathContainer = new() { style = { marginTop = 8, marginBottom = 8, paddingLeft = 4, paddingRight = 4, paddingTop = 4, paddingBottom = 4, borderLeftWidth = 1, borderLeftColor = new Color(0.3f, 0.3f, 0.3f), flexDirection = FlexDirection.Row, } }; Label persistentPathLabel = new($"Persistent Path: {Application.persistentDataPath}") { style = { fontSize = 12, color = new Color(0.7f, 0.9f, 0.9f) } }; persistentPathContainer.Add(persistentPathLabel); Button openPersistentPathButton = new(() => { Application.OpenURL(Application.persistentDataPath); }) { style = { fontSize = 12, width = 48 }, text = "Open" }; persistentPathContainer.Add(openPersistentPathButton); rootContainer.Add(persistentPathContainer); Label onGameRunScriptLabel = new("On Game Run Script (User):") { style = { fontSize = 12, color = new Color(0.7f, 0.9f, 0.9f) } }; rootContainer.Add(onGameRunScriptLabel); TextField onGameRunScriptTextField = new() { style = { fontSize = 12, }, multiline = true, value = EditorPrefs.GetString(REditorConsts.k_OnGameRunScriptContentKey, "") }; onGameRunScriptTextField.RegisterValueChangedCallback(evt => { EditorPrefs.SetString(REditorConsts.k_OnGameRunScriptContentKey, evt.newValue); }); rootContainer.Add(onGameRunScriptTextField); Label consoleCommandsLabel = new("Console Commands:") { style = { fontSize = 12, color = new Color(0.7f, 0.9f, 0.9f) } }; rootContainer.Add(consoleCommandsLabel); ConsoleService.ConsoleCommand[] consoleCommands = ConsoleService.GenerateCommandsToRegister(); foreach (ConsoleService.ConsoleCommand consoleCommand in consoleCommands) { VisualElement commandContainer = new() { style = { flexDirection = FlexDirection.Row, marginTop = 4, marginBottom = 4, paddingLeft = 4, paddingRight = 4, paddingTop = 4, paddingBottom = 4, } }; Label commandLabel = new(consoleCommand.name) { style = { fontSize = 12, color = new Color(0.7f, 0.9f, 0.9f) } }; commandContainer.Add(commandLabel); Label descriptionLabel = new(consoleCommand.description) { style = { fontSize = 12, color = new Color(0.5f, 0.7f, 0.7f) } }; commandContainer.Add(descriptionLabel); rootContainer.Add(commandContainer); } return rootContainer; } } }