GameData

using UnityEngine;
using System.Collections.Generic;

public class GameData : MonoBehaviour
{
  public Texture2D beginStateSplash;
  public Texture2D lostStateSplash;
  public Texture2D wonStateSplash;
  
  public List<GameObject> cameras;
  
  private int playerLivesSelected = 2;
  private int sceneBeginningScore;
  
  [HideInInspector]
  public int playerLives;
  [HideInInspector]
  public int score;
    
  void Start ()
  {
    playerLives = playerLivesSelected;
  }
  
  public void ResetPlayer()
  {
    playerLives = playerLivesSelected;
    score = sceneBeginningScore;
  }
  
  public void SetPlayerLives(int livesSelected)
  {
    playerLivesSelected = livesSelected;
    playerLives = livesSelected;
  }
  
  public void SetScore()
  {
    sceneBeginningScore = score;
  }
}

Get Learning C# by Developing Games with Unity 3D Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.