您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

47 行
1.1 KiB

using GameplayIngredients;
using GameplayIngredients.Interactions;
using NaughtyAttributes;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(SphereCollider))]
public class ARUIInteractive : Interactive
{
public float MaxDistance = 5.0f;
[ReorderableList]
public Callable[] OnHoverIn;
[ReorderableList]
public Callable[] OnHoverOut;
bool m_Hover;
protected override void OnEnable()
{
base.OnEnable();
m_Hover = false;
}
public void Hover(InteractiveUser user, bool state)
{
if (state != m_Hover)
{
if(state) // hover in
{
Callable.Call(OnHoverIn, user.gameObject);
}
else // hover out
{
Callable.Call(OnHoverOut, user.gameObject);
}
m_Hover = state;
}
}
public override bool CanInteract(InteractiveUser user)
{
return Vector3.SqrMagnitude(user.transform.position - transform.position) < (MaxDistance * MaxDistance);
}
}