using System; using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using DG.Tweening; using UnityEditor; using UnityEngine; using UnityEngine.Windows.WebCam; public class Door : MonoBehaviour { [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; } public void Open() { _graphics .DOMove(_endpoint.position, _animTime) .SetEase(Ease.InOutSine); } public void Close() { _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(); } } } #endif