2021-05-13 19:20:44 +02:00
|
|
|
using System;
|
2021-04-15 16:10:58 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
2021-05-13 19:20:44 +02:00
|
|
|
using System.Runtime.CompilerServices;
|
2021-04-15 16:10:58 +02:00
|
|
|
using System.Runtime.InteropServices;
|
2021-05-13 19:20:44 +02:00
|
|
|
using DG.Tweening;
|
|
|
|
using UnityEditor;
|
2021-04-15 16:10:58 +02:00
|
|
|
using UnityEngine;
|
2021-05-13 19:20:44 +02:00
|
|
|
using UnityEngine.Windows.WebCam;
|
2021-04-15 16:10:58 +02:00
|
|
|
|
|
|
|
public class Door : MonoBehaviour
|
|
|
|
{
|
2021-05-13 19:20:44 +02:00
|
|
|
[SerializeField] private Transform _graphics;
|
|
|
|
[SerializeField] private Transform _endpoint;
|
|
|
|
[SerializeField] private float _animTime = 1.2f;
|
|
|
|
|
|
|
|
// private bool _opened = false;
|
|
|
|
private Vector3 _initialPos;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
_initialPos = _graphics.position;
|
|
|
|
}
|
2021-04-15 16:10:58 +02:00
|
|
|
|
|
|
|
public void Open()
|
|
|
|
{
|
2021-05-13 19:20:44 +02:00
|
|
|
_graphics
|
|
|
|
.DOMove(_endpoint.position, _animTime)
|
|
|
|
.SetEase(Ease.InOutSine);
|
2021-04-15 16:10:58 +02:00
|
|
|
}
|
2021-04-21 17:42:11 +02:00
|
|
|
|
|
|
|
public void Close()
|
|
|
|
{
|
2021-05-13 19:20:44 +02:00
|
|
|
_graphics
|
|
|
|
.DOMove(_initialPos, _animTime)
|
|
|
|
.SetEase(Ease.InOutSine);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Reset()
|
|
|
|
{
|
|
|
|
_graphics.DOKill();
|
|
|
|
_graphics.position = _initialPos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
[CustomEditor(typeof(Door))]
|
|
|
|
public class DoorEditor : Editor
|
|
|
|
{
|
|
|
|
private Door _door;
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
{
|
|
|
|
_door = target as Door;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnInspectorGUI()
|
|
|
|
{
|
|
|
|
base.OnInspectorGUI();
|
|
|
|
|
|
|
|
if (!Application.isPlaying) return;
|
|
|
|
|
|
|
|
if (GUILayout.Button("Open"))
|
|
|
|
{
|
|
|
|
_door.Open();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GUILayout.Button("Close"))
|
|
|
|
{
|
|
|
|
_door.Close();
|
|
|
|
}
|
2021-04-21 17:42:11 +02:00
|
|
|
}
|
2021-04-15 16:10:58 +02:00
|
|
|
}
|
2021-05-13 19:20:44 +02:00
|
|
|
#endif
|