using System.Collections; using System.Collections.Generic; using UnityEngine; using InfallibleCode; public class DrawingPickup : MonoBehaviour { public ExaminableItem examinableItem; private MeshRenderer _drawingMeshRenderer; private bool _collectedItem; public int ItemID; // Start is called before the first frame update void Start() { _drawingMeshRenderer = GetComponentInChildren(); examinableItem = GetComponent(); } // Update is called once per frame void Update() { PickUpDrawing(); } public void PickUpDrawing() { if (examinableItem.examineItem.CanPressButtonToGetItem && examinableItem.examineItem.CurrenltyExaminingObj && !_collectedItem) { if (Input.GetKeyDown(KeyCode.E)) { LampsSequence.GetInstance().DrawingsCollectedID += 1; LampsSequence.GetInstance().ItemID = ItemID; LampsSequence.GetInstance().UpdateItemIndex = true; StartCoroutine(PickingUpObject()); _collectedItem = true; } } } IEnumerator PickingUpObject() { Destroy(_drawingMeshRenderer.gameObject); yield return new WaitForSecondsRealtime(0.1f); examinableItem.examineItem.GotItemExitDisplayingItem3d(); yield return new WaitForSecondsRealtime(0.1f); Destroy(gameObject); } }