So I am trying to spawn a text thats a prefab like so, and for whatever reason it gives me ‘The object you want to insitantiate is null’ however I have triple checked that they are all named the exact same, and the prefab is named the exact same… Any ideas?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FloatingTextController : MonoBehaviour {
private static FloatingText popupText;
private static GameObject canvas;
public static void Initialize()
{
canvas = GameObject.Find("Canvas");
popupText = Resources.Load<FloatingText>("Prefabs/PopupTextParent");
}
public static void CreateFloatingText(string text, Transform location)
{
FloatingText instance = Instantiate(popupText);
instance.transform.SetParent(canvas.transform, false);
instance.SetText(text);
}
}