55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
|
|
public class Space3DIcon : MonoBehaviour
|
|
{
|
|
|
|
private GameObject icon;
|
|
public int floorIndex;
|
|
public GameObject effect;//区域点位特效
|
|
|
|
// 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<UI3DEventTrigger>())
|
|
icon.AddComponent<UI3DEventTrigger>();
|
|
icon.GetComponent<UI3DEventTrigger>().onClick= ViewCenter;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 视角居中
|
|
/// </summary>
|
|
public void ViewCenter() {
|
|
Quaternion angle= Quaternion.LookRotation(-transform.forward);
|
|
Vector3 endpos= transform.position + transform.forward * 5;
|
|
CameraManager._instance.CameraMoveTarget(endpos, angle);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 给UI添加碰撞体
|
|
/// </summary>
|
|
/// <param name="uiobj"></param>
|
|
void AddUICollider(GameObject uiobj)
|
|
{
|
|
if (!uiobj.GetComponent<BoxCollider>())
|
|
{
|
|
uiobj.AddComponent<BoxCollider>();
|
|
Vector2 pivot = uiobj.GetComponent<RectTransform>().pivot;
|
|
Vector3 center = new Vector3(uiobj.GetComponent<RectTransform>().sizeDelta.x * (0.5f - pivot.x), uiobj.GetComponent<RectTransform>().sizeDelta.x * (0.5f - pivot.y));
|
|
uiobj.GetComponent<BoxCollider>().size = uiobj.GetComponent<RectTransform>().sizeDelta;
|
|
uiobj.GetComponent<BoxCollider>().center = center;
|
|
}
|
|
}
|
|
}
|