Search Unity

Don't Destroy script

Discussion in 'Editor & General Support' started by Vorian9223, Aug 15, 2019.

  1. Vorian9223

    Vorian9223

    Joined:
    Aug 15, 2019
    Posts:
    1
    Hi. I want to make a script that will store all boolean variables that indicate whether or not the player took an item in the scenario. This script cannot be destroyed at any time during the game. Am I required to put it in a game object? (google translator)
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You can use static variables if you don't want to use a MonoBehaviour.

    Code (csharp):
    1. public class WhateverClass
    2. {
    3.     public static bool WhateverBool;
    4. }
     
    Vryken likes this.