Java Examples for com.unity3d.player.UnityPlayer

The following java examples will help you to understand the usage of com.unity3d.player.UnityPlayer. These source code samples are taken from different open source projects.

Example 1
Project: PokemonGo_Android_RE-master  File: SfidaUnityPlugin.java View source code
public void onClick() {
    SfidaUnityPlugin.this.sfidaService.sendDeviceControlMessage(SfidaMessage.UUID_LED_VIBRATE_CTRL_CHAR, SfidaMessage.getThrewPokeball());
    SfidaUnityPlugin.this.sfidaService.setOnClickSfidaListener(null);
    UnityPlayer.UnitySendMessage(SfidaUnityPlugin.UNITY_GAME_OBJECT, SfidaUnityPlugin.UNITY_METHOD_THROW_POKEBALL, BuildConfig.FLAVOR);
}
Example 2
Project: ngui-master  File: GoogleIAB.java View source code
@Override
public void onIabSetupFinished(IabResult result) {
    Log.d(TAG, "IabHelper 초기화 완료");
    // 초기화를 실패했는지 체크
    if (!result.isSuccess()) {
        // 유니티로 초기화실패 상황전달
        UnityPlayer.UnitySendMessage(GoogleIAB_OBJECT, "Error", "" + result.getResponse());
        return;
    }
    Log.d(TAG, "초기화성공 후 소모하지않은 인앱 상품 체크");
    mHelper.queryInventoryAsync(mGotInventoryListener);
}
Example 3
Project: appboy-android-sdk-master  File: EventSubscriberFactory.java View source code
@Override
public void trigger(FeedUpdatedEvent feedUpdatedEvent) {
    String unityGameObjectName = unityConfigurationProvider.getFeedListenerGameObjectName();
    if (StringUtils.isNullOrBlank(unityGameObjectName)) {
        Log.d(TAG, "There is no Unity GameObject registered in the appboy.xml configuration file to receive " + "feed updates. Not sending the message to the Unity Player.");
        return;
    }
    String unityCallbackFunctionName = unityConfigurationProvider.getFeedListenerCallbackMethodName();
    if (StringUtils.isNullOrBlank(unityCallbackFunctionName)) {
        Log.d(TAG, "There is no Unity callback method name registered to receive feed updates in " + "the appboy.xml configuration file. Not sending the message to the Unity Player.");
        return;
    }
    JSONArray jsonArray = new JSONArray();
    List<Card> cards = feedUpdatedEvent.getFeedCards();
    for (Card card : cards) {
        jsonArray.put(card.forJsonPut());
    }
    JSONObject object = new JSONObject();
    try {
        object.put("mFeedCards", jsonArray);
        object.put("mFromOfflineStorage", feedUpdatedEvent.isFromOfflineStorage());
    } catch (JSONException e) {
        AppboyLogger.e(TAG, "Caught exception creating feed updated event Json.", e);
    }
    UnityPlayer.UnitySendMessage(unityGameObjectName, unityCallbackFunctionName, object.toString());
}
Example 4
Project: admob-unity-plugin-master  File: AdMobPlugin.java View source code
public static AdMobPlugin getInstance(String publisherId, boolean isTesting, String[] testDeviceIds, boolean guessSelfDeviceId, int size, int orientation, int horizontalPosition, int verticalPosition) {
    if (AdMobPlugin.instance.config == null) {
        Log.d(AdMobPlugin.LOGTAG, "Initializing...");
        AdMobPlugin.instance.activity = UnityPlayer.currentActivity;
        AdMobPlugin.instance.config = new AdMobConfiguration(publisherId, isTesting, testDeviceIds, guessSelfDeviceId, size, orientation, horizontalPosition, verticalPosition);
        AdMobPlugin.instance.activity.runOnUiThread(AdMobPlugin.instance.CONF);
        Log.i(AdMobPlugin.LOGTAG, "Initialized.");
    }
    return (AdMobPlugin.instance);
}
Example 5
Project: UnitySimpleNotifier-master  File: SimpleNotificationService.java View source code
public static void notify(String title, String body) {
    Activity activity = UnityPlayer.currentActivity;
    Context context = activity.getApplicationContext();
    int id = (int) (Math.random() * 10000.0f) + 1;
    Intent intent2 = new Intent();
    intent2.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent2, PendingIntent.FLAG_UPDATE_CURRENT);
    final PackageManager pm = context.getPackageManager();
    ApplicationInfo applicationInfo = null;
    try {
        applicationInfo = pm.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
        return;
    }
    final int appIconResId = applicationInfo.icon;
    Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), appIconResId);
    // NotificationBuilderを作成
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setContentIntent(contentIntent);
    builder.setTicker(title);
    builder.setSmallIcon(appIconResId);
    builder.setContentTitle(title);
    builder.setContentText(body);
    builder.setLargeIcon(largeIcon);
    builder.setWhen(System.currentTimeMillis());
    builder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS);
    builder.setAutoCancel(true);
    NotificationManager manager = (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(id, builder.build());
}
Example 6
Project: unity-billing-for-android-master  File: BillingPlugin.java View source code
/**
	 * 通常アイテムの購入処理を実行する.
	 * 
	 * @param productId
	 *            課金アイテムのID.
	 * @param consume
	 *            true 消費アイテム, false 非消費アイテム.
	 * @param payload
	 *            verify用文字列.
	 * @return true 成功, false 失敗.
	 */
public boolean purchaseInApp(String productId, boolean consume, String payload) {
    Log.d(TAG, "Called purchase : " + productId + "  consume : " + consume);
    if (!mPurchaseState.equals(PurchaseState.Idle)) {
        // Processing Purchase or initialize. 何か処理中の場合は購入処理不可.
        return false;
    }
    if (consume) {
        mPurchaseState = PurchaseState.ConsumablePurchase;
    } else {
        mPurchaseState = PurchaseState.NoConSumablePurchase;
    }
    mProductId = productId;
    mHelper.launchPurchaseFlow(UnityPlayer.currentActivity, productId, RC_REQUEST, mPurchaseFinishedListener, payload);
    return true;
}
Example 7
Project: UIAP-master  File: MainActivity.java View source code
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
    if (result.isFailure()) {
        // handle error
        return;
    }
    //put all items of inventory which is in skuList to JSONObject
    JSONObject jsonResult = new JSONObject();
    try {
        for (int i = 0; i < m_reqSkuList.size(); ++i) {
            String sku = m_reqSkuList.get(i);
            SkuDetails detail = inventory.getSkuDetails(sku);
            JSONObject info = fillInfo(detail);
            jsonResult.put(sku, info);
        }
    } catch (JSONException ex) {
        throw new RuntimeException(ex);
    }
    String resultString = jsonResult.toString();
    Log.d(GOOGLE_TAG, "Inventory Result: " + resultString);
    //responds the itemList data to Unity3d
    if (jsonResult.length() > 0) {
        UnityPlayer.UnitySendMessage("Bridge", "onGetItem", jsonResult.toString());
    }
    Log.d(GOOGLE_TAG, "check unfinished ...");
    //check unfinished purchase in skuList 
    for (int i = 0; i < m_reqSkuList.size(); ++i) {
        String sku = m_reqSkuList.get(i);
        Purchase pur = inventory.getPurchase(sku);
        if (pur != null && verifyDeveloperPayload(pur)) {
            Log.d(GOOGLE_TAG, "find unfinished purchase, SKU: " + sku);
            mCurPurchase = sku;
            mHelper.consumeAsync(pur, mConsumeFinishedListener);
            return;
        }
    }
}
Example 8
Project: Flappy-And-Fire-master  File: UnityMessage.java View source code
public void send() {
    assert methodName != null : "no method specified";
    String message = new UnityParams(this.params).toString();
    Log.v(FB.TAG, "sending to Unity " + this.methodName + "(" + message + ")");
    try {
        UnityPlayer.UnitySendMessage(FB.FB_UNITY_OBJECT, this.methodName, message);
    } catch (UnsatisfiedLinkError e) {
        Log.v(FB.TAG, "message not send, Unity not initialized");
    }
}
Example 9
Project: ColourReflex-master  File: UnityMessage.java View source code
public void send() {
    assert methodName != null : "no method specified";
    String message = new UnityParams(this.params).toString();
    Log.v(FB.TAG, "sending to Unity " + this.methodName + "(" + message + ")");
    try {
        UnityPlayer.UnitySendMessage(FB.FB_UNITY_OBJECT, this.methodName, message);
    } catch (UnsatisfiedLinkError e) {
        Log.v(FB.TAG, "message not send, Unity not initialized");
    }
}
Example 10
Project: carrot-unity-master  File: UnityMessage.java View source code
public void send() {
    assert methodName != null : "no method specified";
    String message = new UnityParams(this.params).toString();
    Log.v(FB.TAG, "sending to Unity " + this.methodName + "(" + message + ")");
    try {
        UnityPlayer.UnitySendMessage(FB.FB_UNITY_OBJECT, this.methodName, message);
    } catch (UnsatisfiedLinkError e) {
        Log.v(FB.TAG, "message not send, Unity not initialized");
    }
}
Example 11
Project: unity3d-floppy-clone-game-master  File: UnityMessage.java View source code
public void send() {
    assert methodName != null : "no method specified";
    String message = new UnityParams(this.params).toString();
    Log.v(FB.TAG, "sending to Unity " + this.methodName + "(" + message + ")");
    try {
        UnityPlayer.UnitySendMessage(FB.FB_UNITY_OBJECT, this.methodName, message);
    } catch (UnsatisfiedLinkError e) {
        Log.v(FB.TAG, "message not send, Unity not initialized");
    }
}
Example 12
Project: Unity3d-Amazon-Mobile-Ads-Plugin-master  File: AmazonAds.java View source code
// Get instance of the AdRotator
public static AmazonAds getInstance() {
    AmazonAds.instance.activity = UnityPlayer.currentActivity;
    Log.d(tag, "Amazon Ads Plugin instantiated.");
    return AmazonAds.instance;
}
Example 13
Project: GlobalGameJam2014-master  File: FB.java View source code
public void send() {
    assert methodName != null : "no method specified";
    String message = new JSONObject(this.params).toString();
    Log.v(TAG, "sending to Unity " + this.methodName + "(" + message + ")");
    UnityPlayer.UnitySendMessage(FB_UNITY_OBJECT, this.methodName, message);
}