-1

Unity3Dでスマホアプリを作ろうとして、unityscriptを使っています。Prime31 からいくつかのプラグインを購入しましたが、それらはすべて正常に動作しますが、サンプル スクリプトは C# で記述されています。

以下の例をJSに変換したい:

var buttons = new string[] { "Save", "Cancel" };
EtceteraBinding.showAlertWithTitleMessageAndButtons( "Alert!", "Do you want to save?", buttons );

私はこのように試しました:

var buttons:String[];
buttons=["Save","Cancel"];
EtceteraBinding.showAlertWithTitleMessageAndButtons( "Alert!", "Do you want to save?", buttons );

これは良くありません。コース["Save","Cancel"]は最初のボタンに表示され、他のボタンには何も表示されませんか?

私は何を間違っていますか?

4

5 に答える 5

1

のドキュメントはありshowAlertWithTitleMessageAndButtons()ますか?

たぶんJavaScriptでは引数が異なります。たとえば、ボタンのタイトルが配列ではなく個別のパラメータとして渡される場合があります。

showAlertWithTitleMessageAndButtons("Alert", "Something", "buttonTitle1", "buttontTitle2")

于 2012-07-31T14:54:40.683 に答える
1

あなたが提供したドキュメントから外れます:

 // Shows a standard Apple alert with the given title, message and an array of buttons. At least one button must be included. 
 public static void showAlertWithTitleMessageAndButtons( string title, string message, string[] buttons )

次のものを使用できるはずです:

EtceteraBinding.showAlertWithTitleMessageAndButtons( "Alert!", "Do you want to save?", ["Save", "Cancel"]);
于 2012-07-31T15:35:29.797 に答える
0

これを試してみてください。私は Prime31 プラグインを持っています。これはうまくコンパイルできます。

var test : String[] = ["One", "Two"];
EtceteraBinding.showAlertWithTitleMessageAndButtons("Name","Stuff", test);

うまくいかない場合、Unity でどのようなエラーが発生していますか?

于 2012-08-22T01:07:45.570 に答える
-2

これはどうですか:

var buttons = new Array("Save","Cancel");
于 2012-07-31T14:52:53.430 に答える
-2

これを試して:

var buttons = new Array();
buttons.push("Save");
buttons.push("Cancel");
于 2012-07-31T14:56:20.020 に答える