1

在 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
4

0 回答 0