﻿//----------------------------------------------------------------------------------
// GVRNavi | Garpix Virtual Reality Navigation
// Copyright (c) 2017 Garpix Ltd.
//
// Plugin Homepage: https://gvrnavi.garpix.com
// Author Homepage: https://garpix.com
// Support: support@garpix.com
// License: Asset Store Terms of Service and EULA
// License URI: See LICENSE file in the project root for full license information.
//----------------------------------------------------------------------------------

using UnityEngine;

namespace GVRNavi
{
    public class FloorPanelRotation : MonoBehaviour
    {
        #region variables

        public Transform targetTransform;
        public bool blockX = false;
        public bool blockY = false;
        public bool blockZ = false;

        #endregion


        void LateUpdate()
        {
            if (targetTransform != null)
            {
                Vector3 v = targetTransform.rotation.eulerAngles - transform.rotation.eulerAngles;
                v = new Vector3(blockX ? 0f : v.x, blockY ? 0f : v.y, blockZ ? 0f : v.z);
                if (v != Vector3.zero)
                    transform.Rotate(v, Space.World);
            }
        }
    }
}