Merhaba. Ben yeniyim. Rastgele oluşturduğum sayıları (sayılar gamobject, resim olarak geliyorlar ekrana) bir görüntü olarak yok etmek istiyorum. Ama sırayla yok edemiyorum, 1,2,3,4,5 gibi sırayla yok etmeliyim ve sıra dışı bas başladığında oyunun yeniden başlaması veya bitmesi gerekiyor. Lütfen bir kod örneği paylaşıp bana sırayla onu yok etmeyi öğretir misin?
I am going to write a response in English and run it through google translate to Turkish for you in case you don’t know English. All code has not been tested.
İngilizce bilmiyorsanız sizin için İngilizce bir cevap yazacağım ve google translate’den Türkçe’ye çevireceğim. Kodun tamamı test edilmemiştir.
I am assuming that you want to have a number of object destroy in your scene in a particular order with a particular delay. This is not too difficult to do in Unity.
Sahnenizde belirli bir sırayla belirli bir gecikmeyle bir dizi nesnenin yok edilmesini istediğinizi varsayıyorum. Bunu Unity’de yapmak çok zor değil.
Firstly you are going to want a list of your objects in order, see code below:
Öncelikle, sırayla nesnelerinizin bir listesini isteyeceksiniz, aşağıdaki koda bakın:
public List<GameObject> objectList;
Then, you are going to want a counting variable:
Ardından, bir sayma değişkeni isteyeceksiniz:
private int index = 0;
Now you are going to create a function that will destroy your object:
Şimdi nesnenizi yok edecek bir işlev yaratacaksınız:
private void DestroyObject() {
if (index < objectList.size) {
Destroy(objectList[index]);
}
else {
CancelInvoke();
}
}
Finally, you are going to want to invoke your method to repeat:
Son olarak, tekrarlamak için yönteminizi çağırmak isteyeceksiniz:
InvokeRepeating("DestroyObject", 0f, **repeat delay**);
In this case repeat delay is the amount of time you want to have between each call of the destroy method.
Bu durumda repeat delay, yok etme yönteminin her çağrısı arasında olmasını istediğiniz süredir.
This probably isn’t the most efficient way of doing this but should get your system working.
Bu muhtemelen bunu yapmanın en verimli yolu değildir, ancak sisteminizin çalışmasını sağlamalıdır.
Thank you very much, my friend. You are the only answer. I am grateful. But I want to do it in order of numbers, not that way. I’ll take a sample picture.
Gördüğünüz gibi en küçüğünden başlayarak bu sayıları tek tek elemek istiyorum ama sıraya koyamıyorum. Ortadan kaybolurlar ama kontrol edilmezler.