来源:蜘蛛抓取(WebSpider)
时间:2018-03-03 22:08
标签:
苹果平板玩安卓游戏
求助各位大神帮我看下 Unity3d 与 Android 交互的问题_百度知道
求助各位大神帮我看下 Unity3d 与 Android 交互的问题
我有更好的答案
);androidplayer\,在这里面再去调用其他的Activity) 5 package com.example. } public void StartActivity(String name) { Intent intent = new Intent(mContext, WelcomeA).height * 0.1f.onCreate(savedInstanceState); } } 4 添加要在unity中调用的方法.player.UnityPlayerA public class MainActivity extends UnityPlayerActivity { private Context mContext = null: 在脚本文件中写如下代码;)) { AndroidJavaClass jc = new AndroidJavaClass(&com.unity3d.player.UnityPlayer&); AndroidJavaObject jo = jc.GetStatic&AndroidJavaObject&(¤tActivity&); Debug.Log(jo.Call&int&(&GetInt&)); } } } 然后生成APK文件,记得先把包名改成与Android工程一样的包名。 要测试,只能在手机上测。 最终效果图: 17 单击StartActivity,启动Android的一个Activity,单击GetInt,Console显示1,其他格式的文件如果放在其他目录下会加载不出来) 然后在Unity里面创建一个脚本文件; using System.C public class Demo .startActivity(intent).jar选择Build Path里面的Add to Build Path.unity3d; import android.os.Button(new Rect(Screen.width * 0.1f;GetInt&com.Home) ) { Application, &StartActivity& jo.Call("。 然后在Build Project 右键单击工程,选择Export 选择JAR file 右边全部勾选, &第一个Activity": using UnityEngine。UnityPlayerActivity只能作为Unity和Android交互的一个接口.height * 0.1f), ".player.UnityPlayer",libs文件夹放需要用的第三方库文件,res文件夹和AndroidManifest直接从Android工程中拷贝过来。 (除了res文件夹不能动,输入JAR的路径和名字,绑定在MainCamera上(当然也可以绑定在其他的对象上),如下;)) { AndroidJavaClass jc = new AndroidJavaClass(".Quit(); } } void OnGUI() { if (GUI; AndroidJavaObject jo = jc.putExtra(&name&;classes, name); this, Screen.Crelease\.Escape) || Input.GetKeyDown(KeyCode.B import com,其他的最好都不要放在单独的文件夹里面,貌似除了jar能加载出来.2f, Screen.width * 0.8f;PlaybackEngines\,这里添加一个带一个参数的方法StartActivity来调用Android的Activity从而运行Android的代码。还添加了一个有返回值的方法GetInt,用来测试在Unity中获取android中方法的返回值。(貌似只能有一个UnityPlayerActivity,而且这个Activity不能是调用第三方SDK方法的Activity,然后单击finish: 在Unity项目中创建一个Plugins.1f, Screen.height * 0: public class MainActivity extends UnityPlayerActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.width * 0.1f).class); intent: MonoBehaviour { void Start () { } void Update() { //.width * 0; } } 6 然后Clean一下当前工程,避免一些不必要的问题;当用户按下手机的返回键或home键退出游戏 if (Input.GetKeyDown(KeyCode.onCreate语句,如下; } if (GUI.Button(new Rect(Screen.jar 拷贝到Android工程的libs文件夹里: 2 右键单击classes, SStartActivity&; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);(¤tActivity& import android.content.I).GetStatic&AndroidJavaObject&bin\.8f, Screen.height * 0: 3 在MainActivity中继承UnityPlayerActivity。删除多余的方法,仅保留onCreate方法中的super, S } public int GetInt() { return 1,如下的目录结构 其中bin文件夹放我们刚刚导出的JAR包; mContext = this.unity3d.Editor\Data\ 1将Unity3D安装目录下的Unity\
资深电脑人
为您推荐:
其他类似问题
unity3d的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。1,795被浏览1,338,302分享邀请回答838添加评论分享收藏感谢收起472180 条评论分享收藏感谢收起unity 怎么监听安卓和苹果系统的home键_百度知道
unity 怎么监听安卓和苹果系统的home键
我有更好的答案
似乎在不同手机上。它对应的键值是不相同的。得到Back和Home的键值然后再匹配键值。写自己要做的事就可以了Back的可以这样写:public boolean onKeyDown(int keyC TODO Auto-generated method stubif (keyCode == KeyEvent, KeyEvent event) {//继承Activity重写OnKeyDown()在里面打印下键 值
采纳率:95%
来自团队:
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。当前位置: >
Unity3D 判断所在平台
时间: 10:31 来源:Unity之家 作者:unity.jb51.net 浏览:
#ifUNITY_ANDROID
&&&&&&&&Debug.Log(&Android&);
&&&&#endif
&&&&#if&UNITY_IPHONE
&&&&&&&&Debug.Log(&IOS&);
&&&&#endif
&&&&#if&UNITY_STANDALONE_WIN
&&&&&&&&Debug.Log(&WINDOWS&);
&&&&#endif此外还支持以下的平台UNITY_EDITORDefine for calling Unity Editor scripts from your game code.UNITY_STANDALONE_OSXPlatform define for compiling/executing code specifically for Mac OS (This includes Universal, PPC and Intel architectures).UNITY_DASHBOARD_WIDGETPlatform define when creating code for Mac OS dashboard widgets.UNITY_STANDALONE_WINUse this when you want to compile/execute code for Windows stand alone applications.UNITY_STANDALONE_LINUXUse this when you want to compile/execute code for Linux stand alone applications.UNITY_STANDALONEUse this to compile/execute code for any standalone platform (Mac, Windows or Linux).UNITY_WEBPLAYERPlatform define for web player content (this includes Windows and Mac Web player executables).UNITY_WIIPlatform define for compiling/executing code for the Wii console.UNITY_IPHONEPlatform define for compiling/executing code for the iPhone platform.UNITY_ANDROIDPlatform define for the Android platform.UNITY_PS3Platform define for running PlayStation 3 code.UNITY_XBOX360Platform define for executing Xbox 360 code.UNITY_NACLPlatform define when compiling code for Google native client (this will be set additionally to&UNITY_WEBPLAYER).UNITY_FLASHPlatform define when compiling code for Adobe Flash.UNITY_BLACKBERRYPlatform define for a Blackberry10 device.UNITY_WP8Platform define for Windows Phone 8.UNITY_METROPlatform define for Windows Store Apps (additionally&NETFX_CORE&is defined when compiling C# files against .NET Core).
(责任编辑:脚印)
免责声明:Unity之家部分内容来源于互联网,如有侵权,请联系我们,本站将立即进行处理。
猜你也喜欢看这些 ??????
其他类型的开发经验 ??????他的最新文章
他的热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)