unity switch to scene and transfer data
C#
using UnityEngine;
/// <summary>Manages data for persistance between levels.</summary>
public class DataManager : MonoBehaviour
{
/// <summary>Static reference to the instance of our DataManager</summary>
public static DataManager instance;
/// <summary>The player's current score.</summary>
public int score;
/// <summary>The player's remaining health.</summary>
public int health;
/// <summary>The player's remaining lives.</summary>
public int lives;
/// <summary>Awake is called when the script instance is being loaded.</summary>
void Awake()
{
// If the instance reference has not been set, yet,
if (instance == null)
{
// Set this instance as the instance reference.
instance = this;
}
else if(instance != this)
{
// If the instance reference has already been set, and this is not the
// the instance reference, destroy this game object.
Destroy(gameObject);
}
// Do not destroy this object, when we load a new scene.
DontDestroyOnLoad(gameObject);
}
}
Also in C#:
- Title
- unity switch to scene and transfer data
- Category
- C#
- Title
- get hash c#
- Category
- C#
- Title
- asp.net c# set session timeout
- Category
- C#
- Title
- math class C# exponents
- Category
- C#
- Title
- c# directories loop
- Category
- C#
- Title
- asp.net tag helper checkbox
- Category
- C#
- Title
- isdaylightsavingtime in c#
- Category
- C#
- Title
- degree to radians c#
- Category
- C#
- Title
- c# return two variables of different types
- Category
- C#
- Title
- call a function c#
- Category
- C#
- Title
- array syntax c#
- Category
- C#
- Title
- json serialize object capitalization config
- Category
- C#
- Title
- get set c#
- Category
- C#
- Title
- disable a component unity
- Category
- C#
- Title
- c# pull request
- Category
- C#
- Title
- unity variable from another script
- Category
- C#
- Title
- unity how to move an object to another object
- Category
- C#
- Title
- how to stop player rotating when hit by object
- Category
- C#
- Title
- assign datasource to dropdownlist in c#
- Category
- C#
- Title
- socket in c#
- Category
- C#
- Title
- eager loading c#
- Category
- C#
- Title
- c# anonymous class
- Category
- C#
- Title
- c# making a folder
- Category
- C#
- Title
- C# for
- Category
- C#
- Title
- asp net mvc 5 return view from another controller
- Category
- C#
- Title
- unity hide mouse first person
- Category
- C#
- Title
- divide string in chunks c#
- Category
- C#
- Title
- asking for user input integer c#
- Category
- C#
- Title
- unity gameobject.find
- Category
- C#
- Title
- c# make request to rest api
- Category
- C#
- Title
- get last element of array c#
- Category
- C#
- Title
- c# inline if
- Category
- C#
- Title
- call Textboxfor in cs
- Category
- C#
- Title
- itext7 pdfwriter outputstream c#
- Category
- C#
- Title
- trello
- Category
- C#
- Title
- .net directorysearcher get manager accountname
- Category
- C#
- Title
- Instantiate c#
- Category
- C#
- Title
- 5 second timer in c#
- Category
- C#
- Title
- dynamic group by expression C#
- Category
- C#
- Title
- c sharp substring
- Category
- C#
- Title
- unity c# public all codes
- Category
- C#
- Title
- list clone - C#
- Category
- C#
- Title
- c# ^ operator
- Category
- C#
- Title
- C# invoke
- Category
- C#
- Title
- Unity if object doens't exist
- Category
- C#
- Title
- c# instantiate
- Category
- C#
- Title
- unity list length
- Category
- C#
- Title
- c# remove spaces from string
- Category
- C#
- Title
- copy a list C#
- Category
- C#
- Title
- c# zip a file
- Category
- C#
- Title
- parsing string to int c#
- Category
- C#
- Title
- computer
- Category
- C#
- Title
- xamarin forms alarm
- Category
- C#
- Title
- how to check if a value is inside an array c#
- Category
- C#
- Title
- show double in textbox c#
- Category
- C#
- Title
- unity how to tell when a gameobject is colliding
- Category
- C#
- Title
- c# char array to string
- Category
- C#
- Title
- beard styles without mustache Intitle:work with me
- Category
- C#
- Title
- c# find process by name
- Category
- C#
- Title
- read xml file c#
- Category
- C#
- Title
- open zip file in c#
- Category
- C#
- Title
- how to sort string array alphabetically in c#
- Category
- C#
- Title
- reverse a string in c#
- Category
- C#
- Title
- devexpress objectspace to session
- Category
- C#
- Title
- uwp roaming data sample
- Category
- C#
- Title
- nullreferenceexception c#
- Category
- C#
- Title
- c# how to run external program
- Category
- C#
- Title
- how to delay something in c# unity
- Category
- C#
- Title
- what data type should be for contact number in asp.net
- Category
- C#
- Title
- unity movetowards 2d
- Category
- C#
- Title
- make string
- Category
- C#
- Title
- exit game unity
- Category
- C#
- Title
- asp.netcore: develop on win10 run on ubuntu
- Category
- C#
- Title
- what is the and in c#
- Category
- C#
- Title
- unity rotate around point
- Category
- C#
- Title
- c# making a folder wpf
- Category
- C#
- Title
- c# odd even median
- Category
- C#
- Title
- arry in c#
- Category
- C#
- Title
- wpf binding object get value
- Category
- C#
- Title
- how consider the first caracter in Split c#
- Category
- C#
- Title
- unity mobile controls
- Category
- C#
- Title
- or in unity c#
- Category
- C#
- Title
- cannot apply indexing with to an expression of type 'object'
- Category
- C#
- Title
- how to add a componet to a gameobject throgh code unity
- Category
- C#
- Title
- unity up arrow input
- Category
- C#
- Title
- c# select first value from list
- Category
- C#
- Title
- automapper c# initialize error
- Category
- C#
- Title
- unity key detection
- Category
- C#
- Title
- month number to text in c#
- Category
- C#
- Title
- when do i need to end a sentence with ; in c#
- Category
- C#
- Title
- unity how to change text in script
- Category
- C#
- Title
- query associative table ef6
- Category
- C#
- Title
- reload current scene unity
- Category
- C#
- Title
- visual studio clear text script
- Category
- C#
- Title
- how to close a windows form application in c#
- Category
- C#
- Title
- bulk update in c# using jquery datatble
- Category
- C#
- Title
- wpf restart application c#
- Category
- C#
- Title
- c# convert dictionary to anonymous object
- Category
- C#
- Title
- Unity C# add slider into editor
- Category
- C#
- Title
- convert number of days into months c#
- Category
- C#