UnityInterface.h
15.6 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
#pragma once
#include <stdint.h>
#include <stdarg.h>
#include "UnityForwardDecls.h"
#include "UnityRendering.h"
// unity plugin functions
// audio plugin api
typedef int (*UnityPluginGetAudioEffectDefinitionsFunc)(struct UnityAudioEffectDefinition*** descptr);
// OLD rendering plugin api (will become obsolete soon)
typedef void (*UnityPluginSetGraphicsDeviceFunc)(void* device, int deviceType, int eventType);
typedef void (*UnityPluginRenderMarkerFunc)(int marker);
// new rendering plugin api
typedef void (*UnityPluginLoadFunc)(struct IUnityInterfaces* unityInterfaces);
typedef void (*UnityPluginUnloadFunc)();
// log handler function
#ifdef __cplusplus
typedef bool (*LogEntryHandler)(LogType logType, const char* log, va_list list);
#endif
//
// these are functions referenced in trampoline and implemented in unity player lib
//
#ifdef __cplusplus
extern "C" {
#endif
// life cycle management
void UnityInitRuntime(int argc, char* argv[]);
void UnityInitApplicationNoGraphics(const char* appPathName);
void UnityUnloadApplication();
void UnityQuitApplication(int exitCode);
void UnityInitApplicationGraphics();
void UnityCleanup();
void UnityLoadApplication();
void UnityLoadApplicationFromSceneLessState();
void UnityPlayerLoop(); // normal player loop
void UnityBatchPlayerLoop(); // batch mode like player loop, without rendering (usable for background processing)
void UnitySetPlayerFocus(int focused); // send OnApplicationFocus() message to scripts
void UnityLowMemory();
void UnityPause(int pause);
int UnityIsPaused(); // 0 if player is running, 1 if paused
void UnityWillPause(); // send the message that app will pause
void UnityWillResume(); // send the message that app will resume
void UnityInputProcess();
void UnityDeliverUIEvents(); // unity processing impacting UI will be called in there
// rendering
int UnityGetRenderingAPIs(int capacity, int* outAPIs);
void UnityFinishRendering();
// OpenGL ES.
int UnityHasRenderingAPIExtension(const char* extension);
void UnityOnSetCurrentGLContext(EAGLContext* context);
// This must match the one in ApiEnumsGLES.h
typedef enum UnityFramebufferTarget
{
kDrawFramebuffer = 0,
kReadFramebuffer,
kFramebufferTargetCount
} UnityFramebufferTarget;
void UnityBindFramebuffer(UnityFramebufferTarget target, int fbo);
void UnityRegisterFBO(UnityRenderBufferHandle color, UnityRenderBufferHandle depth, unsigned fbo);
// when texture (managed in trampoline) is used in unity (e.g. with external render surfaces)
// we need to poke unity when we delete it (so it could clear caches etc)
void UnityOnDeleteGLTexture(int tex);
// controling player internals
// TODO: needs some cleanup
void UnitySetAudioSessionActive(int active);
void UnityGLInvalidateState();
void UnityReloadResources();
int UnityIsCaptureScreenshotRequested();
void UnityCaptureScreenshot();
void UnitySendMessage(const char* obj, const char* method, const char* msg);
void UnityUpdateMuteState(int mute);
void UnityUpdateAudioOutputState();
EAGLContext* UnityGetDataContextGLES();
#ifdef __cplusplus
void UnitySetLogEntryHandler(LogEntryHandler newHandler);
#endif
// plugins support
// WARNING: old UnityRegisterRenderingPlugin will become obsolete soon
void UnityRegisterRenderingPlugin(UnityPluginSetGraphicsDeviceFunc setDevice, UnityPluginRenderMarkerFunc renderMarker);
void UnityRegisterRenderingPluginV5(UnityPluginLoadFunc loadPlugin, UnityPluginUnloadFunc unloadPlugin);
void UnityRegisterAudioPlugin(UnityPluginGetAudioEffectDefinitionsFunc getAudioEffectDefinitions);
// resolution/orientation handling
void UnityGetRenderingResolution(unsigned* w, unsigned* h);
void UnityGetSystemResolution(unsigned* w, unsigned* h);
void UnityRequestRenderingResolution(unsigned w, unsigned h);
int UnityIsOrientationEnabled(unsigned /*ScreenOrientation*/ orientation);
int UnityHasOrientationRequest();
int UnityShouldAutorotate();
int UnityShouldChangeAllowedOrientations();
int UnityRequestedScreenOrientation(); // returns ScreenOrientation
void UnityOrientationRequestWasCommitted();
int UnityReportResizeView(unsigned w, unsigned h, unsigned /*ScreenOrientation*/ contentOrientation); // returns ScreenOrientation
void UnityReportSafeAreaChange(float x, float y, float w, float h);
void UnityReportBackbufferChange(UnityRenderBufferHandle colorBB, UnityRenderBufferHandle depthBB);
float UnityCalculateScalingFactorFromTargetDPI(UIScreen* screen);
void UnityReportDisplayCutouts(const float* x, const float* y, const float* width, const float* height, int count);
// player settings
int UnityDisableDepthAndStencilBuffers();
int UnityUseAnimatedAutorotation();
int UnityGetDesiredMSAASampleCount(int defaultSampleCount);
int UnityGetSRGBRequested();
int UnityGetWideColorRequested();
int UnityGetShowActivityIndicatorOnLoading();
int UnityGetAccelerometerFrequency();
int UnityGetTargetFPS();
int UnityGetUseCustomAppBackgroundBehavior();
int UnityGetDeferSystemGesturesTopEdge();
int UnityGetDeferSystemGesturesBottomEdge();
int UnityGetDeferSystemGesturesLeftEdge();
int UnityGetDeferSystemGesturesRightEdge();
int UnityGetHideHomeButton();
int UnityMetalFramebufferOnly();
int UnityMetalMemorylessDepth();
int UnityPreserveFramebufferAlpha();
void UnitySetAbsoluteURL(const char* url);
// push notifications
#if !PLATFORM_TVOS
void UnitySendLocalNotification(UILocalNotification* notification);
#endif
void UnitySendRemoteNotification(NSDictionary* notification);
void UnitySendDeviceToken(NSData* deviceToken);
void UnitySendRemoteNotificationError(NSError* error);
// native events
void UnityInvalidateDisplayDataCache(void* screen);
void UnityUpdateDisplayListCache(void** screens, int screenCount);
// profiler
void* UnityCreateProfilerCounter(const char*);
void UnityDestroyProfilerCounter(void*);
void UnityStartProfilerCounter(void*);
void UnityEndProfilerCounter(void*);
// sensors
void UnitySensorsSetGyroRotationRate(int idx, float x, float y, float z);
void UnitySensorsSetGyroRotationRateUnbiased(int idx, float x, float y, float z);
void UnitySensorsSetGravity(int idx, float x, float y, float z);
void UnitySensorsSetUserAcceleration(int idx, float x, float y, float z);
void UnitySensorsSetAttitude(int idx, float x, float y, float z, float w);
void UnityDidAccelerate(float x, float y, float z, double timestamp);
void UnitySetJoystickPosition(int joyNum, int axis, float pos);
int UnityStringToKey(const char *name);
void UnitySetKeyState(int key, int /*bool*/ state);
void UnitySetKeyboardKeyState(int key, int /*bool*/ state);
void UnitySendKeyboardCommand(UIKeyCommand* command);
// WWW connection handling
void UnityReportWebRequestStatus(void* udata, int status);
void UnityReportWebRequestNetworkError(void* udata, int status);
void UnityReportWebRequestResponseHeader(void* udata, const char* headerName, const char* headerValue);
void UnityReportWebRequestReceivedResponse(void* udata, unsigned expectedDataLength);
void UnityReportWebRequestReceivedData(void* udata, const void* buffer, unsigned totalRead, unsigned expectedTotal);
void UnityReportWebRequestFinishedLoadingData(void* udata);
void UnityReportWebRequestSentData(void* udata, unsigned totalWritten, unsigned expectedTotal);
int UnityReportWebRequestValidateCertificate(void* udata, const void* certificateData, unsigned certificateSize);
const void* UnityWebRequestGetUploadData(void* udata, unsigned* bufferSize);
void UnityWebRequestConsumeUploadData(void* udata, unsigned consumedSize);
// AVCapture
void UnityReportAVCapturePermission();
void UnityDidCaptureVideoFrame(intptr_t tex, void* udata);
// logging override
#ifdef __cplusplus
} // extern "C"
#endif
// touches processing
#ifdef __cplusplus
extern "C" {
#endif
void UnitySetViewTouchProcessing(UIView* view, int /*ViewTouchProcessing*/ processingPolicy);
void UnityDropViewTouchProcessing(UIView* view);
void UnitySendTouchesBegin(NSSet* touches, UIEvent* event);
void UnitySendTouchesEnded(NSSet* touches, UIEvent* event);
void UnitySendTouchesCancelled(NSSet* touches, UIEvent* event);
void UnitySendTouchesMoved(NSSet* touches, UIEvent* event);
void UnityCancelTouches();
#ifdef __cplusplus
} // extern "C"
#endif
//
// these are functions referenced and implemented in trampoline
//
#ifdef __cplusplus
extern "C" {
#endif
// UnityAppController.mm
UIViewController* UnityGetGLViewController();
UIView* UnityGetGLView();
UIWindow* UnityGetMainWindow();
enum ScreenOrientation UnityCurrentOrientation();
// Unity/DisplayManager.mm
float UnityScreenScaleFactor(UIScreen* screen);
#ifdef __cplusplus
} // extern "C"
#endif
//
// these are functions referenced in unity player lib and implemented in trampoline
//
#ifdef __cplusplus
extern "C" {
#endif
// iPhone_Sensors.mm
void UnityInitJoysticks();
void UnityCoreMotionStart();
void UnityCoreMotionStop();
void UnityUpdateAccelerometerData();
int UnityIsGyroEnabled(int idx);
int UnityIsGyroAvailable();
void UnityUpdateGyroData();
void UnitySetGyroUpdateInterval(int idx, float interval);
float UnityGetGyroUpdateInterval(int idx);
void UnityUpdateJoystickData();
NSArray* UnityGetJoystickNames();
void UnityGetJoystickAxisName(int idx, int axis, char* buffer, int maxLen);
void UnityGetNiceKeyname(int key, char* buffer, int maxLen);
// UnityAppController+Rendering.mm
void UnityInitMainScreenRenderingCallback();
void UnityGfxInitedCallback();
void UnityPresentContextCallback(struct UnityFrameStats const* frameStats);
void UnityFramerateChangeCallback(int targetFPS);
int UnitySelectedRenderingAPI();
NSBundle* UnityGetMetalBundle();
MTLDeviceRef UnityGetMetalDevice();
MTLCommandQueueRef UnityGetMetalCommandQueue();
MTLCommandQueueRef UnityGetMetalDrawableCommandQueue();
int UnityCommandQueueMaxCommandBufferCountMTL();
EAGLContext* UnityGetDataContextEAGL();
UnityRenderBufferHandle UnityBackbufferColor();
UnityRenderBufferHandle UnityBackbufferDepth();
int UnityIsWideColorSupported();
// UI/ActivityIndicator.mm
void UnityStartActivityIndicator();
void UnityStopActivityIndicator();
// UI/Keyboard.mm
void UnityKeyboard_Create(unsigned keyboardType, int autocorrection, int multiline, int secure, int alert, const char* text, const char* placeholder, int characterLimit);
void UnityKeyboard_Show();
void UnityKeyboard_Hide();
void UnityKeyboard_GetRect(float* x, float* y, float* w, float* h);
void UnityKeyboard_SetText(const char* text);
NSString* UnityKeyboard_GetText();
int UnityKeyboard_IsActive();
int UnityKeyboard_Status();
void UnityKeyboard_SetInputHidden(int hidden);
int UnityKeyboard_IsInputHidden();
void UnityKeyboard_SetCharacterLimit(unsigned characterLimit);
int UnityKeyboard_CanGetSelection();
void UnityKeyboard_GetSelection(int* location, int* range);
int UnityKeyboard_CanSetSelection();
void UnityKeyboard_SetSelection(int location, int range);
// UI/UnityViewControllerBase.mm
void UnityNotifyHideHomeButtonChange();
void UnityNotifyDeferSystemGesturesChange();
// Unity/AVCapture.mm
int UnityGetAVCapturePermission(int captureTypes);
void UnityRequestAVCapturePermission(int captureTypes);
// Unity/CameraCapture.mm
void UnityEnumVideoCaptureDevices(void* udata, void(*callback)(void* udata, const char* name, int frontFacing, int autoFocusPointSupported, int kind, const int* resolutions, int resCount));
void* UnityInitCameraCapture(int device, int w, int h, int fps, int isDepth, void* udata);
void UnityStartCameraCapture(void* capture);
void UnityPauseCameraCapture(void* capture);
void UnityStopCameraCapture(void* capture);
void UnityCameraCaptureExtents(void* capture, int* w, int* h);
void UnityCameraCaptureReadToMemory(void* capture, void* dst, int w, int h);
int UnityCameraCaptureVideoRotationDeg(void* capture);
int UnityCameraCaptureVerticallyMirrored(void* capture);
int UnityCameraCaptureSetAutoFocusPoint(void* capture, float x, float y);
// Unity/DeviceSettings.mm
const char* UnityDeviceUniqueIdentifier();
const char* UnityVendorIdentifier();
const char* UnityAdvertisingIdentifier();
int UnityAdvertisingTrackingEnabled();
int UnityGetLowPowerModeEnabled();
int UnityGetWantsSoftwareDimming();
void UnitySetWantsSoftwareDimming(int enabled);
const char* UnityDeviceName();
const char* UnitySystemName();
const char* UnitySystemVersion();
const char* UnityDeviceModel();
int UnityDeviceCPUCount();
int UnityGetPhysicalMemory();
int UnityDeviceGeneration();
float UnityDeviceDPI();
const char* UnitySystemLanguage();
int UnityDeviceSupportsUpsideDown();
// Unity/DisplayManager.mm
EAGLContext* UnityGetMainScreenContextGLES();
EAGLContext* UnityGetContextEAGL();
void UnityStartFrameRendering();
void UnityDestroyUnityRenderSurfaces();
int UnityMainScreenRefreshRate();
void UnitySetBrightness(float brightness);
float UnityGetBrightness();
// Unity/Filesystem.mm
const char* UnityDataBundleDir();
void UnitySetDataBundleDirWithBundleId(const char * bundleId);
const char* UnityDocumentsDir();
const char* UnityLibraryDir();
const char* UnityCachesDir();
int UnityUpdateNoBackupFlag(const char* path, int setFlag); // Returns 1 if successful, otherwise 0
// Unity/WWWConnection.mm
void* UnityStartWWWConnectionGet(void* udata, const void* headerDict, const char* url);
void* UnityStartWWWConnectionPost(void* udata, const void* headerDict, const char* url, const void* data, unsigned length);
void UnityDestroyWWWConnection(void* connection);
void UnityShouldCancelWWW(const void* connection);
// Unity/FullScreenVideoPlayer.mm
int UnityIsFullScreenPlaying();
void TryResumeFullScreenVideo();
//Apple TV Remote
int UnityGetAppleTVRemoteAllowExitToMenu();
void UnitySetAppleTVRemoteAllowExitToMenu(int val);
int UnityGetAppleTVRemoteAllowRotation();
void UnitySetAppleTVRemoteAllowRotation(int val);
int UnityGetAppleTVRemoteReportAbsoluteDpadValues();
void UnitySetAppleTVRemoteReportAbsoluteDpadValues(int val);
int UnityGetAppleTVRemoteTouchesEnabled();
void UnitySetAppleTVRemoteTouchesEnabled(int val);
// Unity/UnityReplayKit.mm
void UnityShouldCreateReplayKitOverlay();
#ifdef __cplusplus
} // extern "C"
#endif
#ifdef __OBJC__
// This is basically a wrapper for [NSString UTF8String] with additional strdup.
//
// Apparently multiple calls on UTF8String will leak memory (NSData objects) that are collected
// only when @autoreleasepool is exited. This function serves as documentation for this and as a
// handy wrapper.
inline char* AllocCString(NSString* value)
{
if (value == nil)
return 0;
const char* str = [value UTF8String];
return str ? strdup(str) : 0;
}
#endif