Hey all, fairly new to Unity development. I am working on a game with increasing score requirements each level to advance on. I have this script controlling score
public Text scoreText;
public int score;
public void Start()
{
score = 0;
UpdateScore();
}
public void AddScore (int newScoreValue)
{
score += newScoreValue;
UpdateScore();
if(score >= 7)
{
SceneManager.LoadScene(4);
}
}
void UpdateScore()
{
scoreText.text = "Items Placed: " + score + "/7";
}
This is linked with an item dropping script that adds a point when you interact with the correct items in the scene. It is attached to the empty game manager object and when the item drop script asks for a score controller in the editor, the manager object is placed in said slot.
The issue is, I’m not sure how to make a single script to handle multiple different level’s scores so I recreated the same 2 scripts for the second level and changed the int value and corresponding scene to move to afterwards, however, when this score script is added to the manager in the new scene it won’t let me slot it into the item drop script in the editor. I am totally baffled and any help would be appreciated. Here is the code in the item drop script if it helps, but it may not out of context.
public Item dropItem;
public GameObject placeHolderObject;
public int scoreValue = 1;
public ScoreController scoreController;
public override void Interact()
{
base.Interact();
Item itemToDrop = Inventory.instance.Remove(dropItem);
if (itemToDrop != null)
{
Instantiate(itemToDrop.itemObject, placeHolderObject.transform.position, placeHolderObject.transform.rotation);
placeHolderObject.SetActive(false);
hasInteracted = true;
scoreController.AddScore(scoreValue);
}
else
{
Debug.Log("You no have item click click click");
hasInteracted = false;
}
}