Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Created June 24, 2018 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flushpot1125/5f21838031725f27cade4991066f8060 to your computer and use it in GitHub Desktop.
Save flushpot1125/5f21838031725f27cade4991066f8060 to your computer and use it in GitHub Desktop.
//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