M
M
max_vr2017-04-01 23:19:08
C++ / C#
max_vr, 2017-04-01 23:19:08

How to get a reference to a Unity object (C#)?

Good afternoon. There is the following hierarchy: main/canvas/pages/navigationBar . The navigation bar includes a few more components. How to get a reference to it from a script from another class bound to another object? Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2017-04-02
@max_vr

There are many options. The simplest is to do in another script where you need to get a link, SerializeField of type NavigationBar and drag the navigation bar there in the editor.
There are all sorts of options with singletons, GetComponent, FindObject and more. But Unity-way - described above.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question