diff --git a/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs b/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs index 2f7ef01..09b87da 100644 --- a/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs +++ b/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs @@ -97,8 +97,11 @@ return _cellPool.Pop(); } - var cell = Activator.CreateInstance(_cellType); - var uiCell = (UiCell)cell; + var uiCell = Activator.CreateInstance(_cellType) as UiCell; + if (uiCell is null) + { + throw new Exception($"cellType 无法转为'{typeof(UiCell).FullName}'类型!"); + } uiCell.CellNode = _template.Clone(); uiCell.Grid = this; uiCell.OnInit();