質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Objective-C

Objective-Cはオブジェクト指向型のプログラミング言語のひとつです。C言語をベースにSmalltalkが取り入れられています。

C#

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

Q&A

0回答

2045閲覧

UnitySendMessageのオブジェクト/メソッド名を直打ちしたくない

nakamu

総合スコア82

Objective-C

Objective-Cはオブジェクト指向型のプログラミング言語のひとつです。C言語をベースにSmalltalkが取り入れられています。

C#

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

0グッド

0クリップ

投稿2020/02/06 11:35

安心安全にUnitySendMessageを使う【Unity】【iOS】

こちらを参考に作りましたが、object not found状態です。
また、オブジェクトの部分のみ直打ちし
下記を追加したところ画像のように返ってきました。
import <Foundation/Foundation.h>
import <UIKit/UIKit.h>
イメージ説明

C#

1using System; 2using System.Collections; 3using System.Collections.Generic; 4using UnityEngine; 5using System.Runtime.InteropServices; 6 7public class ShowActionSheet : MonoBehaviour 8{ 9 10 [DllImport("__Internal")] 11 private static extern void showActionSheet(string gameObjectName, string callbackMethodName); 12 13 // Start is called before the first frame update 14 void Start() 15 { 16 17 } 18 19 // Update is called once per frame 20 void Update() 21 { 22 23 } 24 25 //ネイティブ側から実行されるコールバック 26 void Callback(string message) { 27 Debug.Log("こんにちは"); 28 Debug.Log(message); 29 } 30 31 public void OnClick() 32 { 33#if UNITY_IOS 34 Debug.Log("テストテスト"); 35 Debug.Log(gameObject.name); 36 Debug.Log("こんにちは"); 37 showActionSheet(gameObject.name, nameof(Callback)); 38#endif 39 } 40}

ObjectiveC

1extern "C" { 2 void showActionSheet(const char *gameObjectName, const char *callbackMethodName) { 3 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; 4 5 [alertController addAction:[UIAlertAction actionWithTitle:@"新規登録" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 6 UnitySendMessage(gameObjectName, callbackMethodName, "新規登録"); 7 }]]; 8 9 [alertController addAction:[UIAlertAction actionWithTitle:@"ログイン" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 10 UnitySendMessage(gameObjectName, callbackMethodName, "ログイン"); 11 }]]; 12 13 [alertController addAction:[UIAlertAction actionWithTitle:@"キャンセル" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { 14 UnitySendMessage(gameObjectName, callbackMethodName, "キャンセル"); 15 }]]; 16 17 [UnityGetGLViewController() presentViewController:alertController animated:YES completion:nil]; 18 } 19} 20

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問