summaryrefslogtreecommitdiff
path: root/Runtime/Export/AndroidJava.txt
blob: ab2c9f54d5c1fb1cd624d742ea8afa00dd6e1abe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
C++RAW


#include "UnityPrefix.h"
#include "Runtime/Scripting/ScriptingUtility.h"
#include "Runtime/Mono/MonoBehaviour.h"

CSRAW
#if UNITY_EDITOR || UNITY_ANDROID
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace UnityEngine
{

// AndroidJavaObject is the Unity representation of a generic instance of java.lang.Object.
NONSEALED_CLASS AndroidJavaObject : IDisposable

	// Construct an AndroidJavaObject based on the name of the class.
	CSRAW public AndroidJavaObject(string className, params object[] args) : this()
	{
		_AndroidJavaObject(className, args);
	}

	// IDisposable callback
	CSRAW public void Dispose()
	{
		_Dispose();
	}

	//===================================================================

	// Calls a Java method on an object (non-static).
	CSRAW public void Call(string methodName, params object[] args)
	{
		_Call(methodName, args);
	}

	//===================================================================

	// Call a static Java method on a class.
	CSRAW public void CallStatic(string methodName, params object[] args)
	{
		_CallStatic(methodName, args);
	}

	//===================================================================

	// Get the value of a field in an object (non-static).
	CSRAW public FieldType Get<FieldType>(string fieldName)
	{
		return _Get<FieldType>(fieldName);
	}


	// Set the value of a field in an object (non-static).
	CSRAW public void Set<FieldType>(string fieldName, FieldType val)
	{
		_Set<FieldType>(fieldName, val);
	}


	//===================================================================

	// Get the value of a static field in an object type.
	CSRAW public FieldType GetStatic<FieldType>(string fieldName)
	{
		return _GetStatic<FieldType>(fieldName);
	}


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


	//===================================================================

	// Retrieve the <i>raw</i> jobject pointer to the Java object.
	CSRAW public IntPtr GetRawObject() { return _GetRawObject(); }
	// Retrieve the <i>raw</i> jclass pointer to the Java class;
	CSRAW public IntPtr GetRawClass() { return _GetRawClass(); }

	//===================================================================

	// Call a Java method on an object.
	CSRAW public ReturnType Call<ReturnType>(string methodName, params object[] args)
	{
		return _Call<ReturnType>(methodName, args);
	}

	// Call a static Java method on a class.
	CSRAW public ReturnType CallStatic<ReturnType>(string methodName, params object[] args)
	{
		return _CallStatic<ReturnType>(methodName, args);
	}
END

// AndroidJavaClass is the Unity representation of a generic instance of java.lang.Class
NONSEALED_CLASS AndroidJavaClass : AndroidJavaObject

	// Construct an AndroidJavaClass from the class name
	CSRAW public AndroidJavaClass(string className) : base()
	{
		_AndroidJavaClass(className);
	}
END

CSRAW
}
#endif