48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DefaultNamespace.Dto;
|
|
using DefaultNamespace.ProcessMode;
|
|
using DG.Tweening;
|
|
using Framework.Scripts.Runtime.Engine.Engine.Camera;
|
|
using Framework.Scripts.Runtime.Engine.Engine.Camera.UIMoveTarget;
|
|
using MotionFramework;
|
|
using Newtonsoft.Json;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class test1 : MonoBehaviour
|
|
{
|
|
private IRaycastable _raycastComponent;
|
|
private IUIFollow _uiFollow;
|
|
|
|
public RectTransform ui;
|
|
|
|
private void Awake()
|
|
{
|
|
_raycastComponent = new CameraRaycastComponent();
|
|
_uiFollow = new CameraFollowComponent();
|
|
}
|
|
void OnEnable()
|
|
{
|
|
_raycastComponent.OnRaycastHit += HandleRaycastHit;
|
|
}
|
|
|
|
// 处理射线命中事件并打印物体名称
|
|
void HandleRaycastHit(RaycastHit hit)
|
|
{
|
|
Debug.Log("Raycast hit: " + hit.collider.name);
|
|
_uiFollow.FollowObject(hit.collider.transform,ui,Camera.main);
|
|
// 在这里可以添加更多处理逻辑,比如交互或特效
|
|
}
|
|
void Update()
|
|
{
|
|
// 调用射线功能
|
|
_raycastComponent?.Raycast();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} |