Hello, out there.
Help needed.
I have a variable in some script:
public GameObject firstKeyPrefab = null;
I would like to add reference to prefab to this variable.
If I do it thru inspector by grag-and-drop prefab from Asset folder evrething are correct.
But if I do it thru:
Object obj = Resources.Load("Key3");
firstKeyPrefab = obj;
I have an error.
Assets\Scripts\SceneInitials.cs(50,22): error CS0266: Cannot implicitly convert type ‘UnityEngine.Object’ to ‘UnityEngine.GameObject’. An explicit conversion exists (are you missing a cast?)
Can you advise me how to convert refference to prefab from “Object” type to “GameObject” one or directly get refference to prefab as GameObject type, please?