RenderPluginDelegate.mm
2.31 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
#include "RenderPluginDelegate.h"
@implementation RenderPluginDelegate
- (void)mainDisplayInited:(struct UnityDisplaySurfaceBase*)surface
{
mainDisplaySurface = surface;
// TODO: move lifecycle to init?
UnityRegisterLifeCycleListener(self);
}
@end
#define CALL_METHOD_ON_ARRAY(method) \
do{ \
for(id<RenderPluginDelegate> del in delegateArray) \
{ \
if([del respondsToSelector:@selector(method)]) \
[del method]; \
} \
} while(0)
#define CALL_METHOD_ON_ARRAY_ARG(method, arg) \
do{ \
for(id<RenderPluginDelegate> del in delegateArray) \
{ \
if([del respondsToSelector:@selector(method:)]) \
[del method:arg]; \
} \
} while(0)
@implementation RenderPluginArrayDelegate
@synthesize delegateArray;
- (void)mainDisplayInited:(struct UnityDisplaySurfaceBase*)surface
{
[super mainDisplayInited: surface];
CALL_METHOD_ON_ARRAY_ARG(mainDisplayInited, surface);
}
- (void)onBeforeMainDisplaySurfaceRecreate:(struct RenderingSurfaceParams*)params
{
CALL_METHOD_ON_ARRAY_ARG(onBeforeMainDisplaySurfaceRecreate, params);
}
- (void)onAfterMainDisplaySurfaceRecreate;
{
CALL_METHOD_ON_ARRAY(onAfterMainDisplaySurfaceRecreate);
}
- (void)onFrameResolved;
{
CALL_METHOD_ON_ARRAY(onFrameResolved);
}
- (void)didBecomeActive:(NSNotification*)notification
{
CALL_METHOD_ON_ARRAY_ARG(didBecomeActive, notification);
}
- (void)willResignActive:(NSNotification*)notification
{
CALL_METHOD_ON_ARRAY_ARG(willResignActive, notification);
}
- (void)didEnterBackground:(NSNotification*)notification
{
CALL_METHOD_ON_ARRAY_ARG(didEnterBackground, notification);
}
- (void)willEnterForeground:(NSNotification*)notification
{
CALL_METHOD_ON_ARRAY_ARG(willEnterForeground, notification);
}
- (void)willTerminate:(NSNotification*)notification
{
CALL_METHOD_ON_ARRAY_ARG(willTerminate, notification);
}
@end
#undef CALL_METHOD_ON_ARRAY
#undef CALL_METHOD_ON_ARRAY_ARG