Skip to content
Snippets Groups Projects

Foreach-silmukka for-silmukaksi

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by tailkauh
    Edited
    koodi.cs 468 B
    // foreach (GameObject vanha in GetObjectsWithTag("tekstikentta"))
    // {
    //     vanha.Y += 50;
    // }
    
    // foreach tehty for-silmukalla
    
    // Lista, jossa GameObject-tyyppisiä alkioita   
    List<GameObject> lista = GetObjectsWithTag("tekstikentta"); 
    
    // lista.Count palauttaa listan alkioiden lukumäärän                
    for (int i = 0; i<lista.Count; ++i)                                                            
    {
        GameObject vanha = lista[i];
        vanha.Y += 50;
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment