I am trying to instantiate a prefab based off position and rotation values saved to firebase, but for some reason the prefab is not instantiating even though I am able to retrieve the values from firebase.
Here is my method, it is attached to a button that is supposed to load in all the prefabs onclick
I tried Resource.Load(), The prefab is active, I also have the prefab attached to the game object with the script attached to it.
The values in the Vector3 and Quaternion are also correct since they debug properly.
Also there are no errors when I load the game.
public void GetTrees()
{
FirebaseDatabase dbInstance = FirebaseDatabase.DefaultInstance;
dbInstance.GetReference("Player").Child(scenarioName).GetValueAsync().ContinueWith(treeData =>
{
if (treeData.IsFaulted)
{
Debug.LogError("Error");
}
if (treeData.IsCompleted)
{
DataSnapshot snapshot = treeData.Result;
foreach (DataSnapshot tree in snapshot.Children)
{
IDictionary loadTreeDictionary = (IDictionary)tree.Value;
//Debug.Log(loadTreeDictionary.Values.Count); //returns 7 meaning all the data is in here..
xPos = float.Parse(loadTreeDictionary["xPos"].ToString());
yPos = float.Parse(loadTreeDictionary["yPos"].ToString());
zPos = float.Parse(loadTreeDictionary["zPos"].ToString());
xRot = float.Parse(loadTreeDictionary["xRot"].ToString());
yRot = float.Parse(loadTreeDictionary["yRot"].ToString());
zRot = float.Parse(loadTreeDictionary["zRot"].ToString());
wRot = float.Parse(loadTreeDictionary["wRot"].ToString());
Vector3 loadTreePosition = new Vector3(xPos, yPos, zPos);
Quaternion loadTreeRotation = new Quaternion(xRot, yRot, zRot, wRot);
//Debug.Log(prefab.name); //it does not even debug the prefab name
//Debug.Log("Tree Positons " + loadTreePosition);
//Debug.Log("Tree Rotations " + loadTreeRotation);
Instantiate(prefab, loadTreePosition, loadTreeRotation);
}
}
});
}