Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SetStatic

Set the value of a static field in an object type.
Read time 1 minuteLast updated 5 days ago

Definition

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

SetStatic<T>(string, T)

Set the value of a static field in an object type.
public void SetStatic<FieldType>(string fieldName, FieldType val)

Parameters

fieldName

The name of the field (e.g. int counter; would have fieldName = "counter").

val

T
The value to assign to the field. It has to match the field type.

Remarks

The generic parameter determines the field type.

Examples

using UnityEngine;public class Example : MonoBehaviour{ // Create an object of user provided class org.example.StaticFields, // and set the value of field 'globalName'. void Start() { AndroidJavaObject javaObject = new AndroidJavaObject("org.example.StaticFields"); javaObject.Set<string>("globalName", "this_is_the_name"); }}

SetStatic<T>(IntPtr, T)

Set the value of a static field in an object type.
public void SetStatic<FieldType>(IntPtr fieldID, FieldType val)

Parameters

fieldID

The ID of the field to set.

val

T
The value to assign to the field. It has to match the field type.

Remarks

The generic parameter determines the field type.