从包装类访问视图

时间:2012-11-29 08:07:56

标签: iphone objective-c ios unity3d objective-c++

在Unity的回调方法中,我添加了一个UIButton

int OpenEAGL_UnityCallback(UIWindow** window, int* screenWidth, int* screenHeight,  int* openglesVersion) {
CGRect rect = [[UIScreen mainScreen] bounds];

// Create a full-screen window
_window = [[UIWindow alloc] initWithFrame:rect];
EAGLView* view = [[EAGLView alloc] initWithFrame:rect];

if (wrapperObj == nil)
{
    wrapperObj = [[WrapperClass alloc] init];
}

UIImage *buttonImage = [UIImage imageNamed:@"imageButton.png"];
UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(view.bounds.origin.x+35, view.bounds.size.height-72, 36, 39)];
[backButton setImage:buttonImage forState:UIControlStateNormal];

[backButton addTarget:wrapperObj action:@selector(goToPreviousScreen:) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:backButton];

}

如何访问已实例化Unity3D的类(MyViewController)视图?我想改变观点

@implementation MyViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {

        QCARUnityPlayer::getInstance().QCARInit([orientation UTF8String]);
        [self startUnity];
    }
    return self;
}

@end

0 个答案:

没有答案