Interaction between android + unity game development scripts

Source: Internet
Author: User

 

Let's talk about the call in two cases, namely the call of scripts in the same game object and the call of scripts of different game objects;

 

1. In a game object, the script call is very simple, as shown below:

 

 

Var Contro;

 

Control = GetComponent (scriptname); // scriptname indicates the name of the script to be called.

 

 

2. In different game objects, it is not difficult to call scripts, that is, to find the game objects first, and then find the scripts. You will understand the code.

 

<Pre class = "html" name = "code"> var aa: GameObject;

Aa = GameObject. Find ("GameObjectname"); // GameObjectname indicates the game object you want to call.

Var mus: scriptname = aa. GetComponent (scriptname); // scriptname indicates the name of the called script.

 

Note: If you write the code outside the function, it may be wrong. If an error occurs, cut it into the function.

 

 

 

Let's talk about it. It's simple. We often use it ~~~

From dlnuchunge's column

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.