Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//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