### Floating Button Page Example in C# Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Demonstrates how to use the FloatingButtonPage to create a page with a floating action button for actions like 'Apply Changes'. It includes adding settings controls (sliders) and handling the button's completion callback. This example requires UnityDebugSheet.Runtime.Core.Scripts. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.Cells; using System; using System.Collections; public class FloatingButtonExamplePage : DefaultDebugPageBase { protected override string Title => "Settings Menu"; public override IEnumerator Initialize() { // Create a link to FloatingButtonPage var linkModel = new PageLinkButtonCellModel(false); linkModel.CellTexts.Text = "Apply Settings"; linkModel.PageType = typeof(FloatingButtonPage); linkModel.PageTitleOverride = "Configure and Apply"; linkModel.ShowArrow = true; linkModel.OnLoad += x => { var floatingPage = (FloatingButtonPage)x.page; float volume = 0.5f; float brightness = 1.0f; // Add settings controls floatingPage.AddSlider(0.5f, 0f, 1f, "Volume", valueChanged: v => volume = v); floatingPage.AddSlider(1.0f, 0.5f, 1.5f, "Brightness", valueChanged: v => brightness = v); // Setup the floating button floatingPage.Setup("Apply Changes", completed => { // Perform async operation floatingPage.StartCoroutine(ApplySettingsRoutine(volume, brightness, completed)); }); }; AddPageLinkButton(linkModel); yield break; } private IEnumerator ApplySettingsRoutine(float volume, float brightness, Action completed) { Debug.Log($"Applying: Volume={volume}, Brightness={brightness}"); yield return new WaitForSeconds(0.5f); Debug.Log("Settings applied!"); completed(); } } ``` -------------------------------- ### Add Numeric Sliders in UnityDebugSheet Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Explains how to integrate sliders for numeric input. Includes examples for floating-point values, integer constraints, and custom formatting. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.Cells; public class SliderExamplePage : DefaultDebugPageBase { protected override string Title => "Sliders Example"; public override IEnumerator Initialize() { AddSlider(0.5f, 0.0f, 1.0f, "Master Volume", valueChanged: value => { AudioListener.volume = value; }); AddSlider(60f, 30f, 144f, "Target FPS", showValueText: true, valueTextFormat: "F0", wholeNumbers: true, valueChanged: value => { Application.targetFrameRate = (int)value; }); var sliderModel = new SliderCellModel(true, 0.1f, 2.0f); sliderModel.CellTexts.Text = "Time Scale"; sliderModel.CellTexts.SubText = "Adjust game speed"; sliderModel.Value = 1.0f; sliderModel.ShowValueText = true; sliderModel.ValueTextFormat = "F2"; sliderModel.ValueChanged += value => Time.timeScale = value; AddSlider(sliderModel); yield break; } } ``` -------------------------------- ### Integrate with In-game Debug Console Source: https://github.com/haruma-k/unitydebugsheet/blob/master/README.md This code demonstrates how to link Unity Debug Sheet with the In-game Debug Console. It requires setup of the In-game Debug Console package and potentially adding scripting define symbols and referencing assemblies. ```csharp DefaultDebugPageBase.AddPageLinkButton("In-Game Debug Console", onLoad: x => x.page.Setup(DebugLogManager.Instance)); ``` -------------------------------- ### Pop Multiple Pages from Unity Debug Sheet Source: https://github.com/haruma-k/unitydebugsheet/blob/master/README.md This code shows how to pop multiple pages at once from the Unity Debug Sheet. It includes examples for popping a specific number of pages or pages up to a certain PageID. Lifecycle events for skipped pages are also mentioned. ```csharp DebugSheet debugSheet; debugSheet.PopPage(true, 2); ``` ```csharp DebugSheet debugSheet; debugSheet.PushPage(true, onLoad: x => { var pageId = x.pageId; }); ``` ```csharp DebugSheet debugSheet; debugSheet.PushPage(true, pageId: "MyPageId"); ``` -------------------------------- ### Integrate with Graphy Source: https://github.com/haruma-k/unitydebugsheet/blob/master/README.md This snippet shows how to integrate Unity Debug Sheet with the Graphy package for displaying FPS and memory information. It requires Graphy installation and potentially scripting define symbols and assembly references. ```csharp DefaultDebugPageBase.AddPageLinkButton("Graphy", onLoad: x => x.page.Setup(GraphyManager.Instance)); ``` -------------------------------- ### Add Page Link Buttons for Navigation Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Implements buttons that navigate to other debug pages, creating a hierarchical menu structure. Page link buttons automatically display a navigation arrow. Supports direct linking, generic page types, and custom setup callbacks. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.Cells; public class NavigationExamplePage : DefaultDebugPageBase { protected override string Title => "Main Debug Menu"; public override IEnumerator Initialize() { // Link to a generic DebugPage AddPageLinkButton("Player Stats", onLoad: x => { x.page.AddLabel("Health", subText: "100"); x.page.AddLabel("Mana", subText: "50"); }); // Link to a custom page type AddPageLinkButton("Graphics Settings"); // Link with setup callback AddPageLinkButton("Character Viewer", subText: "View and modify characters", onLoad: x => x.page.Setup(characterSpawner, standController)); // Using model for full control var linkModel = new PageLinkButtonCellModel(true); linkModel.CellTexts.Text = "Audio Settings"; linkModel.CellTexts.SubText = "Volume, effects, music"; linkModel.PageType = typeof(AudioSettingsPage); linkModel.ShowArrow = true; linkModel.OnLoad += x => Debug.Log("Audio page loaded"); AddPageLinkButton(linkModel); yield break; } } ``` -------------------------------- ### Initialize DebugSheet System Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Demonstrates how to access the DebugSheet singleton to initialize the root page and link custom debug pages. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityEngine; public class DebugSheetController : MonoBehaviour { private void Start() { var rootPage = DebugSheet.Instance.GetOrCreateInitialPage(); rootPage.AddPageLinkButton("Example Debug Page"); } } ``` -------------------------------- ### Create a Custom Debug Page Source: https://github.com/haruma-k/unitydebugsheet/blob/master/README.md Demonstrates how to define a new debug page by inheriting from DefaultDebugPageBase and adding interactive elements like buttons. ```csharp using System.Collections; using UnityDebugSheet.Runtime.Core.Scripts; using UnityEngine; public sealed class ExampleDebugPage : DefaultDebugPageBase { protected override string Title { get; } = "Example Debug Page"; public override IEnumerator Initialize() { AddButton("Example Button", clicked: () => { Debug.Log("Clicked"); }); yield break; } } ``` -------------------------------- ### Create Custom Debug Page Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Shows how to create a custom debug page by inheriting from DefaultDebugPageBase and implementing the Initialize method to add various UI controls. ```csharp using System.Collections; using UnityDebugSheet.Runtime.Core.Scripts; using UnityEngine; public sealed class ExampleDebugPage : DefaultDebugPageBase { protected override string Title => "Example Debug Page"; public override IEnumerator Initialize() { AddButton("Example Button", clicked: () => Debug.Log("Button clicked!")); AddSwitch(false, "Enable Feature", valueChanged: isOn => { Debug.Log($"Feature enabled: {isOn}"); }); AddSlider(0.5f, 0.0f, 1.0f, "Volume", valueChanged: value => { Debug.Log($"Volume: {value}"); }); yield break; } } ``` -------------------------------- ### Implement Multi-Selection Pickers in UnityDebugSheet Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Explains how to add pickers that allow users to toggle multiple options simultaneously. It demonstrates both direct method usage and the use of MultiPickerCellModel for more complex state management. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.Cells; using System.Collections.Generic; public class MultiPickerExamplePage : DefaultDebugPageBase { public override IEnumerator Initialize() { var features = new[] { "Shadows", "Reflections", "Anti-Aliasing", "Bloom", "Motion Blur" }; AddMultiPicker(features, new[] { 0, 2, 3 }, "Graphics Features", optionStateChanged: (index, isOn) => Debug.Log($"{features[index]}: {isOn}"), confirmed: () => Debug.Log("Selection confirmed")); var multiModel = new MultiPickerCellModel(); multiModel.Text = "Enable Layers"; multiModel.SetOptions(new[] { "UI", "Environment", "Characters", "Effects" }, new[] { 0, 1, 2 }); multiModel.OptionStateChanged += (index, isOn) => Debug.Log($"Layer {index}: {isOn}"); AddMultiPicker(multiModel); yield break; } } ``` -------------------------------- ### Implement Custom Cells for Unity Debug Sheet Source: https://github.com/haruma-k/unitydebugsheet/blob/master/README.md Shows how to create a custom UI cell by inheriting from Cell and CellModel. Requires a corresponding prefab with a LayoutElement for the cell recycling system. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityEngine; using UnityEngine.UI; public sealed class CustomTextCell : Cell { [SerializeField] private Text _text; [SerializeField] private LayoutElement _layoutElement; private const int Padding = 36; protected override void SetModel(CustomTextCellModel model) { _text.text = model.Text; _text.color = model.Color; _layoutElement.preferredHeight = _text.preferredHeight + Padding; } } public sealed class CustomTextCellModel : CellModel { public string Text { get; set; } public Color Color { get; set; } = Color.black; } ``` -------------------------------- ### Implement Standard Pickers in UnityDebugSheet Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Demonstrates how to add standard option pickers to a debug page. It covers both simple array-based initialization and advanced configuration using PickerCellModel to handle option changes and confirmation events. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.Cells; public class PickerExamplePage : DefaultDebugPageBase { protected override string Title => "Pickers Example"; public override IEnumerator Initialize() { var difficulties = new[] { "Easy", "Normal", "Hard", "Nightmare" }; AddPicker(difficulties, 1, "Difficulty", activeOptionChanged: index => Debug.Log($"Difficulty: {difficulties[index]}"), confirmed: () => Debug.Log("Difficulty selection confirmed")); var pickerModel = new PickerCellModel(); pickerModel.Text = "Graphics Quality"; pickerModel.SetOptions(new[] { "Low", "Medium", "High", "Ultra" }, 2); pickerModel.ActiveOptionChanged += index => { QualitySettings.SetQualityLevel(index); Debug.Log($"Quality level: {index}"); }; pickerModel.Confirmed += () => Debug.Log("Quality saved"); AddPicker(pickerModel); yield break; } } ``` -------------------------------- ### Configure Unity Package Dependencies Source: https://github.com/haruma-k/unitydebugsheet/blob/master/README.md Shows how to add the UnityDebugSheet dependency to the project's manifest.json file, including optional versioning. ```json { "dependencies": { "com.harumak.unitydebugsheet": "https://github.com/Haruma-K/UnityDebugSheet.git?path=/Assets/UnityDebugSheet" } } ``` -------------------------------- ### Display Unity System Information Source: https://github.com/haruma-k/unitydebugsheet/blob/master/README.md This snippet shows how to add a button to display system information within Unity. It requires referencing the SystemInfoDebugPage class and can be integrated into custom assemblies. ```csharp DefaultDebugPageBase.AddPageLinkButton("System Info"); ``` -------------------------------- ### Link Custom Debug Page to Root Source: https://github.com/haruma-k/unitydebugsheet/blob/master/README.md Explains how to register a custom debug page by adding a link button to the root debug sheet instance. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityEngine; public sealed class DebugSheetController : MonoBehaviour { private void Start() { var rootPage = DebugSheet.Instance.GetOrCreateInitialPage(); rootPage.AddPageLinkButton(nameof(ExampleDebugPage)); } } ``` -------------------------------- ### Add Button Collection for Quick Actions Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Adds a collection of small buttons arranged in a grid layout, ideal for presenting numerous quick actions in a compact space. Each button can have custom text and a click handler. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.Cells; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.CellParts; public class ButtonCollectionExamplePage : DefaultDebugPageBase { protected override string Title => "Quick Actions"; public override IEnumerator Initialize() { var collectionModel = new ButtonCollectionCellModel(); // Add multiple small buttons var actions = new[] { "Kill All", "Heal", "Add Gold", "Level Up", "Reset", "Teleport" }; for (int i = 0; i < actions.Length; i++) { int index = i; var buttonData = new CollectionButtonModel(); buttonData.Text = actions[i]; buttonData.Clicked += () => ExecuteAction(index); collectionModel.Buttons.Add(buttonData); } AddButtonCollection(collectionModel); yield break; } private void ExecuteAction(int actionIndex) { Debug.Log($"Executing action {actionIndex}"); } } ``` -------------------------------- ### Add Text Input Fields in UnityDebugSheet Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Shows how to implement text input fields for user interaction. Covers basic string input, integer-only fields, and model-based configuration for complex inputs. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.Cells; using UnityEngine.UI; public class InputFieldExamplePage : DefaultDebugPageBase { protected override string Title => "Input Fields Example"; public override IEnumerator Initialize() { AddInputField("Player Name", placeholder: "Enter name...", valueChanged: text => Debug.Log($"Name: {text}")); AddInputField("Starting Gold", placeholder: "0", contentType: InputField.ContentType.IntegerNumber, valueChanged: text => { if (int.TryParse(text, out int gold)) Debug.Log($"Gold set to: {gold}"); }); var inputModel = new InputFieldCellModel(true); inputModel.CellTexts.Text = "Cheat Code"; inputModel.CellTexts.SubText = "Enter debug command"; inputModel.Placeholder = "Type command..."; inputModel.ContentType = InputField.ContentType.Standard; inputModel.ValueChanged += command => ExecuteCheatCode(command); AddInputField(inputModel); yield break; } private void ExecuteCheatCode(string code) { Debug.Log($"Executing: {code}"); } } ``` -------------------------------- ### Implement Enum-based Pickers in UnityDebugSheet Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Shows how to create pickers that automatically derive options from C# enums. Includes support for single-value selection and multi-select flag enums using EnumPickerCellModel and EnumMultiPickerCellModel. ```csharp using System; using UnityDebugSheet.Runtime.Core.Scripts; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.Cells; public class EnumPickerExamplePage : DefaultDebugPageBase { public enum GameState { MainMenu, Playing, Paused, GameOver } [Flags] public enum DebugFlags { None = 0, ShowColliders = 1, ShowPaths = 2, ShowStats = 4 } public override IEnumerator Initialize() { AddEnumPicker(GameState.Playing, "Game State", activeValueChanged: value => Debug.Log($"State changed to: {(GameState)value}")); var enumModel = new EnumPickerCellModel(GameState.MainMenu); enumModel.Text = "Force State"; enumModel.ActiveValueChanged += value => Debug.Log($"Forced: {(GameState)value}"); AddEnumPicker(enumModel); var flagsModel = new EnumMultiPickerCellModel(DebugFlags.ShowColliders | DebugFlags.ShowStats); flagsModel.Text = "Debug Flags"; flagsModel.ActiveValueChanged += value => Debug.Log($"Active flags: {(DebugFlags)value}"); AddEnumMultiPicker(flagsModel); yield break; } } ``` -------------------------------- ### Control Debug Sheet Navigation Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Demonstrates how to programmatically show, hide, push, and pop pages within the Unity Debug Sheet. It covers basic navigation actions and advanced options like popping multiple pages or navigating to a specific page ID. Dependencies include the core UnityDebugSheet library. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityEngine; public class DebugSheetNavigationExample : MonoBehaviour { public void ShowDebugMenu() { DebugSheet.Instance.Show(); } public void HideDebugMenu() { DebugSheet.Instance.Hide(); } public void PushCustomPage() { // Push a new page onto the navigation stack DebugSheet.Instance.PushPage( playAnimation: true, titleOverride: "Custom Title", onLoad: x => x.page.Setup(someData), pageId: "my-custom-page"); } public void PopCurrentPage() { // Pop the current page DebugSheet.Instance.PopPage(playAnimation: true); } public void PopMultiplePages() { // Pop multiple pages at once DebugSheet.Instance.PopPage(playAnimation: true, popCount: 2); // Or pop to a specific page by ID // DebugSheet.Instance.PopPage(true, "target-page-id"); } public void NavigateFromWithinPage() { // From within a debug page, use DebugSheet.Of(transform) // DebugSheet.Of(transform).PushPage(true); } } ``` -------------------------------- ### Control Debug Menu Programmatically Source: https://github.com/haruma-k/unitydebugsheet/blob/master/README.md This C# code demonstrates how to toggle the debug menu's open/closed state using its controller. It checks the current progress of the drawer and sets the target state accordingly, with animation. ```csharp // These scripts are attached on the GameObject "DebugSheetCanvas > Drawer". StatefulDrawer drawer; StatefulDrawerController drawerController; // Toggle debug sheet. var isClosed = Mathf.Approximately(drawer.Progress, drawer.MinProgress); var targetState = isClosed ? DrawerState.Max : DrawerState.Min; drawerController.SetStateWithAnimation(targetState); ``` -------------------------------- ### Add Buttons to Debug Page Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Demonstrates adding interactive buttons to a debug page, supporting simple callbacks or detailed button models for advanced configuration. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.Cells; public class ButtonExamplePage : DefaultDebugPageBase { protected override string Title => "Buttons Example"; public override IEnumerator Initialize() { AddButton("Reset Position", clicked: () => Debug.Log("Position reset!")); AddButton("Player Settings", subText: "Configure player options", showAllow: true, clicked: () => Debug.Log("Opening settings...")); var buttonModel = new ButtonCellModel(true); buttonModel.CellTexts.Text = "Spawn Enemy"; buttonModel.Clicked += () => Debug.Log("Enemy spawned!"); AddButton(buttonModel); yield break; } } ``` -------------------------------- ### Add Labels to Debug Page Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Illustrates how to add static text labels to a debug page, including options for sub-text and custom models for icon support. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.Cells; public class LabelExamplePage : DefaultDebugPageBase { protected override string Title => "Labels Example"; public override IEnumerator Initialize() { AddLabel("Player Stats"); AddLabel("Health", subText: "100/100"); var labelModel = new LabelCellModel(true); labelModel.CellTexts.Text = "Status"; labelModel.CellTexts.SubText = "Active"; AddLabel(labelModel); yield break; } } ``` -------------------------------- ### Add Debug Menu Elements in Unity Source: https://github.com/haruma-k/unitydebugsheet/blob/master/README.md Demonstrates how to add various interactive elements such as labels, buttons, switches, and sliders to a Unity Debug Sheet. These methods allow for quick integration of debug controls into the hierarchical menu. ```csharp // Label AddLabel("Example Label"); // Button AddButton("Example Button", clicked: () => { Debug.Log("Clicked"); }); // Switch AddSwitch(false, "Example Switch", valueChanged: x => Debug.Log($"Changed: {x}")); // Slider AddSlider(0.5f, 0.0f, 1.0f, "Example Slider", valueChanged: x => Debug.Log($"Value Changed: {x}")); ``` -------------------------------- ### Create Custom Debug Sheet Cells Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Explains how to create entirely new cell types for the Unity Debug Sheet by defining custom cell components and their corresponding models. This allows for highly specialized UI elements within the debug panel. Requires inheriting from Cell and CellModel, and registering the prefab. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityEngine; using UnityEngine.UI; // Custom cell component public sealed class CustomTextCell : Cell { [SerializeField] private Text _text; [SerializeField] private LayoutElement _layoutElement; private const int Padding = 36; protected override void SetModel(CustomTextCellModel model) { _text.text = model.Text; _text.color = model.Color; _layoutElement.preferredHeight = _text.preferredHeight + Padding; } } // Custom cell model public sealed class CustomTextCellModel : CellModel { public string Text { get; set; } public Color Color { get; set; } = Color.black; } // Using custom cell in a page public class CustomCellPage : DebugPageBase { protected override string Title => "Custom Cells"; public override IEnumerator Initialize() { // Add custom cell using AddItem with prefab key var model = new CustomTextCellModel { Text = "This is custom formatted text", Color = Color.blue }; AddItem("CustomTextCell", model); // Prefab must be registered in DebugSheet.CellPrefabs yield break; } } ``` -------------------------------- ### Add Toggle Switches in UnityDebugSheet Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Demonstrates how to add boolean toggle switches to a debug page. It shows both simple implementation and advanced usage with custom models and sub-text. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.Cells; public class SwitchExamplePage : DefaultDebugPageBase { protected override string Title => "Switches Example"; private bool _godMode = false; private bool _showFps = true; public override IEnumerator Initialize() { AddSwitch(_godMode, "God Mode", valueChanged: value => { _godMode = value; Debug.Log($"God Mode: {value}"); }); AddSwitch(_showFps, "Show FPS", subText: "Display framerate counter", valueChanged: value => { _showFps = value; }); var switchModel = new SwitchCellModel(true); switchModel.CellTexts.Text = "Debug Colliders"; switchModel.CellTexts.SubText = "Visualize collision boxes"; switchModel.Value = false; switchModel.ValueChanged += isOn => Debug.Log($"Debug Colliders: {isOn}"); AddSwitch(switchModel); yield break; } } ``` -------------------------------- ### AddSwitch Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Adds a toggle switch component to the debug page for boolean settings. ```APIDOC ## AddSwitch ### Description Adds a toggle switch to the debug page. It supports direct value binding or a SwitchCellModel for advanced configuration. ### Method C# Method Call ### Parameters - **initialValue** (bool) - Required - The starting state of the switch. - **text** (string) - Required - The label displayed next to the switch. - **subText** (string) - Optional - Additional descriptive text below the label. - **valueChanged** (Action) - Optional - Callback triggered when the switch state changes. ### Request Example AddSwitch(false, "God Mode", valueChanged: value => Debug.Log(value)); ``` -------------------------------- ### Use Async Methods for Lifecycle Events in Unity Debug Sheet Source: https://github.com/haruma-k/unitydebugsheet/blob/master/README.md This snippet demonstrates how to use asynchronous methods instead of coroutines for defining lifecycle events in Unity Debug Sheet. It requires adding 'UDS_USE_ASYNC_METHODS' to Scripting Define Symbols in Player Settings. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using System.Threading.Tasks; public class SomePage : DefaultDebugPageBase { protected override string Title => "Some Page"; // Using asynchronous methods to define lifecycle events public override async Task Initialize() { await Task.Delay(100); } } ``` -------------------------------- ### Dynamically Update Debug Sheet Cells Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Shows how to update the content of existing cells in the Unity Debug Sheet after they have been created. This involves using CellModel references and calling RefreshData methods. It's useful for displaying live data or responding to user interactions. Dependencies include UnityDebugSheet.Runtime.Core.Scripts and default cell implementations. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.Cells; using System.Collections; public class DynamicUpdatePage : DefaultDebugPageBase { protected override string Title => "Dynamic Updates"; private int _counter; private int _buttonCellIndex; private ButtonCellModel _buttonModel; public override IEnumerator Initialize() { // Create and store the model _buttonModel = new ButtonCellModel(false); _buttonModel.CellTexts.Text = GetButtonText(); _buttonModel.Clicked += OnButtonClicked; // Store the cell index for later updates _buttonCellIndex = AddButton(_buttonModel); yield break; } private void Update() { // Update on key press if (Input.GetKeyDown(KeyCode.Space)) { _counter++; _buttonModel.CellTexts.Text = GetButtonText(); // Refresh only this cell RefreshDataAt(_buttonCellIndex); // Or refresh all cells: RefreshData(); } } private string GetButtonText() => "Click Count: " + _counter; private void OnButtonClicked() => _counter++; } ``` -------------------------------- ### AddInputField Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Adds a text input field to the debug page for user-entered data. ```APIDOC ## AddInputField ### Description Adds a text input field to the debug page. Supports various content types such as standard text, integers, and passwords. ### Method C# Method Call ### Parameters - **text** (string) - Required - The label for the input field. - **placeholder** (string) - Optional - Hint text shown when the field is empty. - **contentType** (InputField.ContentType) - Optional - Defines the type of input (e.g., IntegerNumber, Password). - **valueChanged** (Action) - Optional - Callback triggered when the input text changes. ### Request Example AddInputField("Player Name", placeholder: "Enter name...", valueChanged: text => Debug.Log(text)); ``` -------------------------------- ### Update Cell Contents Dynamically in Unity Debug Sheet Source: https://github.com/haruma-k/unitydebugsheet/blob/master/README.md Demonstrates how to update a button cell's text dynamically by modifying the CellModel and calling RefreshDataAt. This is useful for reflecting state changes in the debug menu. ```csharp using System.Collections; using UnityDebugSheet.Runtime.Core.Scripts; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.Cells; using UnityEngine; public sealed class ExampleDebugPage : DefaultDebugPageBase { private int _buttonCellIndex; private ButtonCellModel _buttonCellModel; private int _counter; protected override string Title => "Example Debug Page"; public override IEnumerator Initialize() { var buttonCellModel = new ButtonCellModel(false); buttonCellModel.CellTexts.Text = GetButtonName(); buttonCellModel.Clicked += () => { Debug.Log("Clicked"); }; _buttonCellIndex = AddButton(buttonCellModel); _buttonCellModel = buttonCellModel; yield break; } private void Update() { if (Input.GetKeyDown(KeyCode.Space)) { _counter++; _buttonCellModel.CellTexts.Text = GetButtonName(); RefreshDataAt(_buttonCellIndex); } } private string GetButtonName() { return $"Example Button {_counter}"; } } ``` -------------------------------- ### Add Search Field for Filtering Content Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Implements a search field for filtering or searching within debug content, particularly useful for pages with a large number of items. Supports basic input handling and model-based configuration. ```csharp using UnityDebugSheet.Runtime.Core.Scripts; using UnityDebugSheet.Runtime.Core.Scripts.DefaultImpl.Cells; public class SearchExamplePage : DefaultDebugPageBase { protected override string Title => "Search Example"; public override IEnumerator Initialize() { // Simple search field AddSearchField( placeholder: "Search items...", valueChanged: query => FilterItems(query), submitted: query => Debug.Log($"Search submitted: {query}")); // Search field using model var searchModel = new SearchFieldCellModel(); searchModel.Placeholder = "Type to filter..."; searchModel.ValueChanged += query => Debug.Log($"Filtering: {query}"); searchModel.Submitted += query => PerformSearch(query); AddSearchField(searchModel); yield break; } private void FilterItems(string query) { /* Filter logic */ } private void PerformSearch(string query) { /* Search logic */ } } ``` -------------------------------- ### AddSlider Source: https://context7.com/haruma-k/unitydebugsheet/llms.txt Adds a slider component to the debug page for adjusting numeric values within a range. ```APIDOC ## AddSlider ### Description Adds a slider to the debug page to control float or integer values. Supports custom ranges, value formatting, and whole number constraints. ### Method C# Method Call ### Parameters - **initialValue** (float) - Required - The starting numeric value. - **min** (float) - Required - The minimum value of the slider. - **max** (float) - Required - The maximum value of the slider. - **text** (string) - Required - The label for the slider. - **showValueText** (bool) - Optional - Whether to display the numeric value. - **wholeNumbers** (bool) - Optional - If true, restricts input to integers. ### Request Example AddSlider(0.5f, 0.0f, 1.0f, "Master Volume", valueChanged: val => AudioListener.volume = val); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.