Hey all, I’m using PrefabUtility to store and pull player GameObjects from my resources and have been having some issues when building the game because of it. Here’s the code I’ve written:
using Unity.VisualScripting;
using UnityEditor;
using UnityEngine;
public class RunDataManager : MonoBehaviour
{
public static void SaveDataFromLevel()
{
PrefabUtility.SaveAsPrefabAsset(GameObject.FindGameObjectWithTag("Player"), "Assets/Resources/RunData/PlayerObject.prefab");
PrefabUtility.SaveAsPrefabAsset(GameObject.FindGameObjectWithTag("DroneHolder"), "Assets/Resources/RunData/DroneHolderObject.prefab");
}
public static void LoadData(out GameObject playerObject, out GameObject droneHolder, out RunData runData)
{
playerObject = (GameObject)Resources.Load("RunData/PlayerObject");
droneHolder = (GameObject)Resources.Load("RunData/DroneHolderObject");
runData = Resources.Load("RunData/RunData").GetComponent<RunData>();
}
}
And here’s an image of the errors I’m getting when I build the game:
The game launches and the editor perfectly fine, and works exactly how I want it to. This error only pops up when building. Any thoughts on how this could be fixed? I tried searching but couldn’t find an exact solution.
Thank you!