Disable Studio Add for record types the model cannot create
The window lost its disabled state when record creation moved into the model: Add and Create were enabled for abstract types and threw on click, and CreateElement(type, type) on an abstract [Union] type threw "X is not a choice for X". CultInspectorModel.CanCreate is now the one rule CreateDefault and the window both read, a slot's own type is always a choice, and an abstract one returns the "abstract or no parameterless constructor" notice. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
bddec0fe4d
commit
baa8de0baf
3 changed files with 20 additions and 10 deletions
|
|
@ -138,9 +138,10 @@ namespace GameCult.Unity.Caching.Editor
|
|||
{
|
||||
var descriptor = _selectedType == null ? null : _cache.Registry.GetRequired(_selectedType);
|
||||
var selected = Selected();
|
||||
var cannotAdd = descriptor == null || ReadOnly || !_model.CanCreate(_selectedType);
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
using (new EditorGUI.DisabledScope(descriptor == null || descriptor.IsGlobal || ReadOnly))
|
||||
using (new EditorGUI.DisabledScope(cannotAdd || descriptor.IsGlobal))
|
||||
{
|
||||
if (GUILayout.Button("Add", EditorStyles.miniButtonLeft)) Add();
|
||||
}
|
||||
|
|
@ -169,7 +170,7 @@ namespace GameCult.Unity.Caching.Editor
|
|||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.LabelField("Global is absent.");
|
||||
using (new EditorGUI.DisabledScope(ReadOnly))
|
||||
using (new EditorGUI.DisabledScope(cannotAdd))
|
||||
{
|
||||
if (GUILayout.Button("Create", GUILayout.Width(56))) Add();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue