Background: I trying to make multidimensional scoring system for a live robotics competition.
Each team’s competes on a track with multiple challenges, across 5 rounds.
The referee scores the robots progress on a device this this application, pressing respective button to allocate each tasks score, which vary reach round.
Each round produces 4 values for each team’s score: Gross Score, Touches, Time & Net Score.
This part of the scoring system is working perfectly and is producing the data I want and is accessible in other scripts.
I have created a Scriptable Object to collate all this data in to the one place, so (potentially) to push it to a leaderboard table.
The Scriptable Object has built the way I want it to look like (whether this is the correct way forward, I don’t know)
The Scriptable Object, has 3 levels of data.
3 string variables for storing basic ‘current’ round data as I switch between scenes (scoring pages) and to interact with the main menu page.
There is then the ‘Team Data’ a list with data and a second list inside with each round data.
Team Data x number of team in the competition.
With 6 round lists containing the above round data achieved for each round. (as above).
I can access and manipulate the string data in the Scriptable Object, and from other scripts.
But, with sheer frustration, I can’t work out how to access and manipulate the data in the list(s).
I mainly want to do this from my ‘MenuManager’ Script. But also need to get the game data from the round scripts and pass them to the leaderboard table script.
This is the C# Script for the Scriptable Object
[CreateAssetMenu]
public class CurrentGameData : ScriptableObject
{
public string currentCategory;
public string currentRound;
[System.Serializable]
public class TeamDataContainer
{
public string TeamName;
public int TeamID;
public string TeamSchool;
public string TeamCatID;
public GameObject tableTeamLine;
public List<RoundDataContainer> roundDataContainer = new();
}
[System.Serializable]
public class RoundDataContainer
{
public string RoundID;
public int GrossScore;
public int Touches;
public int Time;
public int NetScore;
}
[SerializeField]
public List<TeamDataContainer> teamRoundData = new();
}
The Scriptable Object Layout
The 'MenuManager' That is tring to interact with the contect
public class MenuManager : MonoBehaviour
{
public GameObject categoryDropdownGO;
public GameObject primaryDropdownGO;
public GameObject secondaryDropdownGO;
public GameObject openDropDownGO;
[SerializeField]
private CurrentGameData currentCategory;
[SerializeField]
private CurrentGameData currentRound;
[SerializeField]
private CurrentGameData currentGameData;
//public TextMeshProUGUI[] teamCat; // this works, but it would mean adding every text object from every team!!!!!
// Start is called before the first frame update
void Awake()
{
var catDD = categoryDropdownGO.GetComponent<TMP_Dropdown>();
var rndDD = categoryDropdownGO.GetComponent<TMP_Dropdown>();
Debug.Log(currentGameData.teamRoundData[1].TeamName); // This isn't working
if (currentCategory.currentCategory == "primary")
{
CategoryMenuSwitch(1);
catDD.value = 1;
catDD.RefreshShownValue();
}
the //comment line is one of my may attempts to access the data.
Each 'TableTeamLine' Gameobject in the menu Scene and associated with the Scriptable Object has the script to be able to present the Team Data.
public class TeamTableData : MonoBehaviour
{
public TextMeshProUGUI teamIDText;
public TextMeshProUGUI teamNameText;
public TextMeshProUGUI teamSchoolText;
public TextMeshProUGUI teamCatText;
public TextMeshProUGUI roundIDText;
public TextMeshProUGUI grossScoreText;
public TextMeshProUGUI touchText;
public TextMeshProUGUI grossTimeText;
public TextMeshProUGUI netScoreText;
}