33 lines
626 B
C#
33 lines
626 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class DrawerContent : MonoBehaviour
|
|
{
|
|
[SerializeField] private Drawer _drawer;
|
|
|
|
private Rigidbody _rb;
|
|
private Collider _collider;
|
|
|
|
void Start()
|
|
{
|
|
_rb = GetComponent<Rigidbody>();
|
|
_collider = GetComponent<Collider>();
|
|
SetPhysics(false);
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (_drawer.IsOpen)
|
|
SetPhysics(true);
|
|
else
|
|
SetPhysics(false);
|
|
}
|
|
|
|
void SetPhysics(bool active)
|
|
{
|
|
_rb.isKinematic = !active;
|
|
_collider.enabled = active;
|
|
}
|
|
}
|