﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PointQuadsToObject : MonoBehaviour
{

    /*************************************************************************
* 
* 
* Use in conjunction with the "MakeChildOfTheARCamera" component to
* keep Quad/Object pointing toward the AR Camera.
* 
    // If the ARCamera is the desired target use the 
    // "MakeChildOfTheARCamera" Component and attach it to a GameObject called CameraChild. 
    // See the "MakeChildOfTheARCamera" component comments for more info.
    //
    // Create and empty GameObject and attach this script.
    // Select the Target Object to point at (this would usually be the CameraChild or a Child of it)
    // Create a Quad/Text/GameObject as a child of your empty GameObject containing this script.
    // The GameObject's positive Z direction will point to the target.
    // To account for this Rotate the child Quad/Text/GameObject to 180 degrees on the y axis. 
    // The child Quad/Text/GameObject will remain oriented toward the Target Object throughout the experience.
    // Great for building virtual image based ecommerce stores
    //
    // Clone the empty GameObject and change the child surfaces to replicate. 
    // Toggle "Rotate on Y only" if desired. By default the X and Y rotations axis will be used. 


* ARConnex CONFIDENTIAL
* __________________
* 
*  [2017] - [2020] ARConnex Incorporated 
*  All Rights Reserved.
* 
* NOTICE:  All information contained herein is, and remains
* the property of ARConnex Incorporated and its suppliers,
* if any.  The intellectual and technical concepts contained
* herein are proprietary to ARConnex Incorporated
* and its suppliers and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from ARConnex Incorporated.
*/





    public GameObject target;
    public bool rotateOnYOnly;

    // Update is called once per frame
    void Update()
    {
        
        Vector3 lookPoint = target.transform.position;
        transform.LookAt(lookPoint);
        if (rotateOnYOnly)
        {
            transform.localEulerAngles = new Vector3(0, transform.localEulerAngles.y, 0);
        }
       


       

    }
}
