配列によりひとつの変数に複数のオブジェクトを格納できます。
Array クラスは Javascript でのみ利用可能です
Here is a basic example of what you can do with an array class:
There are two types of arrays in Unity, builtin arrays and normal Javascript Arrays.
Builtin arrays (native .NET arrays), are extremely fast and efficient but they can not be resized.
これらは static に型宣言されていて、インスペクターで編集可能です。次にビルトインの配列を使用する基本的なサンプルを示します。
// example c# script showing how // an array can be implemented. using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { // Exposes an float array in the inspector, which you can edit there. public float[] values; void Start() { foreach (float value in values) { print(value); }
// Since we can't resize builtin arrays // we have to recreate the array to resize it values = new float[10];
// assign the second element values[1] = 5.0F; } }
ビルトイン配列はパフォーマンスが重要なスクリプトでは便利です( Unity の Javascript やビルトイン配列では mesh インターフェースを使用して秒間 200 万頂点を容易に処理できます。)
Normal Javascript Arrays on the other hand can be resized, sorted and can do all other operations you would expect from an array class.
Javascript Arrays do not show up in the inspector.
Note: You can easily convert between Javascript Arrays and builtin arrays.
Note that Array functions are upper case following Unity's naming convention.
As a convenience for javascript users, Unity also accepts lower case functions for the array class.
Note: Unity doesn't support serialization of a List of Lists, nor an Array of Arrays.
length | The length property that returns or sets the number of elements in the Array. |
Array | サイズが固定された配列を作成します |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.