この文書の現在のバージョンと選択したバージョンの差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
|
vci:script:reference:exportassets:material [2019/11/28 17:41] h-eguchi [assets.material (ExportMaterial) (マテリアル制御)] |
vci:script:reference:exportassets:material [2023/06/01 11:12] (現在) pastatto リファレンスページの注意書き追加 |
||
|---|---|---|---|
| ライン 1: | ライン 1: | ||
| - | ====== assets.material (ExportMaterial) (マテリアル制御) ====== | + | ~~NOTOC~~ |
| + | ====== ExportMaterial(マテリアル制御) ====== | ||
| + | <WRAP center round important 80%> | ||
| - | 1.8.2aから、マテリアル制御系の関数が追加されました。[[vci:script:reference:exportassets|vci.assets(ExportAssets)]]にもマテリアル操作系の関数がありますが、今後はExportMaterialに移行する予定ですので、こちらを優先してご使用ください。 | + | このページは過去の情報となります。\\ |
| + | 新しいスクリプトリファレンスは**[[https://developer.virtualcast.jp/vci-docs/api/|こちら]]**になります。 | ||
| + | </WRAP> | ||
| + | **ExportMaterial**は[[vci/script/reference/exportassets]]の中にあるマテリアル制御系の関数の後に追加されました。\\ | ||
| + | 現在はこちらのページの関数が推奨です。 | ||
| - | ===== メソッド一覧 ===== | ||
| - | **メソッド一覧は[EmbeddedScriptWorkspace]フォルダ内の[types.lua]を開くと最新のメソッド一覧を確認できます。** | + | ^ExportAssets^^^ |
| + | ^ 名前 ^ 説明 ^ バージョン ^ | ||
| + | |[[vci/script/reference/exportassets/material#material]]| VCI内のObjectを取得 | | | ||
| + | ^ExportMaterial^^^ | ||
| + | ^ 名前 ^ 説明 ^ バージョン ^ | ||
| + | |[[vci/script/reference/exportassets/material#GetNames]]| マテリアル名の一覧を取得| | | ||
| + | |[[vci/script/reference/exportassets/material#GetColorFromIndex]]| 番号を指定してColorを取得| | | ||
| + | |[[vci/script/reference/exportassets/material#GetColor]]| 名前を指定してColorを取得| | | ||
| + | |[[vci/script/reference/exportassets/material#GetEmissionColorFromIndex]]| 番号を指定してEmissionColorを取得| | | ||
| + | |[[vci/script/reference/exportassets/material#GetEmissionColor]]| 名前を指定してEmissionColorを取得| | | ||
| + | |[[vci/script/reference/exportassets/material#GetTextureOffsetFromIndex]]| 番号を指定してTextureOffsetを取得| | | ||
| + | |[[vci/script/reference/exportassets/material#GetTextureOffset]]| 名前を指定してTextureOffsetを取得| | | ||
| + | |[[vci/script/reference/exportassets/material#SetColorFromIndex]]| 番号を指定してColorを設定| | | ||
| + | |[[vci/script/reference/exportassets/material#SetColor]]| 名前を指定してColorを設定| | | ||
| + | |[[vci/script/reference/exportassets/material#SetEmissionColorFromIndex]]| 番号を指定してEmissionColorを設定| | | ||
| + | |[[vci/script/reference/exportassets/material#SetEmissionColor]]| 名前を指定してEmissionColorを設定| | | ||
| + | |[[vci/script/reference/exportassets/material#SetTextureOffsetFromIndex]]| 番号を指定してTextureOffsetを設定| | | ||
| + | |[[vci/script/reference/exportassets/material#SetTextureOffset]]| 名前を指定してTextureOffsetを設定| | | ||
| + | |[[vci/script/reference/exportassets/material#SetTextureFromIndex]]| 番号を指定してTextureを設定| | | ||
| + | |[[vci/script/reference/exportassets/material#SetTexture]]| 名前を指定してTextureを設定| | | ||
| + | |[[vci/script/reference/exportassets/material#ResetFromIndex]]| 番号を指定して初期状態にリセット| | | ||
| + | |[[vci/script/reference/exportassets/material#Reset]]| 名前を指定して初期状態にリセット| | | ||
| - | ^ メソッド名 ^ 説明 ^ | ||
| - | |GetNames: fun(): usertype| マテリアル名の一覧を取得します。| | ||
| - | |GetColorFromIndex: fun(index: number): Color| 番号を指定してColorを取得します。| | ||
| - | |GetColor: fun(name: string): Color| 名前を指定してColorを取得します。| | ||
| - | |GetEmissionColorFromIndex: fun(index: number): Color| 番号を指定してEmissionColorを取得します。| | ||
| - | |GetEmissionColor: fun(name: string): Color| 名前を指定してEmissionColorを取得します。| | ||
| - | |GetTextureOffsetFromIndex: fun(index: number): Vector2| 番号を指定してTextureOffsetを取得します。| | ||
| - | |GetTextureOffset: fun(name: string): Vector2| 名前を指定してTextureOffsetを取得します。| | ||
| - | |SetColorFromIndex: fun(index: number, color: Color)| 番号を指定してColorを設定します。| | ||
| - | |SetColor: fun(name: string, color: Color) fun(name: string): Vector2| 名前を指定してColorを設定します。| | ||
| - | |SetEmissionColorFromIndex: fun(index: number, color: Color)| 番号を指定してEmissionColorを設定します。| | ||
| - | |SetEmissionColor: fun(name: string, color: Color)| 名前を指定してEmissionColorを設定します。| | ||
| - | |SetTextureOffsetFromIndex: fun(index: number, offset: Vector2)| 名前を指定してTextureOffsetを取得します。| | ||
| - | |SetTextureOffset: fun(name: string, offset: Vector2)| 番号を指定してTextureOffsetを設定します。| | ||
| - | |ResetFromIndex: fun(index: number)| 番号を指定して初期状態にリセットします。| | ||
| - | |Reset: fun(name: string)| 名前を指定して初期状態にリセットします。| | ||
| - | ''_ALL_''を含むメソッド(他のクライアントでも実行されます) | + | ''_ALL_'' を含む関数は、他のクライアントでも実行され同期します。 |
| + | 全てのクライアントで同じ結果になってほしい場合は ''_ALL_'' を含む関数を使用してください。 | ||
| + | <code> | ||
| + | SetColor | ||
| + | _ALL_SetColor | ||
| + | </code> | ||
| + | |||
| + | ===== material ===== | ||
| + | <wrap em>ExportAssets.</wrap>** material ExportMaterial **\\ | ||
| + | |||
| + | VCI内のObjectを取得します。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | local Material = vci.assets.material | ||
| + | function onUse(use) | ||
| + | print(Material.GetColor("CubeColor")) | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | RGBA(1.000, 1.000, 1.000, 1.000) | ||
| + | </code> | ||
| + | |||
| + | |||
| + | |||
| + | ===== GetNames ===== | ||
| + | <wrap em>ExportMaterial.</wrap>**GetNames: fun(): usertype** | ||
| + | |||
| + | マテリアル名の一覧を取得します。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | for key, value in pairs(vci.assets.material.GetNames()) do | ||
| + | print(key.. ' = ' ..value) | ||
| + | end | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | "1 = Default-Material" | ||
| + | "2 = Cube-Material" | ||
| + | "3 = Test-Material" | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ===== GetColorFromIndex ===== | ||
| + | **GetColorFromIndex: fun(index: number): Color** | ||
| + | |||
| + | 番号を指定してColorを取得します。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | print(vci.assets.material.GetColorFromIndex(1)) | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | RGBA(0.500, 0.500, 0.500, 1.000) | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ===== GetColor ===== | ||
| + | |||
| + | **GetColor: fun(name: string): Color** | ||
| + | |||
| + | 名前を指定してColorを取得します。 | ||
| + | |||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | print(vci.assets.material.GetColor("Cube-Material")) | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | RGBA(0.500, 0.500, 0.500, 1.000) | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ===== GetEmissionColorFromIndex ===== | ||
| + | |||
| + | **GetEmissionColorFromIndex: fun(index: number): Color** | ||
| + | |||
| + | 番号を指定してEmissionColorを取得します。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | print(vci.assets.material.GetEmissionColorFromIndex(1)) | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | RGBA(0.000, 0.000, 0.000, 1.000) | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ===== GetEmissionColor ===== | ||
| + | **GetEmissionColor: fun(name: string): Color** | ||
| + | |||
| + | 名前を指定してEmissionColorを取得します。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | print(vci.assets.material.GetEmissionColor("Cube-Material")) | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | RGBA(0.000, 0.000, 0.000, 1.000) | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ===== GetTextureOffsetFromIndex ===== | ||
| + | **GetTextureOffsetFromIndex: fun(index: number): Vector2** | ||
| + | |||
| + | 番号を指定してTextureOffsetを取得します。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | print(vci.assets.material.GetTextureOffsetFromIndex(1)) | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | (0.0, 0.0) | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ===== GetTextureOffset ===== | ||
| + | **GetTextureOffset: fun(name: string): Vector2** | ||
| + | |||
| + | 名前を指定してTextureOffsetを取得します。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | print(vci.assets.material.GetTextureOffset("Cube-Material")) | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | (0.0, 0.0) | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ===== SetColorFromIndex ===== | ||
| + | **SetColorFromIndex: fun(index: number, color: Color)**\\ | ||
| + | **_ALL_SetColorFromIndex: fun(index: number, color: Color)** | ||
| + | |||
| + | 番号を指定してColorを設定します。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | vci.assets.material.SetColorFromIndex(1, Color.red) | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | index番号1番のマテリアルのColorを赤に設定します。 | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ===== SetColor ===== | ||
| + | **SetColor: fun(name: string, color: Color) fun(name: string): Vector2**\\ | ||
| + | **_ALL_SetColor: fun(name: string, color: Color) fun(name: string): Vector2** | ||
| + | |||
| + | 名前を指定してColorを設定します。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | vci.assets.material.SetColor("Cube-Material", Color.blue) | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | マテリアル名がCube-MaterialのColorを青に設定します。 | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ===== SetEmissionColorFromIndex ===== | ||
| + | **SetEmissionColorFromIndex: fun(index: number, color: Color)**\\ | ||
| + | **_ALL_SetEmissionColorFromIndex: fun(index: number, color: Color)** | ||
| + | |||
| + | 番号を指定してEmissionColorを設定します。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | vci.assets.material.SetEmissionColorFromIndex(1, Color.red) | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | index番号1番のマテリアルのEmissionColorを赤に設定します。 | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ===== SetEmissionColor ===== | ||
| + | **SetEmissionColor: fun(name: string, color: Color)**\\ | ||
| + | **_ALL_SetEmissionColor: fun(name: string, color: Color)** | ||
| + | |||
| + | 名前を指定してEmissionColorを設定します。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | vci.assets.material.SetEmissionColor("Cube-Material", Color.blue) | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | マテリアル名がCube-MaterialのEmissionColorを青に設定します。 | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ===== SetTextureOffsetFromIndex ===== | ||
| + | **SetTextureOffsetFromIndex: fun(index: number, offset: Vector2)**\\ | ||
| + | **_ALL_SetTextureOffsetFromIndex: fun(index: number, offset: Vector2)** | ||
| + | |||
| + | 番号を指定してTextureOffsetを設定します。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | if count == 9 then | ||
| + | count = 0 | ||
| + | else | ||
| + | count = count + 1 | ||
| + | end | ||
| + | SetCounterOffset(count) | ||
| + | end | ||
| + | |||
| + | function SetCounterOffset(count) | ||
| + | local offset = Vector2.zero | ||
| + | |||
| + | -- y shift | ||
| + | local Yshift = math.floor(count / 4) | ||
| + | offset.y = -0.25 * Yshift | ||
| + | |||
| + | -- x shift | ||
| + | local Xshift = count % 4 | ||
| + | offset.x = 0.25 * Xshift | ||
| + | |||
| + | vci.assets.material.SetTextureOffsetFromIndex(1, offset) | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | クリックするごとにTextureOffsetをずらします。サンプルでは4*4枚の画像まで使用できますが、10枚だけ使用しています。 | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ===== SetTextureOffset ===== | ||
| + | **SetTextureOffset: fun(name: string, offset: Vector2)**\\ | ||
| + | **_ALL_SetTextureOffset: fun(name: string, offset: Vector2)** | ||
| + | |||
| + | 名前を指定してTextureOffsetを設定します。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | local offset = Vector2.zero | ||
| + | offset.y = -0.25 | ||
| + | offset.x = 0.25 * Xshift | ||
| + | vci.assets.material.SetTextureOffset("PlaneMaterial", offset) | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | マテリアル名が"PlaneMaterial"であるTextureのOffsetを(0.25, -0.25)に設定しています。 | ||
| + | </code> | ||
| + | |||
| + | |||
| + | |||
| + | ===== SetTextureFromIndex ===== | ||
| + | **SetTextureFromIndex: fun(index: number, textureId: string)**\\ | ||
| + | **_ALL_SetTextureFromIndex: fun(index: number, textureId: string)** | ||
| + | |||
| + | 番号 ''index'' を指定したマテリアルに対して、指定のテクスチャ ''textureId'' を適用します。 | ||
| + | |||
| + | 詳しい説明は [[vci:script:reference:exportassets:material#SetTexture()|SetTexture]] をご覧ください。 | ||
| + | |||
| + | |||
| + | ===== SetTexture ===== | ||
| + | **SetTexture: fun(name: string, textureId: string)**\\ | ||
| + | **_ALL_SetTexture: fun(name: string, textureId: string)** | ||
| + | |||
| + | 名前 ''name'' を指定したマテリアルに対して、指定のテクスチャ ''textureId'' を適用します。 | ||
| + | |||
| + | ^ テクスチャ ID ^ 説明 ^ | ||
| + | | ''_SYS_NULL'' | テクスチャの指定が空の状態 | | ||
| + | | ''_SYS_DEFAULT'' | このマテリアルのデフォルトのテクスチャ | | ||
| + | | [[vci:script:reference:exportphotographycamera#getcamerapreviewtexture|GetCameraPreviewTextureで得られるID]] | 写真撮影用カメラのプレビューテクスチャ | | ||
| + | | [[vci:script:reference:exportphotographycamera#setontakephotocallback|SetOnTakePhotoCallbackで得られるID]] | 写真撮影用カメラの写真テクスチャ | | ||
| + | |||
| + | === サンプル === | ||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | -- Use するとテクスチャが無くなる | ||
| + | vci.assets.material.SetTexture("PlaneMaterial", "_SYS_NULL") | ||
| + | end | ||
| + | |||
| + | function onUnuse(use) | ||
| + | -- Unuse するとテクスチャがデフォルトに戻る | ||
| + | vci.assets.material.SetTexture("PlaneMaterial", "_SYS_DEFAULT") | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | ===== ResetFromIndex() ===== | ||
| + | **ResetFromIndex: fun(index: number)**\\ | ||
| + | **_ALL_ResetFromIndex: fun(index: number)** | ||
| + | |||
| + | 番号を指定して初期状態にリセットします。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | vci.assets.material.ResetFromIndex(1) | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | index番号1番のマテリアルを初期状態にします。 | ||
| + | </code> | ||
| + | |||
| + | |||
| + | |||
| + | ===== Reset ===== | ||
| + | **Reset: fun(name: string)**\\ | ||
| + | **_ALL_Reset: fun(name: string)** | ||
| + | |||
| + | 名前を指定して初期状態にリセットします。 | ||
| + | |||
| + | === サンプル === | ||
| + | |||
| + | <file lua main.lua> | ||
| + | function onUse(use) | ||
| + | vci.assets.material.Reset("Cube-Material") | ||
| + | end | ||
| + | </file> | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | <code lua> | ||
| + | マテリアル名が"Cube-Material"のマテリアルを初期状態にします。 | ||
| + | </code> | ||
| - | ^ メソッド名 ^ 説明 ^ | ||
| - | |_ALL_SetColorFromIndex: fun(index: number, color: Color)| 番号を指定してColorを設定します。| | ||
| - | |_ALL_SetColor: fun(name: string, color: Color) fun(name: string): Vector2| 名前を指定してColorを設定します。| | ||
| - | |_ALL_SetEmissionColorFromIndex: fun(index: number, color: Color)| 番号を指定してEmissionColorを設定します。| | ||
| - | |_ALL_SetEmissionColor: fun(name: string, color: Color)| 名前を指定してEmissionColorを設定します。| | ||
| - | |_ALL_SetTextureOffsetFromIndex: fun(index: number, offset: Vector2)| 名前を指定してTextureOffsetを取得します。| | ||
| - | |_ALL_SetTextureOffset: fun(name: string, offset: Vector2)| 番号を指定してTextureOffsetを設定します。| | ||
| - | |_ALL_ResetFromIndex: fun(index: number)| 番号を指定して初期状態にリセットします。| | ||
| - | |_ALL_Reset: fun(name: string)| 名前を指定して初期状態にリセットします。| | ||