あなたの世界を作りなさい
ユーザーインターフェース
触覚振動を使用
4分
このガイドでは、zepetoscripでハプティックバイブレーションを実装する方法を示します。 handheld vibrate 関数はunityによって提供されています。 📘 handheld https //docs unity3d com/scriptreference/handheld html https //docs unity3d com/scriptreference/handheld html スクリプトを書く 1\) \[プロジェクト]パネルで、左上隅の\[+]メニューを選択するか、assets > create > zepeto > typescriptを選択します。 2\) 追加したスクリプトにhapticvibrationという名前を付け、以下のようなサンプルスクリプトを書きます。 import { zepetoscriptbehaviour } from 'zepeto script'; import { button } from 'unityengine ui'; import { handheld } from 'unityengine'; export default class hapticvibration extends zepetoscriptbehaviour { public vibrationbutton button; start() { this vibrationbutton onclick addlistener(() => { handheld vibrate(); }); } } 3\) シーンにgameobjectを追加し、hapticfeedbackに名前を変更します。作成したhapticvibration zepetoscriptを追加します。 hierarchyウィンドウで、button uiをzepetoscript inspectorウィンドウに表示されているプロパティにドラッグ&ドロップします。 モバイルでのテスト 1\) qrモバイルテストで例のワールドを実行します。 2\) スクリプトに接続されたボタンを押すと、デバイスが振動します。 📘 以下のガイドを参照してください。 \[ qrモバイルテスト docid\ j7528bwc6 f09umfjhjwj ] ❗️ 注意 次のことに注意してください。 handheld vibrate はモバイル環境でのみ動作します。