2017-02-22 10 views
0

Assets/Plugins/iOSLocationController.mmというファイルがあります。その内部のすべての機能は完全に機能しました。私はファイルとクラスの両方をBackgroundControllerに改名しました。その後、すべての機能が動作しなくなりました。名前を変更してもiOS対応のプラグインが動作しない

didFinishLaunchingWithOptionsstartUnityのように見えます。 Unityから_GetLocation()メソッドを呼び出すと動作しますが、常にすべて0が返されます。

このファイルをインポートする適切な方法はありますか?レスポンスありがとうございます。

BackgroundController.mm(EX LocationController.mm)ファイル:ビルド後

#import <Foundation/Foundation.h> 
#import <CoreLocation/CoreLocation.h> 

#import "UnityAppController.h" 

@interface BackgroundController : UnityAppController 
<CLLocationManagerDelegate>{ 
    CLLocationManager *locationManager; 
} 
@end 

extern bool _unityAppReady; 

static float latitude = 0; 
static float longitude = 0; 
static float horizontalAccuracy = 0; 

@implementation BackgroundController{ 
} 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes: UIUserNotificationTypeAlert | UIUserNotificationTypeSound | UIUserNotificationTypeBadge categories:nil]; 
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; 

    return [super application:application didFinishLaunchingWithOptions:launchOptions]; 
} 

-(void) startUnity:(UIApplication*) application { 
    [self startStandardUpdates]; 

    [super startUnity:application]; 
} 

- (void)startStandardUpdates 
{ 
    // Create the location manager if this object does not 
    // already have one. 
    if (nil == locationManager) 
     locationManager = [[CLLocationManager alloc] init]; 

    locationManager.delegate = self; 
    locationManager.desiredAccuracy = kCLLocationAccuracyBest; 

    // Set a movement threshold for new events. 
    locationManager.distanceFilter = 10; // meters 

    [locationManager requestAlwaysAuthorization]; 

    [locationManager startUpdatingLocation]; 
} 

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { 
    // updating location values 
} 

// other methods implementation 

@end 

extern "C" const char* _GetLocation() 
{ 

    NSString *location = [NSString stringWithFormat:@"%f,%f,%f",latitude,longitude,horizontalAccuracy]; 

    char* ret = (char*)::malloc(location.length + 1); 
    ::memcpy(ret, [location UTF8String], location.length); 
    ret[location.length] = 0; 

    return ret; 
} 

IMPL_APP_CONTROLLER_SUBCLASS(BackgroundController) 

Xcodeのファイルには、以前のようLibraries/Plugins/iOSフォルダにあります。

私はReimportAllファイルにしようとしましたが、それは役に立ちませんでした。

すべての名前をLocationControllerに変更すると、何も機能しません。

すべてのアクセス許可はinfo.plistに設定されています。

答えて

0

ファイル名をBackgroundController.mに変更した後で、ビルドに失敗してエラーが発生し、名前がBackgroundController.mmに変更された後、すべてが仕事になりました。

多くのことをしたので、私の答えが適切かどうかはわかりません。

関連する問題