Reference ID not found and KeyNotFoundException
Posted: Fri Nov 04, 2022 12:47 pm
Hello,
I hope someone can help me understand what I'm doing wrong.
I have two scenes, in scene1, I define the default team name and logo - or, if the game has been run before, load the working team name and logo; then with a button click the user can switch to the a "work" scene (there are many such work scenes).
At the "OptionsMenu" scene, the current team name and logo are reloaded/updated as follows:
But Ii get the following warning and error:
Thank you, in advance, for your time.
I hope someone can help me understand what I'm doing wrong.
I have two scenes, in scene1, I define the default team name and logo - or, if the game has been run before, load the working team name and logo; then with a button click the user can switch to the a "work" scene (there are many such work scenes).
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using TMPro;
public class LoadDefaults : MonoBehaviour
{
//gain access to team name and logo on scene
//gain access to basic gameObjects
public GameObject currentTeamName;
public GameObject currentTeamLogo;
//define and get access to the string of currentTeam
public string DefaultTeamName = "Erie Frostline";
void Start()
{
//gain access to text component of TMP
TextMeshProUGUI currentTeamName_UI = currentTeamName.GetComponent<TextMeshProUGUI>();
if (ES3.KeyExists("activeTeam"))
{
//REassign the logo and collect teamName
ES3.LoadInto<GameObject>("activeTeamLogo", currentTeamLogo);
DefaultTeamName = ES3.Load<string>("activeTeamName");
}
//assign the teamName (whether stored or just assigned, the name and logo are the same)
currentTeamName_UI.text = DefaultTeamName;
//Note: at this point, currentTeamName_UI.text contains the teamName being worked on
//and currentTeamLogo contains its logo
//these should be saved in a scriptableobjects or ES3 file for later use
ES3.Save<string>("actvieTeamName", currentTeamName_UI.text);
ES3.Save<GameObject>("activeTeamLogo", currentTeamLogo);
public void OnBClick()
{
SceneManager.LoadScene("OptionsMenu");
}
}
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using TMPro;
public class teamHQ : MonoBehaviour
{
public GameObject CurrentTeamLogo;
public GameObject CurrentTeamName;
void Start()
{
ES3.LoadInto<GameObject>("activeTeamLogo", CurrentTeamLogo);
TextMeshProUGUI CurrentTeamName_UI = CurrentTeamName.GetComponent<TextMeshProUGUI>();
ES3.LoadInto<string>("activeTeamName", CurrentTeamName_UI.text);
}
Thank you, in advance, for your time.