Created
June 24, 2018 14:30
-
-
Save flushpot1125/5f21838031725f27cade4991066f8060 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Ref: https://github.com/google-ar/arcore-unity-sdk | |
namespace GoogleARCore.Examples.AugmentedImage{ | |
using System; | |
using System.Collections.Generic; | |
using System.Runtime.InteropServices; | |
using GoogleARCore; | |
using GoogleARCoreInternal; | |
using UnityEngine; | |
public class AugmentedImageVisualizer : MonoBehaviour { | |
public AugmentedImage Image; | |
public GameObject FrameLowerLeft; | |
public GameObject FrameLowerRight; | |
public GameObject FrameUpperLeft; | |
public GameObject FrameUpperRight; | |
// added by Limes | |
public GameObject toyPrefab; | |
// | |
public void Update() { | |
if (Image == null || Image.TrackingState != TrackingState.Tracking) { | |
/* | |
FrameLowerLeft.SetActive(false); | |
FrameLowerRight.SetActive(false); | |
FrameUpperLeft.SetActive(false); | |
FrameUpperRight.SetActive(false); | |
*/ | |
toyPrefab.SetActive(false); | |
return; | |
} | |
float halfWidth = Image.ExtentX / 2; | |
float halfHeight = Image.ExtentZ / 2; | |
toyPrefab.transform.localPosition = (halfWidth * Vector3.left) + (halfHeight * Vector3.back); | |
toyPrefab.SetActive(true); | |
/* | |
float halfWidth = Image.ExtentX / 2; | |
float halfHeight = Image.ExtentZ / 2; | |
FrameLowerLeft.transform.localPosition = (halfWidth * Vector3.left) + (halfHeight * Vector3.back); | |
FrameLowerRight.transform.localPosition = (halfWidth * Vector3.right) + (halfHeight * Vector3.back); | |
FrameUpperLeft.transform.localPosition = (halfWidth * Vector3.left) + (halfHeight * Vector3.forward); | |
FrameUpperRight.transform.localPosition = (halfWidth * Vector3.right) + (halfHeight * Vector3.forward); | |
FrameLowerLeft.SetActive(true); | |
FrameLowerRight.SetActive(true); | |
FrameUpperLeft.SetActive(true); | |
FrameUpperRight.SetActive(true); | |
*/ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment