Accessing classes from other GameObjects in Java?

Hello!I am in a bit of trouble with this “classes” :frowning: I can’t seem to find a way to access a class from the same script but attached to another GameObject…

So i have GO1 and GO2.Both have the same script (“Script”) attached to them :

var TheOtherGO : Transform; 

class GetSet
{
var isCurrentLOD : boolean = true;
function get _IsCurrentLOD() : boolean { return isCurrentLOD; }
function set _IsCurrentLOD(value : boolean) { isCurrentLOD = value; }
}

function Start(){
print(TheOtherGO.GetComponent(Script).GetSet()._IsCurrentLOD);
}

Am i doing something terribily wrong?Am i not accessing it right?Sorry if the question is newbish but i haven’t found any topics about this on Google…Please help me :frowning: Thanks in advance!

First… there is no Java in Unity, its a permutation of JavaScript, and should really be called UnityScript because it has very little in common with web JavaScript.

Second, you never actually created an instance of your custom class, “GetSet”, all you did was define it. I’m not even sure why you’re creating a custom class, it seems like it’d be better suited as an individual script (which is by default, a class that inherits from MonoBehaviour).

Okay,i was just using an abbreviation.

Then how can i make an instance of it?All i am trying to do is to convert the Get and Set functions from C# to JavaScript (UnityScript :\ )
http://forum.unity3d.com/threads/104917-Getters-and-Setters-in-JavaScript?p=692098#post692098

And i would like to have isCurrentLOD as a normal variable and _IsCurrentLOD as a public variable.
Using a new script wouldn’t make the variable that is supposed to be private to have the same value over each instance of that GameObject?

This is the C# version :

private bool LOD = true;
	public bool IsCurrentLOD
	{
		get { return LOD; }
		set { LOD = value;}
	}

And i woud like to “JavaScriptify” it / “UnityScriptify” it :smile:

Thanks in advance!

Anyone,please?