Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
4e10c4f05This file is pinned to the selected release. Download the original to open it in your design tool.
using Leap.Unity.Animation;
using Leap.Unity.Attributes;
using Leap.Unity.Interaction;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Leap.Unity.PhysicalInterfaces {
public class HideWhenHandleMoving : MonoBehaviour {
[SerializeField, ImplementsInterface(typeof(IHandle))]
private MonoBehaviour _handle = default;
public IHandle handle {
get {
return _handle as IHandle;
}
}
[SerializeField, ImplementsInterface(typeof(IPropertySwitch))]
private MonoBehaviour _objectVisibleSwitch = default;
public IPropertySwitch objectVisibleSwitch {
get {
return _objectVisibleSwitch as IPropertySwitch;
}
}
void OnDisable() {
if (objectVisibleSwitch.GetIsOffOrTurningOff() && handle.isMoving) {
objectVisibleSwitch.On();
}
}
void Update() {
if (handle.isMoving && objectVisibleSwitch.GetIsOnOrTurningOn()) {
objectVisibleSwitch.Off();
}
if (!handle.isMoving && objectVisibleSwitch.GetIsOffOrTurningOff()) {
objectVisibleSwitch.On();
}
}
}
}