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

public class MakeChildOfTheARCamera : MonoBehaviour
{

    // Use this script to re-parent a gameobject or hierarchy of gameobjects to the AR Camera at runtime.

    //Step1. Set the "Main Camera" transform component to 0.0.0 for position and rotation then 1,1,1 for scale.  
    //Step2. Inside your Prefab, create an Empty GameObject and rename it to CameraChild (the name is key and case sensitive) and attach this "MakeChildOfTheARCamera.cs" script component to it.  
    //       Reset its transform component to insure it is also at 0.0.0 for position and rotation then 1,1,1 for scale.
    //Step3. Now add any GameObjects as Children of this CameraChild object and position them using the Game view.
    // At runtime the object named CameraChild, along with its children, will be detatched from the Prefab Assetbundle and be re-parented to the AR Camera.




    /*************************************************************************
* 
* ARConnex
* __________________
* 
*  [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 or if used for display in the ARConnex Reality Browser.
*/




    public void ParentToCamera(GameObject childObject)
    {
        GameObject arCam = GameObject.Find("ARCamera");
        childObject.transform.SetParent(arCam.transform,false);       
    }
}
