Forgot password?
 立即注册
EasyAR Portal Tutorial View Content

EasyAR Developing Case--AR Gifts(for beginners)

AlbertLee 2017-8-10 10:11

EasyAR Developing Case

Develop intriguing Apps with EasyAR SDK

Preview:




Resources: https://drive.google.com/open?id=0B6vjKDkZUGVselFMblp5RFR2Mnc



Step 1:Developing Environment


If you are not familiar with how to set up AR environment by EsyAR SDK, you can check EasyAR Beginner Guide(1)---display model. Now let’s move to the key part.

Download resources and import them into Unity and set up AR environment. Like that:

Step 2:Prepare model

We import prepared materials—gifts and animated girl into Unity. Import three gift boxes and the girl into the sub model of ImageTarget. The location of gift box lies in:

The position of girl model lies in:

After that, modify the location based on your own needs. The effect is like that:

Step 3:Write script

First add Box Collider to the gift box, tick Trigger

Create a script, the goal is show the animated girl after the gift box disappear by clicking on the box. Here we use the most convenient way Void OnMouseDown(). You should add a Collider on model.

void OnMouseDown()

{

Destroy(this.gameObject);

}

Step 4:Add particle effect

Achieve surprise gift effect by using particle effect. The particle effect is located in here

Next, write script. The script is simple. The goal is to destroy box and display particle effect. The script is like below.

using UnityEngine;

using System.Collections;

public class Explore : MonoBehaviour {

public GameObject explore1;

public GameObject explore2;

public GameObject explore3;

public AudioSource sound;

// Use this for initialization

void Start () {

}

// Update is called once per frame

void Update () {

}

void OnMouseDown()

{

Destroy (this.gameObject);

Instantiate (explore1,transform.position,transform.rotation);

Instantiate (explore2, transform.position, transform.rotation);

Instantiate (explore3,transform.position,transform.rotation);

}

}

You can choose particle according to your favor.

Step 5:Add sound effect

Sound effect has great influence on customer experience while using an App or game. Add AudioSource to gift box.

using UnityEngine;

using System.Collections;

public class Explore : MonoBehaviour {

public GameObject explore1;

public GameObject explore2;

public GameObject explore3;

public AudioSource sound;

// Use this for initialization

void Start () {

}

// Update is called once per frame

void Update () {

}

void OnMouseDown()

{

Destroy (this.gameObject);

sound.Play ();

Instantiate (explore1,transform.position,transform.rotation);

Instantiate (explore2, transform.position, transform.rotation);

Instantiate (explore3,transform.position,transform.rotation);

}

}

Ok, that’s it. We can use simple code and EasyAR SDK to create amazing Apps.

  • gokulkrish 2017-10-18 10:41
    cant download resource in every tutorial. requested permission but still not given access