Hello, Is it possible to access a variable and change it if it’s part of a C# script and Im using Unityscript.
For example. This is the c# script :
public string stringy = “Stringy string”;
That’s stored in scriptyscript.cs
Can I access it from an unityscript ?
var varyvar : scriptyscript;
function Start ()
varyvar = GameObject.Find("Player").GetComponent(ScriptScript);
varyvar.stringy = "Yey, it works"
This is the unityscript.js file. It’s just an example ,sorry if I wasn’t clear enough.
Yes. Check out the docs here.
Note that while it can be done, most people on UA generally recommend against it. Ultimately its a pain to do. Tends to be easier if all scripts are in the same language.
i really dont understand what you are trying there. u can code in js, c# and boo with unity. doesnt matter. So basically u can make one script out of them when u change the unityscript file to cs.
Edit: If you really want to keep the two scripts seperate, I can give you an example how it will work in c# but no clue how it is in js.
Attach the script with the string to a gameobject. Now in your unityscript reference to this script by calling
ScriptyScript str = GameObject.Find("[name of the go the script is attached to]").GetComponent<ScriptyScript>();
str.stringy //is the command you will be using in your unity script to get the stringy variable of the other script)