お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Closeasset | アセット作成する際に使用するオブジェクト |
path | アセット作成する際に使用するオブジェクト |
オブジェクトを指定したパスに作成します。
パスが拡張子に対応していることを確認して下さい(マテリアルは .mat、キューブマップは .cubemap、 スキンは .GUISkin、アニメーションは .anim、他の任意のアセットは .asset)。 アセット作成後に AssetDatabase.AddObjectToAsset を使用してさらにアセットをファイルに追加出来ます。 アセットが path にすでに存在する場合、新規のアセットを作成する前に削除されます。 全てのパスはプロジェクトフォルダに対する相対指定とします。例えば "Assets/MyTextures/hello.png" です。 アセットに複数オブジェクトを追加する場合、オブジェクトが 追加された順序は何も影響しません。 すなわち、追加されたアセットは元のアセットに対しての違いはなく、後に追加するオブジェクトに対する元オブジェクトとなるようなことはありません。 プロジェクトビューでアセットのメインオブジェクトとして表示されたオブジェクトは、 オブジェクトのコレクションの中でもっとも重要とみなされたものです(型により判定)。
@MenuItem("GameObject/Create Material") static function CreateMaterial () { // Create a simple material asset var material = new Material (Shader.Find("Specular")); AssetDatabase.CreateAsset(material, "Assets/MyMaterial.mat"); // Print the path of the created asset Debug.Log(AssetDatabase.GetAssetPath(material)); }