言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Object.FindObjectsOfType

public static Object[] FindObjectsOfType(Type type);

Description

タイプから見つけた全てのアクティブのオブジェクト配列を返します

It will return no assets (meshes, textures, prefabs, ...) or inactive objects. この関数は非常に動作が遅いため、毎フレーム使用することは推奨しません。 多くの場合は変わりにシングルトン パターンが使用できます。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void OnMouseDown() {
        HingeJoint[] hinges = FindObjectsOfType(typeof(HingeJoint)) as HingeJoint[];
        foreach (HingeJoint hinge in hinges) {
            hinge.useSpring = false;
        }
    }
}