void Update() { float distance = Vector2.Distance(transform.position, target.transform.position); if (distance <= distanceToOpenShop) { if (!uiShop.isActiveAndEnabled) { uiShop.gameObject.SetActive(true); } if (!uiShop.IsOpen) { uiShop.Open(); } } else if (distance >= distanceToOpenShop) { if (uiShop.IsOpen) { uiShop.Close(); } } }