reference to gameobject in different scene unity
C#
public Canvas menu;
// Start is called before the first frame update
void Start()
{
//not in OnEnabled since we want these methods to be called on startup
SceneManager.sceneLoaded += OnSceneLoaded;
SceneManager.sceneUnloaded += OnSceneUnloaded;
}
void OnDestroy()
{
//not in OnDisabled since we want these methods to be removed only when destroyed, not switched out of
SceneManager.sceneLoaded -= OnSceneLoaded;
SceneManager.sceneUnloaded -= OnSceneUnloaded;
}
//when a scene is loaded, make this canvas invisible
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
menu.gameObject.SetActive(false);
}
//when a scene is unloaded, make this canvas visible again
void OnSceneUnloaded(Scene current)
{
menu.gameObject.SetActive(true);
}//the truth is, you shouldn't. its better to just add delegates to
//SceneManager.sceneLoaded and SceneManager.sceneUnloaded
//if you really need to,
FindObjectOfType<Canvas>();
//searches across all additively loaded scenes
Also in C#:
- Title
- unity3d quaternion add 90 degrees
- Category
- C#
- Title
- how to get component in unity c#
- Category
- C#
- Title
- asp.net core redirecttoaction with parameters
- Category
- C#
- Title
- blazor wasm routable page in separate project
- Category
- C#
- Title
- unity how to get y value
- Category
- C#
- Title
- c# listview
- Category
- C#
- Title
- c# join array
- Category
- C#
- Title
- Request.ServerVariables["HTTP_X_FORWARDED_FOR"] get only one ipaddress
- Category
- C#
- Title
- c# get date without time
- Category
- C#
- Title
- c# Sleep
- Category
- C#
- Title
- what is the and in c#
- Category
- C#
- Title
- split on uppercase c#
- Category
- C#
- Title
- how to clear console through script unity
- Category
- C#
- Title
- c# append to file
- Category
- C#
- Title
- c# filter non alphanumeric characters
- Category
- C#
- Title
- c# AllowSynchronousIO to true
- Category
- C#
- Title
- font family behind code uwp c#
- Category
- C#
- Title
- c# append array
- Category
- C#
- Title
- list.addrange in c#
- Category
- C#
- Title
- toggle unity c#
- Category
- C#
- Title
- c# arraylist
- Category
- C#
- Title
- c# get all class properties
- Category
- C#
- Title
- max of array C#
- Category
- C#
- Title
- c# try catch error
- Category
- C#
- Title
- object escape player unity
- Category
- C#
- Title
- linq c# object except two lists
- Category
- C#
- Title
- c# web form compare dates
- Category
- C#
- Title
- c# initialize dictionary
- Category
- C#
- Title
- unity c# foreach
- Category
- C#
- Title
- C# sprint key
- Category
- C#
- Title
- c# round number
- Category
- C#
- Title
- waitforseconds unity
- Category
- C#
- Title
- unity 3d mouse look script
- Category
- C#
- Title
- c# string methods
- Category
- C#
- Title
- convert string to number C#
- Category
- C#
- Title
- c# convert excel column index to letter
- Category
- C#
- Title
- How to execute script in C#
- Category
- C#
- Title
- unity to integer
- Category
- C#
- Title
- vector3.lerp
- Category
- C#
- Title
- unity round
- Category
- C#
- Title
- json stringify c#
- Category
- C#
- Title
- c# dynamic object get value
- Category
- C#
- Title
- moq raise event
- Category
- C#
- Title
- c# substring from index to end
- Category
- C#
- Title
- what is a return statement C#
- Category
- C#
- Title
- string.charat c#
- Category
- C#
- Title
- c# events and delegates
- Category
- C#
- Title
- jumping with character controller unity
- Category
- C#
- Title
- run async method parallel c#
- Category
- C#
- Title
- how to put double quotes in a string c#
- Category
- C#
- Title
- how to make a game
- Category
- C#
- Title
- check if two timespans intersect c#
- Category
- C#
- Title
- vector between two points unity
- Category
- C#
- Title
- C# copy string except for last letter
- Category
- C#
- Title
- c sharp tryparse
- Category
- C#
- Title
- c# empty array
- Category
- C#
- Title
- c# implement a superclass in subclass
- Category
- C#
- Title
- unity get velocity of gameobject
- Category
- C#
- Title
- HashSet C# append
- Category
- C#
- Title
- disable button in android studio
- Category
- C#
- Title
- switch case c# range
- Category
- C#
- Title
- how to hide and show object in unity script
- Category
- C#
- Title
- unity rotate vector
- Category
- C#
- Title
- MVC company assignments
- Category
- C#
- Title
- mysql C# select pk and all columns datareader
- Category
- C#
- Title
- unity set text value
- Category
- C#
- Title
- how to reference scripts in other scenes unity
- Category
- C#
- Title
- check connection c#
- Category
- C#
- Title
- lazy loading c#
- Category
- C#
- Title
- unity detect number key
- Category
- C#
- Title
- c# to binary
- Category
- C#
- Title
- unity reset scene
- Category
- C#
- Title
- repeat 10 timesw c#
- Category
- C#
- Title
- unity access child
- Category
- C#
- Title
- get normal from 3 points
- Category
- C#
- Title
- c# warning CS0108
- Category
- C#
- Title
- c# change cursor
- Category
- C#
- Title
- Category
- C#
- Title
- download file from url asp net web api c#
- Category
- C#
- Title
- getcomponent c#
- Category
- C#
- Title
- what type of variable is true or false in c#
- Category
- C#
- Title
- appsettings in console application c#
- Category
- C#
- Title
- edit form item from class C#
- Category
- C#
- Title
- unity create a child object
- Category
- C#
- Title
- how to update modal class using dbfirst in asp.net core
- Category
- C#
- Title
- unity method on scene loaded
- Category
- C#
- Title
- format phone number in c# .net
- Category
- C#
- Title
- unity movetowards 2d
- Category
- C#
- Title
- c# using get set methods
- Category
- C#
- Title
- serilog loglevel order
- Category
- C#
- Title
- unity ui not seen
- Category
- C#
- Title
- no overload for 'useItemOnSceneLoad' matches delegate 'UnityAction<Scene, LoadSceneMode>'
- Category
- C#
- Title
- how to close a form c#
- Category
- C#
- Title
- c# escape characters
- Category
- C#
- Title
- datetitime contrusctor c#
- Category
- C#
- Title
- unity hide mouse
- Category
- C#
- Title
- c# httpclient postasync stringcontent
- Category
- C#
- Title
- c sharp comments
- Category
- C#
- Title
- unity how to end a game with esc
- Category
- C#
- Title
- BCrypt c#
- Category
- C#