x


Proper Cross Script Referencing In C#

Im starting to dig into C# more than JS. Just so Im clear do I have to actually using GameObject.Find() for C#? or does variable = gameObject.GetComponenet

more ▼

asked Apr 12 '12 at 03:14 AM

GC1983 gravatar image

GC1983
540 18 33 44

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

GetComponent<> gets scripts on the same object.

If the script is on a different object, either make a variable of the script type and drag the GameObject containing that script onto it in the editor, or use GameObject.Find(). Find is slower, prefer the other options first whenever possible.

more ▼

answered Apr 12 '12 at 03:17 AM

Talimar gravatar image

Talimar
146 4 4 7

Mind giving me a full example just so Im sure?

Apr 12 '12 at 03:25 AM GC1983

Nevermind! I got it working. thank you!

Apr 12 '12 at 03:56 AM GC1983
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3318

asked: Apr 12 '12 at 03:14 AM

Seen: 360 times

Last Updated: Apr 12 '12 at 03:56 AM