配列

確認済のバージョン: 4

-

難易度: 初級

配列を使って、変数をより管理しやすい形にまとめる方法を学びます。

配列

初級 Scripting

Arrays

Code snippet

using UnityEngine;
using System.Collections;

public class Arrays : MonoBehaviour
{
    public GameObject[] players;

    void Start ()
    {
        players = GameObject.FindGameObjectsWithTag("Player");
        
        for(int i = 0; i < players.Length; i++)
        {
            Debug.Log("Player Number "+i+" is named "+players[i].name);
        }
    }
}
#pragma strict

public var players : GameObject[];

function Start ()
{
    players = GameObject.FindGameObjectsWithTag("Player");
    
    for(var i : int = 0; i < players.Length; i++)
    {
        Debug.Log("Player Number "+i+" is named "+players[i].name);
    }
}
import UnityEngine
import System.Collections


public class Arrays(MonoBehaviour):

    public players as (GameObject)

    
    private def Start():
        players = GameObject.FindGameObjectsWithTag('Player')
        for i in range(0, players.Length):
        
            Debug.Log(((('Player Number ' + i) + ' is named ') + players[i].name))