using System.Collections; using System.Collections.Generic; using UnityEngine; using DG.Tweening; public class Space3DIcon : MonoBehaviour { private GameObject icon; // Start is called before the first frame update void Start() { icon=transform.GetChild(0).gameObject; icon.transform.DOLocalMoveY(3, 0.8f).SetLoops(-1, LoopType.Yoyo); if(!icon.GetComponent()) icon.AddComponent(); icon.GetComponent().onClick= ViewCenter; } // Update is called once per frame void Update() { } /// /// 视角居中 /// public void ViewCenter() { Quaternion angle= Quaternion.LookRotation(-transform.forward); Vector3 endpos= transform.position + transform.forward * 5; Main.intance.CameraMoveTarget(endpos, angle); } /// /// 给UI添加碰撞体 /// /// void AddUICollider(GameObject uiobj) { if (!uiobj.GetComponent()) { uiobj.AddComponent(); Vector2 pivot = uiobj.GetComponent().pivot; Vector3 center = new Vector3(uiobj.GetComponent().sizeDelta.x * (0.5f - pivot.x), uiobj.GetComponent().sizeDelta.x * (0.5f - pivot.y)); uiobj.GetComponent().size = uiobj.GetComponent().sizeDelta; uiobj.GetComponent().center = center; } } }