fixed nullable object warning

This commit is contained in:
Timerix 2025-04-29 01:33:26 +05:00
parent 1940d01d9b
commit 72f47c297e

View File

@ -65,7 +65,8 @@ public class GameObject
if(Components.ContainsKey(t))
return false;
Component component = (Component)Activator.CreateInstance(t, this);
Component component = (Component?)Activator.CreateInstance(t, this)
?? throw new Exception($"can't create instance of class {t.FullName}");
Components.Add(t, component);
return true;
}