K
K
Konstantin Shkilev2013-12-17 12:45:50
JavaScript
Konstantin Shkilev, 2013-12-17 12:45:50

Connecting a script in Unity3d?

I started mastering Unity3d using the lessons offered on unity3d.com. Faced the following problem. (I just want to refer from one script to another.)
There is a Cube object on the stage, the "MainCube" javascript is attached to it:

#pragma strict

public var otherObject: GameObject;
private var printH: PrintH;

function Awake(){
  printH = otherObject.GetComponent(PrintH);
}
function Start(){
 Debug.Log(printH.text);
}

The module we are accessing PrintH:
#pragma strict

public var text: String = "Hi, World!!!";

What am I doing wrong? Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GreatRash, 2013-12-17
@shkilevk

Well, in general, in the tutorial they have everything as you have written. Maybe you didn't assign PrintH to Cube?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question