EasyAR

来源:互联网 发布:知乎 三国 编辑:程序博客网 时间:2024/05/20 03:46
//=============================================================================================================================//// Copyright (c) 2015-2017 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.////=============================================================================================================================using UnityEngine;namespace EasyAR{    public class EasyImageTargetBehaviour : ImageTargetBehaviour    {        public GameObject _tuoka;        public GameObject _ArCamera;       // public GameObject[] _HeroUI;        protected override void Awake()        {            base.Awake();            TargetFound += OnTargetFound;            TargetLost += OnTargetLost;            TargetLoad += OnTargetLoad;            TargetUnload += OnTargetUnload;        }        void OnTargetFound(TargetAbstractBehaviour behaviour)        {            Debug.Log("Found: " + Target.Id);            //关闭脱卡            CloseTuoka();            //隐藏人物介绍UI            //HideHeroUI();        }        void OnTargetLost(TargetAbstractBehaviour behaviour)        {            Debug.Log("Lost: " + Target.Id);            //显示脱卡            OpenTuoka();            //修正相机位置            AmendArCamera();            //显示人物介绍UI            //DisplayHeroUI();        }        void OnTargetLoad(ImageTargetBaseBehaviour behaviour, ImageTrackerBaseBehaviour tracker, bool status)        {            Debug.Log("Load target (" + status + "): " + Target.Id + " (" + Target.Name + ") " + " -> " + tracker);        }        void OnTargetUnload(ImageTargetBaseBehaviour behaviour, ImageTrackerBaseBehaviour tracker, bool status)        {            Debug.Log("Unload target (" + status + "): " + Target.Id + " (" + Target.Name + ") " + " -> " + tracker);        }        //修正相机位置        void AmendArCamera()        {            _ArCamera.transform.localPosition = Vector3.zero;            _ArCamera.transform.localEulerAngles = Vector3.zero;        }        void OpenTuoka()        {            _tuoka.SetActive(true);        }        void CloseTuoka()        {            _tuoka.SetActive(false);        }        ////显示英雄介绍UI        //void DisplayHeroUI()        //{        //    for (int i = 0; i < _HeroUI.Length; i++)        //    {        //        _HeroUI[i].SetActive(true);        //    }        //}        ////隐藏英雄介绍UI        //void HideHeroUI()        //{        //    for (int i = 0; i < _HeroUI.Length; i++)        //    {        //        _HeroUI[i].SetActive(false);        //    }        //}    }  }