0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

UnityでAdaptivePerformanceについて調べたメモ

Last updated at Posted at 2024-06-15

この記事について

今回の記事は機能について調べた内容を記録できるように記事にしたものです。
この記事には間違った事や書かれていない内容もあると思いますので、コメントで教えていただけると幸いです。

AdaptivePerformanceって何?

公式リファレンスでは、スマホの熱量や電力状態などの情報を取得出来るという記載があります。

ダウンロード方法

UnityのテンプレートでMobileテンプレートを選ぶと最初からプロジェクトに入っています。
image.png

また、PackageManagerからもダウンロードする事が出来ます。
image.png

実行確認と設定を行う

AdaptivePerformanceが入っている状態で実行してみると以下のログが表示されます。
image.png
このログは、Adaptive Performanceの設定をして下さいという内容なので設定を行います。
今回はAndroidで2つ設定を行います。

① Edir -> Project Settings -> Player -> Other Settings

Frame Timing Statusにチェックします。
image.png

この項目の内容としては、以下の内容です。
・フレーム単位でデバッグを行いたい時
・動的解像度機能を利用する時
・Adaptive Performanceを利用する時

② Edit -> Project Settings -> Adaptive Performance

設定は簡単で、ProvidersのSamsung Android Providerの項目にチェックを入れるだけです。
image.png
チェックマークを入れると自動的にダウンロードされます。

デバッグ出来る環境を作って実機で確認する

下記の記事を参考にしています。

Unityのシーンにテキストを配置する
image.png

次にデバック用のスクリプトを作ります。
このスクリプトでは、Adaptive Perfomanceに対応している実機かどうかを確認出来ます。

using UnityEngine;
using UnityEngine.AdaptivePerformance;
using UnityEngine.UI;

public class Test : MonoBehaviour
{
    [SerializeField] private Text debugText;
    private IAdaptivePerformance adaptivePerformance = null;

    // Start is called before the first frame update
    void Start()
    {
        adaptivePerformance = Holder.Instance;

        if(adaptivePerformance == null)
        {
            debugText.text = "Adaptive Performanceが存在しません";
            return;
        }

        // Adaptive Performanceがサポートされているか確認する
        if (!adaptivePerformance.Active) 
        {
            debugText.text = "Adaptive Performanceがサポートされていない端末です";
            return;
        }

        debugText.text = "Adaptive Performanceがサポートされている端末です";
    }
}

実行してみましたが、自分が持っているAndroidではサポートされていないという結果になってしまったので実機確認はここで終わろうと思います。

image.png

Adaptive Performanceのまとめ

・スマホの熱量や電力状態を取得する事が出来る
・対応しているデバイスとしていないデバイスがある事

Adaptive Performanceのpackageの消し方

開発途中の環境から削除するとエラーが沢山出るので、
開発が始まる時に削除をオススメします。

エクスプローラー上からプロジェクトのフォルダーを探し、下記のjsonを編集します。

プロジェクト名 -> Packages -> manifest.json

jsonからadaptiveperformanceに関連する内容を削除します。
image.png

後は、AssetsからAdaptive Performanceに関連している物を削除したら終了です。

※追記
mobileテンプレートのプロジェクトから削除する時は、PackagesからAdaptive performanceを選びエクスプローラー上から削除する事で消す事が出来ます。フォルダー自体は残ってしまいますが削除は出来るみたいです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?