# GetFieldID

> Scans a particular Java class for a field matching a name and a signature.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.AndroidJNIModule

## GetFieldID(IntPtr, string)

Scans a particular Java class for a field matching a name and a signature.

```csharp
public static nint GetFieldID(nint javaClass, string fieldName)
```

### Parameters

**** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): Raw JNI Java class object (obtained by calling AndroidJNI.FindClass).**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the field as declared in Java.

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.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.

Additional Resources: [AndroidJNIHelper.GetSignature](/engine/6000.7/script-reference/unityengine/androidjnihelper/getsignature.md), [AndroidJNIHelper.GetConstructorID](/engine/6000.7/script-reference/unityengine/androidjnihelper/getconstructorid.md), [AndroidJNIHelper.GetMethodID](/engine/6000.7/script-reference/unityengine/androidjnihelper/getmethodid.md)

## GetFieldID(IntPtr, string, string)

Scans a particular Java class for a field matching a name and a signature.

```csharp
public static nint GetFieldID(nint javaClass, string fieldName, string signature)
```

### Parameters

**** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): Raw JNI Java class object (obtained by calling AndroidJNI.FindClass).**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the field as declared in Java.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Field signature (e.g. obtained by calling AndroidJNIHelper.GetSignature).

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.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.

Additional Resources: [AndroidJNIHelper.GetSignature](/engine/6000.7/script-reference/unityengine/androidjnihelper/getsignature.md), [AndroidJNIHelper.GetConstructorID](/engine/6000.7/script-reference/unityengine/androidjnihelper/getconstructorid.md), [AndroidJNIHelper.GetMethodID](/engine/6000.7/script-reference/unityengine/androidjnihelper/getmethodid.md)

## GetFieldID(IntPtr, string, string, bool)

Scans a particular Java class for a field matching a name and a signature.

```csharp
public static nint GetFieldID(nint javaClass, string fieldName, string signature, bool isStatic)
```

### Parameters

**** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): Raw JNI Java class object (obtained by calling AndroidJNI.FindClass).**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the field as declared in Java.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Field signature (e.g. obtained by calling AndroidJNIHelper.GetSignature).**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Set to \\\<tt\\>true\\\</tt\\> for static fields; \\\<tt\\>false\\\</tt\\> for instance (nonstatic) fields.

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.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.

Additional Resources: [AndroidJNIHelper.GetSignature](/engine/6000.7/script-reference/unityengine/androidjnihelper/getsignature.md), [AndroidJNIHelper.GetConstructorID](/engine/6000.7/script-reference/unityengine/androidjnihelper/getconstructorid.md), [AndroidJNIHelper.GetMethodID](/engine/6000.7/script-reference/unityengine/androidjnihelper/getmethodid.md)

## GetFieldID\<T>(IntPtr, string, bool)

Get a JNI field ID based on type detection. Generic parameter represents the field type.

```csharp
public static nint GetFieldID<FieldType>(nint jclass, string fieldName, bool isStatic)
```

### Parameters

**** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): **** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the field as declared in Java.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Set to \\\<tt\\>true\\\</tt\\> for static fields; \\\<tt\\>false\\\</tt\\> for instance (nonstatic) fields.

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.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.
