get variable from another script unity
C#
//Make Health public
public class PlayerScript: MonoBehaviour {
public float Health = 100.0f;
}
//Access it.
public class Accessor : MonoBehaviour {
void Start()
{
GameObject thePlayer = GameObject.Find("ThePlayer");
PlayerScript playerScript = thePlayer.GetComponent<PlayerScript>();
playerScript.Health -= 10.0f;
}
}public class Script1 : MonoBehavior
{
public static int Script1Int;
}
//Another script:
public class Script2 : MonoBehavior
{
public static int Script2Int;
void Start()
{
Script2Int = Script1.Script1Int;
}
}
Also in C#:
- Title
- c sharp int to string
- Category
- C#
- Title
- parsing string to int c#
- Category
- C#
- Title
- how to check if textbox is empty in c#
- Category
- C#
- Title
- c# get enum value from string
- Category
- C#
- Title
- check version of asp.net core
- Category
- C#
- Title
- c# System.Resources.MissingManifestResourceException error
- Category
- C#
- Title
- c# find duplicates in list
- Category
- C#
- Title
- trello
- Category
- C#
- Title
- c# random string
- Category
- C#
- Title
- how to convert string to bool c#
- Category
- C#
- Title
- vb.net drag window without titlebar
- Category
- C#
- Title
- non null array length
- Category
- C#
- Title
- web api startup add imemory cache object
- Category
- C#
- Title
- unity load scene
- Category
- C#
- Title
- c# check if type implements interface
- Category
- C#
- Title
- how to detected WindowCloseEvent in other window wpf
- Category
- C#
- Title
- how get data from json in c#
- Category
- C#
- Title
- first person camera controller unity
- Category
- C#
- Title
- unity create a child object
- Category
- C#
- Title
- string to guid c#
- Category
- C#
- Title
- select a whole row out of a 2d array C#
- Category
- C#
- Title
- how to reload app.config file at runtime in c#
- Category
- C#
- Title
- condition when a animation finishes in unity
- Category
- C#
- Title
- delegate function c#
- Category
- C#
- Title
- binding c#
- Category
- C#
- Title
- c# number suffixes
- Category
- C#
- Title
- move file from one folder to another c#
- Category
- C#
- Title
- c# move with arrow keys
- Category
- C#
- Title
- how to work with ascii in c#
- Category
- C#
- Title
- covert char[] to string C#
- Category
- C#
- Title
- why is c# say ; expected
- Category
- C#
- Title
- c# get every point in a line in matrix
- Category
- C#
- Title
- c# clear console read chache
- Category
- C#
- Title
- ignore fakeiteasy
- Category
- C#
- Title
- c sharp substring
- Category
- C#
- Title
- c# inline if
- Category
- C#
- Title
- how to see if they are aholding down a key unity
- Category
- C#
- Title
- eventos c#
- Category
- C#
- Title
- unity find object by name
- Category
- C#
- Title
- c# public static string
- Category
- C#
- Title
- unity key detection
- Category
- C#
- Title
- how to name GameObject in c#
- Category
- C#
- Title
- math.pow in C# using loop
- Category
- C#
- Title
- c# get directory part of path
- Category
- C#
- Title
- how do i limit the amount of prefabs in unity using c# script
- Category
- C#
- Title
- unity image
- Category
- C#
- Title
- computer
- Category
- C#
- Title
- Unity C# instantiate prefab
- Category
- C#
- Title
- built in methods to order a list c#
- Category
- C#
- Title
- c# reflection create generic type
- Category
- C#
- Title
- unity how to see what scen you are in
- Category
- C#
- Title
- Unity if object doens't exist
- Category
- C#
- Title
- make camera follow character unity 2020
- Category
- C#
- Title
- escape double quotes c#
- Category
- C#
- Title
- how to use more than one condition in ef join
- Category
- C#
- Title
- never lose focus textbox c#
- Category
- C#
- Title
- run async methods within a sync process
- Category
- C#
- Title
- degree to radians c#
- Category
- C#
- Title
- c# check internet connection easy
- Category
- C#
- Title
- freeze position unity c#
- Category
- C#
- Title
- unity connect to firebase
- Category
- C#
- Title
- what is type unity
- Category
- C#
- Title
- how to pass object as test case in nunit c#
- Category
- C#
- Title
- .net core identity get user id
- Category
- C#
- Title
- c sharp create dictionary
- Category
- C#
- Title
- asp.net core mvc not triggering client side validation
- Category
- C#
- Title
- how to find a transform unity
- Category
- C#
- Title
- unity 2d Drag object
- Category
- C#
- Title
- defining vectors in c#
- Category
- C#
- Title
- firefoxoptions setpreference to trust certificates
- Category
- C#
- Title
- get enum value c#
- Category
- C#
- Title
- c# resize bitmap
- Category
- C#
- Title
- unity rotation
- Category
- C#
- Title
- error CS0542
- Category
- C#
- Title
- c# create new object
- Category
- C#
- Title
- what is a protected int c#
- Category
- C#
- Title
- c# contextswitchdeadlock
- Category
- C#
- Title
- unity docs player input
- Category
- C#
- Title
- unity 2d top down movement
- Category
- C#
- Title
- find month number from date C#
- Category
- C#
- Title
- epplus excel vb.net
- Category
- C#
- Title
- Update data in db .net
- Category
- C#
- Title
- what does thismean incsharp public static void Main
- Category
- C#
- Title
- How to get the world position of the edge of an object?
- Category
- C#
- Title
- c# how to run external program with args
- Category
- C#
- Title
- how to get length of okobjectresult c#
- Category
- C#
- Title
- or in unity c#
- Category
- C#
- Title
- asp net mvc 5 return view from another controller
- Category
- C#
- Title
- check distance to gameobject
- Category
- C#
- Title
- c# webrequest cookies
- Category
- C#
- Title
- open link c#
- Category
- C#
- Title
- datetitime contrusctor c#
- Category
- C#
- Title
- how to declare a string c#
- Category
- C#
- Title
- c# arraylist contains
- Category
- C#
- Title
- asp textarea
- Category
- C#
- Title
- c# push numbers to array
- Category
- C#
- Title
- c# rsa example
- Category
- C#
- Title
- unity set sprite transparency
- Category
- C#
- Title
- make a list c#
- Category
- C#
- Title
- unity how to check object position
- Category
- C#