codeAPI Reference
s&box IInspectorEditor: Custom inspector panels
IInspectorEditor Interface API Reference
IInspectorEditor is an interface for custom inspector panels that can edit selected GameObjects in the s&box editor. Panels implementing this interface are registered with InspectorEditorAttribute.
Type Signature
CSHARP
namespace Sandbox;
public interface IInspectorEditor
{
public bool TrySetTarget(List<GameObject> selection);
public string Title { get; }
}Methods
TrySetTarget(List<GameObject> selection)
Attempts to set the current selection as the target for editing. Returns true if the editor can handle this selection, false otherwise.Properties
- string Title { get; } - The display title for this inspector editor.
Usage
CSHARP
[InspectorEditor(typeof(MyComponent))]
public class MyComponentEditor : Panel, IInspectorEditor
{
public string Title => "My Component Editor";
public bool TrySetTarget(List<GameObject> selection)
{
// Check if selection contains objects with MyComponent
if (selection.Count == 0) return false;
if (!selection.All(go => go.Components.Has<MyComponent>())) return false;
// Set up editor for this selection
UpdateUI(selection);
return true;
}
private void UpdateUI(List<GameObject> selection)
{
// Update UI based on selection
}
}Notes
- Used by the inspector system to provide custom editors for specific component types
- InspectorEditorAttribute registers the panel with the inspector
- TrySetTarget is called when the selection changes
- Return false if the editor cannot handle the current selection
- The panel must inherit from Panel to be usable in the UI system
Was this helpful?