Unity C # intermodulation Java simple notes, bash simple to use the place

Source: Internet
Author: User

Follow the project this week, continue to change the bug, Gaga in English switch

Focusing on the mutual invocation of unity and Android ADT Online to see what else you need to configure the library my unity is version 4.6, I don't see anything that needs to be configured for the library. Direct from Unity's export project directly at ADT is available. Maybe the tutorial is too old to look at. 1.unity call Javaandroidjavaclass JC = new Androidjavaclass ("Com.unity3d.player.UnityPlayer");

Androidjavaobject Jo = JC. Getstatic<</span>androidjavaobject> ("currentactivity");

These two words are dead, once I thought that the package name needs and export the package name needs the same, the result superfluous, unity is the activity encapsulated a goodCom.unity3d.player.UnityPlayer class, Currentyactivity is getting to the current activity.
Jo. Call ("GetString", "string is csharp!");Jo is the current activity class, calling method GetString.The second parameter is optional, and if the method is null, direct C # does not have to be written. 2.java Call Unity

Unityplayer.unitysendmessage ("Cube", "message", "Java Call unity");

The first one was the name of the target, and I threw it in a box.

The second parameter is the method name of the calling script, which is a message

Parameters passed in the third parameter

3. Need to be aware of

Because Android UI is not thread-safe, so create any UI is no use, the pit Dad is unexpectedly no error, let me a dialog how also do not come out also do not know what is going on

If you want to build something in the UI,

(1) is setmessage can be passed to the main line thread

(2). Runonuithread can create an anonymous thread and then write the UI thread on this anonymous line.

4. can be promoted.

If you call Java's many third-party SDKs in unity, you must overwrite the old ADT project when unity re-guides the package.

So the previously configured SDK may not be available, most of it is not missing something, Androidmanifest is overwritten and res is overwritten, The third party you configure needs androidmanifest to call other application or activity, so it's white.

It is convenient to copy some XML that may be written in the Androidmanifest and res directories and then overwrite it after the package is imported.

See if the library has been lost is also to pay attention to, generally will be lost every time.

Basic operation of 5.bash

Because of the engineering cause of debugging when the need to copy files overwrite other files, such as XML, such as the overwrite, this operation two times is OK, but the number of times is also very annoying, so write a bash or py is very convenient, declare I am just a rookie.

The previous bash or py to the file before the addition of/usr/what, now do not.

With Bash you'll find a lot of commands that are exactly the same as UNIX commands, such as Cp,rm,..

For example I need to copy a androidmanifest.xml in the Override_file folder under the current path to the current path

Then you can

Touch move_file.sh

Create a move_file.sh bash file

sudo chmod-r 777 movefile.sh

Give him permission.

And then open up a software that can edit the text. Open the software vi/vim anything.

CP. Override_file/androidmanifest.xml./

Copy, description below./Is the meaning of the current path, in fact, can also be omitted, but this is more clear-minded, the last "./" can also be written as "."

You can declare variables in the front.

res_dir=./override_file/

When using the

CP $RES _dir/androidmanifest.xml.

The effect is the same

When using SH Direct./movefile.sh.

End Refueling

Unity C # intermodulation Java simple notes, bash simple to use the place

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.