unity variable from another script
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;
}
}
Also in C#:
- Title
- convert string array to int C#
- Category
- C#
- Title
- how to move towards an object unity
- Category
- C#
- Title
- unity get data from firebase
- Category
- C#
- Title
- how to turn 3 floats into quartenion
- Category
- C#
- Title
- fahrenheit to celsius c#
- Category
- C#
- Title
- vb.net check if datatable has rows
- Category
- C#
- Title
- iterate through dictionary c#
- Category
- C#
- Title
- find gameobject with tag
- Category
- C#
- Title
- unity how to change rotation
- Category
- C#
- Title
- asp.net core task iactionresult
- Category
- C#
- Title
- unity ui not seen
- Category
- C#
- Title
- unity vector3 smoothdamp not reaching target
- Category
- C#
- Title
- get enum by index c#
- Category
- C#
- Title
- error CS0542
- Category
- C#
- Title
- move file from one folder to another c#
- Category
- C#
- Title
- IEnumerator
- Category
- C#
- Title
- drag object unity 2d
- Category
- C#
- Title
- c# read all lines from filestream
- Category
- C#
- Title
- c# keyvaluepair
- Category
- C#
- Title
- c# replace string case insensitive
- Category
- C#
- Title
- C# Unknown column 'FundAllocation' in 'field list
- Category
- C#
- Title
- iformfile blobclient
- Category
- C#
- Title
- c# input
- Category
- C#
- Title
- multidimensional meaning
- Category
- C#
- Title
- unity how to load up a scene
- Category
- C#
- Title
- c# getter setter
- Category
- C#
- Title
- c# loop
- Category
- C#
- Title
- input get button uibutton
- Category
- C#
- Title
- how to stop player rotating when hit by object
- Category
- C#
- Title
- unity how to make a ui disappear
- Category
- C#
- Title
- unity docs player input
- Category
- C#
- Title
- c# list append
- Category
- C#
- Title
- linq in c#
- Category
- C#
- Title
- dynamic group by expression C#
- Category
- C#
- Title
- Unity if object doens't exist
- Category
- C#
- Title
- .net core download image from url binary file
- Category
- C#
- Title
- c# check if string is all numbers
- Category
- C#
- Title
- get web config key value in c# razor view
- Category
- C#
- Title
- unity transfoprm position y change
- Category
- C#
- Title
- displayname c#
- Category
- C#
- Title
- file picker uwp c#
- Category
- C#
- Title
- cannot convert string to generic type c#
- Category
- C#
- Title
- how to make if statement c#
- Category
- C#
- Title
- c# console delay
- Category
- C#
- Title
- clear combobox c#
- Category
- C#
- Title
- select a whole row out of a 2d array C#
- Category
- C#
- Title
- variables
- Category
- C#
- Title
- unity making homing rocket
- Category
- C#
- Title
- unity calculate path
- Category
- C#
- Title
- microsoft input tool need .net framework
- Category
- C#
- Title
- cursorlockmode cannot be used as a method C#
- Category
- C#
- Title
- unknown discriminator value mongodb
- Category
- C#
- Title
- csharp datetime string format
- Category
- C#
- Title
- how to check if a value is inside an array c#
- Category
- C#
- Title
- decimals not stored in azure tables
- Category
- C#
- Title
- c# public static string
- Category
- C#
- Title
- c# clear console read chache
- Category
- C#
- Title
- c# loop through repeater items
- Category
- C#
- Title
- declare string array c# without size
- Category
- C#
- Title
- check which activity in focus in android
- Category
- C#
- Title
- c# mathf.ceiling
- Category
- C#
- Title
- c# list to string
- Category
- C#
- Title
- mvc input type file
- Category
- C#
- Title
- itext7 pdfwriter outputstream c#
- Category
- C#
- Title
- c# reverse list
- Category
- C#
- Title
- string to enum c#
- Category
- C#
- Title
- cc# sort list with list if ids
- Category
- C#
- Title
- public enum c#
- Category
- C#
- Title
- how to switch scenes unity
- Category
- C#
- Title
- c# httpclient azure function authorization
- Category
- C#
- Title
- traversing an enum c#
- Category
- C#
- Title
- unity list length
- Category
- C#
- Title
- parsing object from text file c#
- Category
- C#
- Title
- if get key down unity
- Category
- C#
- Title
- how to reference scripts in other scenes unity
- Category
- C#
- Title
- C# loop through array of objet
- Category
- C#
- Title
- page parent wpf
- Category
- C#
- Title
- how to create and trigger a function unity animation events
- Category
- C#
- Title
- c# how to exit program
- Category
- C#
- Title
- c list add element
- Category
- C#
- Title
- if a method doesnt rutern a value, what shouyld i reeturn c#
- Category
- C#
- Title
- bold caption latex
- Category
- C#
- Title
- comments unity c#
- Category
- C#
- Title
- grab reference from method parameter c#
- Category
- C#
- Title
- c# string contains space
- Category
- C#
- Title
- c# skip following code in loop
- Category
- C#
- Title
- c# to vb.net
- Category
- C#
- Title
- how to access first child of parent unity
- Category
- C#
- Title
- how to reference function in unity
- Category
- C#
- Title
- c# bitmap to Image
- Category
- C#
- Title
- winforms messagebox with button
- Category
- C#
- Title
- loop gridcontrol devexpress c#
- Category
- C#
- Title
- c# enum.getvalues
- Category
- C#
- Title
- loop through string array c#
- Category
- C#
- Title
- block wapalyzer from detecting codeigniter
- Category
- C#
- Title
- get number of sundays in a month c#
- Category
- C#
- Title
- c# map
- Category
- C#
- Title
- c# distinct comparer multiple properties
- Category
- C#
- Title
- C# get object property name
- Category
- C#
- Title
- copy a list in c# unity
- Category
- C#