Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetFieldID

Scans a particular Java class for a field matching a name and a signature.
Read time 2 minutesLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.AndroidJNIModule

GetFieldID(IntPtr, string)

Scans a particular Java class for a field matching a name and a signature.
public static nint GetFieldID(nint javaClass, string fieldName)

Parameters

javaClass

Raw JNI Java class object (obtained by calling AndroidJNI.FindClass).

fieldName

Name of the field as declared in Java.

Returns

Type

Description

IntPtr

Remarks

The signature comparison is done to allow sub-/base-classes of a class types. If no signature is provided the first field with the correct name will be returned.

GetFieldID(IntPtr, string, string)

Scans a particular Java class for a field matching a name and a signature.
public static nint GetFieldID(nint javaClass, string fieldName, string signature)

Parameters

javaClass

Raw JNI Java class object (obtained by calling AndroidJNI.FindClass).

fieldName

Name of the field as declared in Java.

signature

Field signature (e.g. obtained by calling AndroidJNIHelper.GetSignature).

Returns

Type

Description

IntPtr

Remarks

The signature comparison is done to allow sub-/base-classes of a class types. If no signature is provided the first field with the correct name will be returned.

GetFieldID(IntPtr, string, string, bool)

Scans a particular Java class for a field matching a name and a signature.
public static nint GetFieldID(nint javaClass, string fieldName, string signature, bool isStatic)

Parameters

javaClass

Raw JNI Java class object (obtained by calling AndroidJNI.FindClass).

fieldName

Name of the field as declared in Java.

signature

Field signature (e.g. obtained by calling AndroidJNIHelper.GetSignature).

isStatic

Set to \<tt\>true\</tt\> for static fields; \<tt\>false\</tt\> for instance (nonstatic) fields.

Returns

Type

Description

IntPtr

Remarks

The signature comparison is done to allow sub-/base-classes of a class types. If no signature is provided the first field with the correct name will be returned.

GetFieldID<T>(IntPtr, string, bool)

Get a JNI field ID based on type detection. Generic parameter represents the field type.
public static nint GetFieldID<FieldType>(nint jclass, string fieldName, bool isStatic)

Parameters

jclass


fieldName

Name of the field as declared in Java.

isStatic

Set to \<tt\>true\</tt\> for static fields; \<tt\>false\</tt\> for instance (nonstatic) fields.

Returns

Type

Description

IntPtr

Remarks

Scans a particular Java class for a field matching a signature of the field type. The signature comparison is done to allow for sub-/base-classes of the class types.