Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Get(fieldName: string): FieldType;
FieldType Get(string fieldName);
def Get(fieldName as string) as FieldType

Parameters

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

Description

Get the value of a field in an object (non-static).

The generic parameter determines the field type.

	// Create a android.os.Message object, and retrieve the default value of the field 'what'.
	function Start() {
		var jo = new AndroidJavaObject("android.os.Message");
		var valueString = jo.Get.<int>("what");
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Start() {
        AndroidJavaObject jo = new AndroidJavaObject("android.os.Message");
        int valueString = jo.Get<int>("what");
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Start() as void:
		jo as AndroidJavaObject = AndroidJavaObject('android.os.Message')
		valueString as int = jo.Get[of int]('what')