Hi,
when trying to replace the javascript from the book “Game Development with Unity” by C# script,
the generic version works well to get the component (the script), but the non-generic version doesn’t work. (get null)
So can anyone explain the difference between them?
The generic version is
Widget_Inventory widgetInventory = (Widget_Inventory)collider.GetComponent<Widget_Inventory>();
The non-generic version is
Widget_Inventory widgetInventory = (Widget_Inventory )collider.GetComponent(“Widget_Inventory”);
Widget_Inventory is a Widget_Inventory .cs script attached on Widget gameObject.
Please let me know if my question or data is unclear.
Thanks