关于Unity使用vuforia制作AR

环境:自带vuforia的unity

如果你的unity没有vuforia,可以在vuforia官网下载

使用前配置

进入vuforia官网,https://developer.vuforia.com/license-manager注册一个帐号

1.Get Development Key,获取License,这个License可以一直使用,以后不需要再Get了

2.添加Database

 

参考文章:https://blog.csdn.net/slj2017/article/details/79730378

 

3.制作AR及其动画

使用vufoira前,需要在Edit->Build Settings->Player Settings->XR Settings下勾选Vuforia Augmented Reality

1)unity中,从GameObject->Vuforia->ARCamera,添加ARCamera删除Main camera,

获取License,在vofuria官网点击ARCamera->Open Vuforia configuration->add License

 

2)从GameObject->Vuforia->Image,添加ImageTarget,点击ImageTarget,添加Database和Image Target,其中Database需要在vuforia官网下载后导入unity

 

3)将下载的模型拖入到unity中,即导入模型,并将对应的模型拖到ImageTarget下,作为其子对象,此时完成AR最基础的部分

4)添加动画声音绑定:

i)右键Create->New Animator Controller,双击打开该controller,create State->empty,再次create State->empty,选中第一次create的new State,右键make transition到第二次create的new State,点击第二次创建的new State,将模型动作拖到它的Motion里,选择controller里的'+'->Bool,命名,例如:isAnimation(与代码相对应,可自定义),最后将这个controller拖给模型

ii)点击模型,创建碰撞体:Add Component->capsule Collider,自行修改碰撞体大小范围

iii)点击模型,添加声音:Add Component->Audio Source,把声音拖到AudioClip下,可看情况选择是否勾选'Play On Awake‘

iiii)添加脚本:

public class hyenaPlay : MonoBehaviour

{ 
    // Start is called before the first frame update 
    Animator ani; 
    AudioSource audio;
     void Start() {
         ani = this.GetComponent<Animator>();
         audio = this.GetComponent<AudioSource>(); 
    } 

     void OnMouseDown() {
         ani.SetBool("isAnimation", true); audio.Play(); 
            }
 }

 

其中,”hyenaPlay“为脚本名字,"isAnimation"与上面的Bool值命名对应,最后将脚本拖给模型

5)可在同个场景内,添加多个AR模型,最后保存为一个场景,即File->Save as

6)导出apk:

i)File->Build settings->Player Settings,在Play Settings下选择other Settings,对Package Name进行设置,满足aa.bb.cc命名即可,将Minimum API Level选择为自己手机对应的android版本

ii)进入Edit->preferences,设置android SDK和JAVA SDK路径,最后bulid即可导出apk

 

关于unity打包安卓apk详细步骤:https://blog.csdn.net/weixin_41881186/article/details/80199302

 

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值