привет у меня не работает данный код что нужно поменять public class NFC : MonoBehaviour…
- User
привет у меня не работает данный код что нужно поменять
public class NFC : MonoBehaviour { public string tagID; public TMP_Text tag_output_text; public TMP_Text tag_output_textTag; public bool tagFound = false;
private AndroidJavaObject mActivity; private AndroidJavaObject mIntent; private string sAction; void Start() { tag_output_text.text = "Scan a NFC tag to make the cube disappear..."; } void Update() { if (Application.platform == RuntimePlatform.Android) { tag_output_textTag.text = "1"; if (!tagFound) { tag_output_textTag.text = "2"; try { tag_output_textTag.text = "3"; // Create new NFC Android object mActivity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity"); // Activities open apps mIntent = mActivity.Call<AndroidJavaObject>("getIntent"); sAction = mIntent.Call<String>("getAction"); // resulte are returned in the Intent object if (sAction == "android.nfc.action.NDEF_DISCOVERED") { tag_output_textTag.text = "Tag of type NDEF"; } else if (sAction == "android.nfc.action.TECH_DISCOVERED") { tag_output_textTag.text = "TAG DISCOVERED"; // Get ID of tag AndroidJavaObject mNdefMessage = mIntent.Call<AndroidJavaObject>("getParcelableExtra", "android.nfc.extra.TAG"); if (mNdefMessage != null) { byte[] payLoad = mNdefMessage.Call<byte[]>("getId"); string text = System.Convert.ToBase64String(payLoad); tag_output_text.text += "This is your tag text: " + text; tagID = text; tag_output_textTag.text = tagID; } else { tag_output_text.text = "No ID found !"; } tagFound = true; // How to read multiple tags maybe with this line mIntent.Call("removeExtra", "android.nfc.extra.TAG"); return; } else if (sAction == "android.nfc.action.TAG_DISCOVERED") { tag_output_textTag.text = "This type of tag is not supported !"; } else { tag_output_text.text = "Scan a NFC tag to make the cube disappear..."; return; } } catch (Exception ex) { string text = ex.Message; tag_output_text.text = text; } } } }}
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.