ラベル Android の投稿を表示しています。 すべての投稿を表示
ラベル Android の投稿を表示しています。 すべての投稿を表示

2022年6月23日木曜日

UE5のTopDownがAndroidでタッチした箇所に移動しない

[UnrealEngine5.0.2][Windows11]で確認

UE5のサンプルTopDownテンプレートが、Androidだとタッチした箇所に移動しなかった。

タッチした方向には移動します。


調査して対応してみました。

C++版で確認しています。プロジェクト名はTopDownTestにしています。


TopDownTestPlayerController.h
FVector HitTouchLocation; を追加。

// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "Templates/SubclassOf.h"
#include "GameFramework/PlayerController.h"
#include "TopDownTestPlayerController.generated.h"

/** Forward declaration to improve compiling times */
class UNiagaraSystem;

UCLASS()
class ATopDownTestPlayerController : public APlayerController
{
	GENERATED_BODY()

public:
	ATopDownTestPlayerController();

	/** Time Threshold to know if it was a short press */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
	float ShortPressThreshold;

	/** FX Class that we will spawn when clicking */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
	UNiagaraSystem* FXCursor;

protected:
	/** True if the controlled character should navigate to the mouse cursor. */
	uint32 bMoveToMouseCursor : 1;

	// Begin PlayerController interface
	virtual void PlayerTick(float DeltaTime) override;
	virtual void SetupInputComponent() override;
	// End PlayerController interface

	/** Input handlers for SetDestination action. */
	void OnSetDestinationPressed();
	void OnSetDestinationReleased();
	void OnTouchPressed(const ETouchIndex::Type FingerIndex, const FVector Location);
	void OnTouchReleased(const ETouchIndex::Type FingerIndex, const FVector Location);

private:
	bool bInputPressed; // Input is bring pressed
	bool bIsTouch; // Is it a touch device
	float FollowTime; // For how long it has been pressed

	FVector HitTouchLocation;	// PlayerTickで保存する
};


TopDownTestPlayerController.cpp
PlayerTickに Hit.Location を HitTouchLocation に保存する処理を追加。
OnSetDestinationReleased に HitTouchLocation を 参照する処理を追加。
OnTouchReleasedで bIsTouch = false; を下へずらす。
今回は暫定対応ですが、本格的に対応するなら bIsTouch の代わりにフラグを別に用意する等の対応をしたがほういいかも。

// Copyright Epic Games, Inc. All Rights Reserved.

#include "TopDownTestPlayerController.h"
#include "GameFramework/Pawn.h"
#include "Blueprint/AIBlueprintHelperLibrary.h"
#include "NiagaraSystem.h"
#include "NiagaraFunctionLibrary.h"
#include "TopDownTestCharacter.h"
#include "Engine/World.h"

#include "Kismet/KismetSystemLibrary.h"

ATopDownTestPlayerController::ATopDownTestPlayerController()
{
	bShowMouseCursor = true;
	DefaultMouseCursor = EMouseCursor::Default;
}

void ATopDownTestPlayerController::PlayerTick(float DeltaTime)
{
	Super::PlayerTick(DeltaTime);

	if(bInputPressed)
	{
		FollowTime += DeltaTime;

		// Look for the touch location
		FVector HitLocation = FVector::ZeroVector;
		FHitResult Hit;
		if(bIsTouch)
		{
			GetHitResultUnderFinger(ETouchIndex::Touch1, ECC_Visibility, true, Hit);
#if 0	// FollowTimeやタッチした座標を表示する。
			{
				//	UKismetSystemLibrary::PrintString(this, "C++ Hello World!", true, true, FColor::Cyan, 2.f);
				FString Str = FString::SanitizeFloat(FollowTime);
				UKismetSystemLibrary::PrintString(this, Str, true, true, FColor::Green, 5.f);
				FString Str2 = FString::SanitizeFloat(Hit.Location.X) + FString(" ") + FString::SanitizeFloat(Hit.Location.Y) + FString(" ") + FString::SanitizeFloat(Hit.Location.Z);
				UKismetSystemLibrary::PrintString(this, Str2, true, true, FColor::Green, 5.f);
			}
#endif
			HitTouchLocation = Hit.Location;	// Released時に使うために保存する。
		}
		else
		{
			GetHitResultUnderCursor(ECC_Visibility, true, Hit);
		}
		HitLocation = Hit.Location;

		// Direct the Pawn towards that location
		APawn* const MyPawn = GetPawn();
		if(MyPawn)
		{
			FVector WorldDirection = (HitLocation - MyPawn->GetActorLocation()).GetSafeNormal();
			MyPawn->AddMovementInput(WorldDirection, 1.f, false);
		}
	}
	else
	{
		FollowTime = 0.f;
	}
}

void ATopDownTestPlayerController::SetupInputComponent()
{
	// set up gameplay key bindings
	Super::SetupInputComponent();

	InputComponent->BindAction("SetDestination", IE_Pressed, this, &ATopDownTestPlayerController::OnSetDestinationPressed);
	InputComponent->BindAction("SetDestination", IE_Released, this, &ATopDownTestPlayerController::OnSetDestinationReleased);

	// support touch devices 
	InputComponent->BindTouch(EInputEvent::IE_Pressed, this, &ATopDownTestPlayerController::OnTouchPressed);
	InputComponent->BindTouch(EInputEvent::IE_Released, this, &ATopDownTestPlayerController::OnTouchReleased);

}

void ATopDownTestPlayerController::OnSetDestinationPressed()
{
	// We flag that the input is being pressed
	bInputPressed = true;
	// Just in case the character was moving because of a previous short press we stop it
	StopMovement();
}

void ATopDownTestPlayerController::OnSetDestinationReleased()
{
	// Player is no longer pressing the input
	bInputPressed = false;

	// If it was a short press
	if(FollowTime <= ShortPressThreshold)
	{
		// We look for the location in the world where the player has pressed the input
		FVector HitLocation = FVector::ZeroVector;
		FHitResult Hit;

		if (bIsTouch)
		{
// タッチの場合、Releaseされた後だとHit.Locationは(0.0f, 0.0f, 0.0f)となるので、
			//GetHitResultUnderFinger(ETouchIndex::Touch1, ECC_Visibility, true, Hit);
			//HitLocation = Hit.Location;
// PlayerTickで保存しておいたのものを使う。
			HitLocation = HitTouchLocation;
		}
		else
		{
			GetHitResultUnderCursor(ECC_Visibility, true, Hit);
			HitLocation = Hit.Location;
		}

		// We move there and spawn some particles
		UAIBlueprintHelperLibrary::SimpleMoveToLocation(this, HitLocation);
		UNiagaraFunctionLibrary::SpawnSystemAtLocation(this, FXCursor, HitLocation, FRotator::ZeroRotator, FVector(1.f, 1.f, 1.f), true, true, ENCPoolMethod::None, true);
	}
}

void ATopDownTestPlayerController::OnTouchPressed(const ETouchIndex::Type FingerIndex, const FVector Location)
{
	bIsTouch = true;
	OnSetDestinationPressed();
}

void ATopDownTestPlayerController::OnTouchReleased(const ETouchIndex::Type FingerIndex, const FVector Location)
{
//	bIsTouch = false;
	OnSetDestinationReleased();
	bIsTouch = false;	// OnSetDestinationReleased()でHitTouchLocationを参照させるため、ここへずらす。
	// 今回は暫定対応ですが、本格的に対応するならフラグを別に用意する等の対応をしたがほういいかも。
}

2022年6月19日日曜日

UE5でAndroid用のビルドのテスト

  [UnrealEngine5.0.2][Windows11]で確認


UE5.0.2でAndroidのテストしたが、SDKのバージョン等は、UE4.27の時と同じバージョンでできました。

https://laidbacktechblog.blogspot.com/2022/01/ue427android.html


2022年6月16日木曜日

MobileStarterContentがない時の対処

 [UnrealEngine5.0.2][Windows11]で確認

Failed to import ‘C:/Program Files/Epic Games/UE_5.0EA/FeaturePacks/MobileStarterContent.upack’. Failed to create asset ‘/Game/MobileStarterContent’. Please see Output Log for details.


https://forums.unrealengine.com/t/failure-to-import-please-help/233204


To fix this issue, go to the folder …\UE_5.0EA\FeaturePacks and rename the “StarterContent.upack” file to “MobileStarterContent.upack”

(この問題を修正するには、フォルダー…\ UE_5.0EA \ FeaturePacksに移動し、「StarterContent.upack」ファイルの名前を「MobileStarterContent.upack」に変更します。)


私は、StarterContent.upackをコピーペーストしてMobileStarterContent.upackに変更しました。

一応、解消されましたが、これでいいのか不安です。


2022年4月23日土曜日

何故かGooglePlayに「アプリ内課金あり」と表示されてしまう

[UnrealEngine4.27.2][Windows11]で確認

アプリ内課金をしてないのに、何故かGooglePlayに「アプリ内課金あり」と表示されてしまう。

アプリ内購入のないアプリのGooglePlayConsoleテストダウンロードページにアプリ内購入ありと出てしまいます。

【UE4】Androidアプリに広告をつけてリリースするときのプロジェクト設定


AdMob広告をつけるためには、com.android.vending.BILLING を入れるように記載されている。

「アプリ内課金」をはずすためには、com.android.vending.BILLINGを削除するように指示されている。

とりあえず
Project Settings
Extra Permissions
自分で追加していた com.android.vending.BILLING を削除したが、
テスト広告は出ているので、
GooglePlayConstoleにリリースしてみたが、数日たつが「アプリ内課金」の表示は消えない。

調べると
Intermediate\Android以下に出力されているAndroidManifest.xmlに、
com.android.vending.BILLINGがある。

Pluginsの
Online Subsystem GooglePlay
をはずしても
AndroidManifest.xmlのcom.android.vending.BILLINGは消えない。
さらにテスト広告も表示されない?

UE4でプロジェクトを新規作成してAndroid用のパッケージを作っても、
AndroidManifest.xmlにcom.android.vending.BILLINGがある。

ただし、AndroidManifest.xmlが複数見つかり、どのAndroidManifest.xmlを使っているかは把握していない。

----------------------------------------
Editor側のソースを調査。
\UE4\Epic Games\UE_4.27\Engine\Source\Programs\UnrealBuildTool\Platform\Android\UEDeployAndroid.cs
private string GenerateManifest(AndroidToolChain ToolChain, string ProjectName, TargetType InTargetType, string EngineDirectory, bool bIsForDistribution, bool bPackageDataInsideApk, string GameBuildFilesPath, bool bHasOBBFiles, bool bDisableVerifyOBBOnStartUp, string UE4Arch, string GPUArch, string CookFlavor, bool bUseExternalFilesDir, string Configuration, int SDKLevelInt, bool bIsEmbedded, bool bEnableBundle)
{


bool bEnableIAP = false;
Ini.GetBool("OnlineSubsystemGooglePlay.Store", "bSupportsInAppPurchasing", out bEnableIAP);


if (bEnableIAP)
{
Text.AppendLine("\t<uses-permission android:name=\"com.android.vending.BILLING\"/>");
}

設定ファイルを参照しているようだ。

https://historia.co.jp/archives/5018/
https://qiita.com/EGJ-Kaz_Okada/items/b0d6adcfa56f2b92609c
上記によると、
プロジェクト以下のConfigファルダにAndroidフォルダを作成し、AndroidEngine.iniを追加して、以下の内容を記載する。

[OnlineSubsystem]
DefaultPlatformService=GooglePlay

[OnlineSubsystemGooglePlay.Store]
bSupportsInAppPurchasing=false
これで公開して様子を見たがダメだったので、
C:\Program Files\Epic Games\UE_4.27\Engine\Config\Android
AndroidEngine.ini
bSupportsInAppPurchasing=false
に変更。
Intermediate\Android\以下に作成される
AndroidManifest.xmlに
    <uses-permission android:name="com.android.vending.BILLING" /> <!-- Permission will be merged into the manifest of the hosting app. -->
が追加されてしまった。

2022年4月10日日曜日

AdMobの広告が表示されなくなった時の対応

AdMobの広告が表示されなくなったので、調査。

リクエストが送信されても​​、UnrealEngine4アプリに広告が表示されない

AdMobの広告が表示されない!その原因と対処方法 | Androidアプリ開発

テスト広告は表示されているので、(複数人からの)広告リクエストが少ないのが原因のように思える。

AdMobのapps-ads.txtの配置を無料で対応する方法

AdMobのapps-ads.txtの配置を無料で対応する方法を探してみました。

GoogleのBloggerでads.txtにリダイレクトする方法が紹介されていました。

 【図解】BloggerでAdMobのapps-ads.txtを設置する方法

2022年3月16日水曜日

2022年1月31日月曜日

Google Play Console の内部テストでセーブできない

 [UnrealEngine4.27.2][Windows11]で確認

Google Play Console の内部テストでテストしたが、セーブ・ロードができていない。

Save Game to Slot 関連が失敗しているようだ。

Project SettingsのPlatforms/Android/Apk Packaging/Use ExternalFilesDir for UE4Game files?

をチェックすると、セーブ・ロードできるようになった。


2022年1月30日日曜日

AndroidManifest.xmlとは

[UnrealEngine4.27.2][Windows11]で確認

AndroidManifest.xmlは、Androidでアプリを開発する時に必要になるxml。

アプリのパッケージング名やバージョン番号、使用するActivity等の重要な情報を記載する。


Android Manifest ファイルの制御

基本的にUnrealEngine4からAndroidManifestを制御する。


[UE4] AndroidManifest.xmlをカスタマイズする

ヒストリアさんの詳細な説明。

2022年1月25日火曜日

Google Play Console 用に設定を調整後に、再度Apkを直接インストールして確認したい時

[UnrealEngine4.27.2][Windows11]で確認

そのままだと動かないので以下に変更する。

For Distribution : false

Target SDK Version : 30 → 28

Androidのバージョン11(APIレベル30)なのに、30で動かないのは何故?


2022年1月20日木曜日

App Bundle をアップ時に、64bit関連のエラーへの対応メモ

[UnrealEngine4.27.2][Windows11]で確認 

「このリリースは Google Play の 64 ビット要件に準拠していません」


https://forums.unrealengine.com/t/arm7-and-arm64-apk-on-playstore/135492

上記を参考。

Support arm64[aka arm64-v8a] をチェックしてさらに、

中間フォルダのIntermediateを削除して、再パッケージ化したら直った。




UE4でGoogle Play Console でのリリース対応で詰まったところのメモ

[UnrealEngine4.27.2][Windows11]で確認 

https://nasvic.hateblo.jp/entry/2020/09/07/102433

「プロジェクト設定>Android>APK Packaging>「Android パッケージ名」項目はちゃんと決めてから設定すること!」


http://kagring.blog.fc2.com/blog-entry-359.html

Project/Description/About/Project Name はアイコン名ではない。


https://www.zkn0hr.com/google-play-firebase-admob-data-safety-example/

データセーフティの参考。


GooglePlayConsoleテストダウンロードページに「アプリ内課金あり」と表示されてしまうが、課金はないので調査中。

アプリ内購入のないアプリのGooglePlayConsoleテストダウンロードページにアプリ内購入ありと出てしまいます。

【Unity】アプリ内課金のパーミッションを消す




Android用のAABファイルとは何ですか?APKとはどのように異なりますか?

Android App Bundle について

AAB(Android App Bundle )には、Androidアプリのプログラムコード全体が含まれている。


[Platforms] > [Android] > [App Bundles] セクションで [Generate Bundle (AAB)] を有効にして、UE4Editorからパッケージを作成すると、apkファイルとobbファイルと共にabbファイルも出力される。

Install_*.batを見るとaabは使われておらず、Android端末へは今までどおりapkとobbがインストールされているようだ。


aab(Android App Bundle)への対応方法:開発メモ

アップロード鍵(Upload key)について参考。


Google Play Asset Delivery のリファレンス

容量が150MBを超えるなら、Google Play Asset Delivery (Google PAD) に対応する。


クック処理とチャンク化

UE4のモバイル開発におけるコンテンツアップデートの話 - Chunk IDとの激闘編 -

チャンクについても把握が必要。


自動的に収集されるユーザープロパティ

AdMobで収集されている。


【GooglePlay】 AdMob広告を入れた場合のプライバシーポリシー対応方法(英語版ジェネレート)

Android 広告 ID の使用ポリシー違反でアプリが削除されたので対応する

プライバシーポリシーについて。


AdMob利用時の「Appのプライバシー」の入力方法虎の巻

収集しているデータの参考。


AdMob利用時の「Appのプライバシー」の入力方法虎の巻


プロジェクト リリースの承認方法

UE4 モバイル向けプロジェクトを Google Play Store にリリースするためのステップの説明。


Store Version

「プロジェクトを再クックしてストアにアップロードするごとに、Store Version 数は大きくなります。これを行わないと、新しい APK ファイルは古いものをアップロードしていないことになります。」


【UE4】Androidアプリに広告をつけてリリースするときのプロジェクト設定

上記を参考に変更。

Target SDK Version は 30

Support arm64[aka arm64-v8a] はチェック

Android でのアプリ内広告の使用方法

UE4で自動でAdmobのテスト広告と本番広告を切り替えるやり方(Android編)

Android 'Games App ID'



2022年1月17日月曜日

UE4でアイコンを変更する時のエラーへの対応

[UnrealEngine4.27.2][Windows11]で確認  

Platforms > Android > Icons

でアイコンを変更する時に以下のエラーが表示された時の対処方法。

"Could not mark image file for add"


以下を参考にした。

https://answers.unrealengine.com/questions/906467/could-not-mark-image-file-for-add-when-changing-ic.html


一時的にGitをはずしたらできた。





Gimpでの、24ビットPNGと32ビットPNGのエクスポート方法

GooglePlayConsoleでの公開時の


アプリのアイコン 

32 ビット PNG(アルファ付き)


フィーチャーグラフィック

JPEG または 24 ビット PNG(アルファなし)


Gimpで作成時、エクスポートで32ビットと24ビットを切り替える方法。

24 ビット PNG なら8bpc RGB

32 ビット PNG なら8bpc RGBA

を選ぶ。





2022年1月13日木曜日

価格やプロモーションを示すキーワードを使用しない

「Drone Free Flight」という名前はダメかもしれない。


https://android-developers.googleblog.com/2021/04/updated-guidance-to-improve-your-app.html

  • Are the preview assets free of buzzwords like "free" or "best" and instead focus on providing meaningful information about the unique aspects of your app or game?

今回は通るかもしれないが、他のマーケットや、GooglePlayも将来的に禁止になるかもしれないので、名前を変更しようかな。

2022年1月12日水曜日

Androidのプライバシーポリシーの表記

[UnrealEngine4.27.2][Windows11]で確認 

Androidのプライバシーポリシーの表記の処理を入れてみました。

外部にプライバシーポリシー表記のホームページを用意して、LaunchURLで開くと、OSの標準のブラウザで表示される。


LaunchURL

https://docs.unrealengine.com/4.27/en-US/BlueprintAPI/Utilities/Platform/LaunchURL/



画像はWindows版ですが、Android実機でもブラウザで開きました。

Google Play Console の審査が通るかは、まだわかりません。











2022年1月5日水曜日

Android端末がPCに認識されているかどうかの確認方法

 [Windows11]で確認

PowerShellやコマンドラインから

adb devices

Androidのログの確認方法

[Windows11]で確認

PowerShellやコマンドラインから

adb logcat


ログをファイルに残したい時は、

adb logcat > log.txt

等のリダイレクトで対応。

2022年1月4日火曜日

UE4.27でAndroidのパッケージ化が失敗する件の対応方法

[UnrealEngine4.27.2][Windows11]で確認

購入したばかりのPCにUE4.27をインストール後、Androidのパッケージ化が失敗するので、調査・対応。

Windows の Unreal Engine 4.27 で Android 用の開発環境を手動で設定する

インストール済のAndroid StudioのSDK Managerで、各バージョンを上記の情報どおりに変更。

Windowsの環境変数はSetupAndroid.batで設定済なので、UnrealEngine の「プロジェクトの設定」の、プラットフォーム - Android SDKのパス設定は空のまま。


[UE4] Android Build-tool 31.0.0 でパッケージが出来ない件

上記を参考に、33.0.0 で試したらパッケージ作成に失敗したが、Android SDK Build-Tools 30.0.3 なら動きました。

しかし、後で確認すると、何故か29.0.2もインストールされてしまう。