当前位置: 首页 > news >正文

怎么看一个网站做没做优化wordpress导航文件

怎么看一个网站做没做优化,wordpress导航文件,人防网站建设与服务,公司企业邮箱注册流程最近在Unity上需要很原生移动端进行交互#xff0c; 原理#xff1a;新建一个android项目#xff0c;把生成的app module给干掉#xff0c;然后留下一个vibrationPlugin module#xff0c;在这个module下写android震动代码#xff0c;将这个android工程构建出来的 aar移…最近在Unity上需要很原生移动端进行交互 原理新建一个android项目把生成的app module给干掉然后留下一个vibrationPlugin module在这个module下写android震动代码将这个android工程构建出来的 aar移动到Unity项目下的Assets/Plugins/Android下重新打包利用 AndroidJavasClass获得unityPlayer,然后通过unityPlayer获得当前unity的activity,将unity activity的context 传递给 vibrationPlugin工程里面 现在开始整个集成的过程 1: Android 一新建Android项目 选择No Activity 等待项目编译 编译完毕之后在 app/java/com.lck.unityvibration/目录下新建一个java文件 package com.lck.unityviabration;import android.content.Context; import android.os.Vibrator;public class VibrationPlugin {private static VibrationPlugin instance;private Vibrator vibrator;public VibrationPlugin(Context context) {vibrator (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);}public static VibrationPlugin getInstance(Context context) {if(instance null) {instance new VibrationPlugin(context);}return instance;}public void vibrate(long milliseconds) {vibrator.vibrate(milliseconds);}public void cancel() {vibrator.cancel();} }注意在 AndroidManifest.xml中引入  uses-permission android:nameandroid.permission.VIBRATE / 可以把测试的无关代码删除掉 最终的项目目录 然后把res/values和xml文件夹删除掉没啥用 然后把 app module设置成 library 就是在app 的build.gradle中   plugins {alias(libs.plugins.androidApplication) } 替换成 apply plugin: com.android.library 另外 module中没有 applicationId 标识干掉 minSdkVersion和unity android主工程保持一致 最后 Build/Make Project会生成一个aar文件将这个文件放到unity工程里面 Plugins/Android/目录下 二Unity项目调用 新建Unity AndroidUtils.cs脚本 using System.Collections; using System.Collections.Generic; using UnityEngine;public class AndroidUtils {private static AndroidJavaObject vibrationPlugin;// Start is called before the first frame updatepublic static void Init(){if(Application.platform RuntimePlatform.Android) {using(var unityPlayer new AndroidJavaClass(com.unity3d.player.UnityPlayer)) {var activity unityPlayer.GetStaticAndroidJavaObject(currentActivity);if(activity ! null) {Debug.Log(has activity);}var context activity.CallAndroidJavaObject(getApplicationContext);if(context ! null) {Debug.Log(has context);}vibrationPlugin new AndroidJavaObject(com.lck.unityviabration.VibrationPlugin,context);}}}public static void Vibrate(long milliseconds) {if(vibrationPlugin null) {Debug.Log(vibrationPlugin is null);}if(Application.platform RuntimePlatform.Android vibrationPlugin ! null) {vibrationPlugin.Call(vibrate,milliseconds);}}public static void Cancel() {if(Application.platform RuntimePlatform.Android vibrationPlugin ! null) {vibrationPlugin.Call(cancel);}} }在游戏开始的时候初始化 AndroidUtils.Init() 在游戏逻辑中需要的地方调用 AndroidUtils.Vibrate(200); Android集成完毕 2: IOS 一IOS项目 同样的道理跟集成Android很类似需要在unity项目中的Plugins文件夹创建一个文件夹为IOS文件夹里面放两个文件就可以了NativeUtils.h和NativeUtils.mm #import Foundation/Foundation.hNS_ASSUME_NONNULL_BEGINinterface NativeUtils : NSObjectendNS_ASSUME_NONNULL_END#import NativeUtils.h #import UIKit/UIKit.himplementation NativeUtils extern C {void setVibrator(float Intensity) {NSLog(设置震动强度:%f,Intensity);UIImpactFeedbackGenerator* generator;generator [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleHeavy];[generator impactOccurred];} } end 二Unity项目集成 在我上面AndroidUtils.cs文件中加入两行代码就行了 // DllImport 语句用于调用iOS插件中的C函数[DllImport(__Internal)]private static extern void setVibrator(float intensity); 调用 public static void Vibrate(long milliseconds) {if(vibrationPlugin null) {Debug.Log(vibrationPlugin is null);}if(Application.platform RuntimePlatform.Android vibrationPlugin ! null) {vibrationPlugin.Call(vibrate,milliseconds);} else if(Application.platform RuntimePlatform.IPhonePlayer) {Debug.Log(调用震动功能);setVibrator(1.5f);}} 打包到目标IOS之后会看到Xcode项目里面多了个Libraries文件夹下的Plugins文件夹里面有IOS/NativeUtils和NativeUtils.mm文件了这就是正确的IOS调用震动功能的全部代码了。
http://www.eeditor.cn/news/122718/

相关文章:

  • 淄博网站制作定制技术谷歌英文网站优化
  • 做网站开发多少钱做网站需要会哪些计算机语言
  • 网站用户体验模型江苏荣邦建设有限公司网站
  • 网站建设的四个步骤小学学校网站模板免费下载
  • 上海网站设计成功柚v米科技1元购类似网站架设药多少钱
  • 劳力士手表网站免费主页空间申请网站
  • 北京大良网站建设wordpress 404判断
  • 谁知道做网站的电话河南省新闻出版培训中心
  • 一个单位网站被黑该怎么做做网站要给ftp密码吗
  • 网站的交互设计包括哪些郑州住房城乡建设局
  • 怎么做网站的效果图应届毕业生招聘官网
  • 重庆网站房地产重庆建设注册执业中心网站
  • 比赛网站开发创建直播平台
  • 大连建设工程设计院有限公司网站关于企业的网站
  • 资源网站模板下载做棋牌网站抓到会怎么量刑
  • 志愿服务网站建设方案wordpress网站布局
  • 合肥建设银行网站首页济南济南网站建设公司
  • 网站开发背景和目的dede 汽车网站
  • 南山专业做网站公司xp做网站
  • 怎样制定一个网站建设方案那个网站可以兼职做效果图
  • 分类网站建设网站的设计过程
  • 网站做程序cms建站模板下载
  • 医院网站备案二级域名解析网
  • 做的网站底部应该标注什么制作应用的网站
  • 汽车最专业的网站建设东莞网站推广服务
  • 如何做论坛网站 知乎上海做推广网站
  • 网络规划设计师可以同时报名吗专业网站优化
  • 网站要怎么做的吗网站备案中更名
  • 网站进度条wordpress换空间后内页全部404
  • 上海网站建设改版短网址 wordpress