My programing skills are very dated but I am usually able to figure this stuff out.
Can someone please explain to me how to reference code from other scripts.
I know this is very basic stuff but I can’t seem to get it to work.
I have tried to make the GameObject from the script where I am trying to get access thinking that might be it but to no avail.
In fact along with how this is done… I had assumed that getting something from another script would be as simple as something like
GetComponent.Barrel.Field_Direction
Where Barrel is some other script and within I have something like
public string[ ] Field_Direction = {“North”, “East”, “South”, “West”}
Part of my problem is I am very dyslexic, in any documentation I need the format like I just used were an actual example name is used followed by a key that tells you which words in the documentation are not computer code functions.
ie.
var scriptName : ScoreTextScript;
function Update () { scriptName.AddScore(); }
ScoreTextScript.js
var score : int = 0;
function Update()
{
guiText.text = "Score: " + score;
}
function AddScore()
{ score ++;
}
I can see with some effort that scriptName and ScoreTextScript are not code but a fill in the blank type of thing. But in many examples there are so many of these fill in the blanks and they appear deeper into the example that I can’t separate them out in my head.
And lastly this type of thing confuses me very much:
public SerializedProperty longStringProp;
void OnEnable () {
longStringProp = serializedObject.FindProperty (“longString”);
}
it seems that if I were to bring in this “longStringProp” that I should just be able to start using it but everywhere I look it seems to need to be redefined to be able to use
ie. longStringProp =
I can’t get why I need to make it = anything unless I need to change it’s type of container like from a int to a float.
For someone like me I wish there were usage examples where the only colored fonts were the fill in your own blank words.
ie.
var scriptName : ScoreTextScript;
function Update () { scriptName.AddScore(); }
I would be able to read that in 2 seconds like most of you can just with normal examples.
This might have been too much to ask but like most things things are not hard once you understand them so I was hoping someone would have not only a grasp on how Unity C works but understand my issue enough to make a nice bridge of understanding for me