U3D导出到安卓apk的日志打印管理

本文介绍了如何在Unity3D中管理并导出安卓APK的日志,尤其是在内外网隔离无法直接使用真机调试时,通过查看Application.persistentDataPath路径下的Log日志来辅助调试的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

虽然U3D提供真机调试,但是由于内外网的隔离,使得这个流程比较麻烦和不太靠谱。真机调试的另一个方法是查看游戏运行导出的Log日志(U3D的Application.persistentDataPath路径下),下面是一个常用的log日志类

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;


public class OutputLog : MonoBehaviour 
{
    public static OutputLog instance = null;
    private string err;
    private string log;
    private string filePath;
    private bool isDebugMode = false;

    void Awake()
    {
        filePath = Application.persistentDataPath + "/P1_log.txt";
        if (System.IO.File.Exists(filePath))
        {
            File.Delete(filePath);
        }
        instance = this;
        Application.RegisterLogCallback(HandleLog);
        Debug.Log(filePath);
    }

    void OnDestroy()
    {
        instance = null;
        Applica
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值