游戏:unity保存log堆栈到本地


public class Test : MonoBehaviour
{

    //文件的路径
    public string path;
    StreamWriter writer;
    StreamReader reader;

    void Start()
    {
        SetPath();

        // 方法一
        FileInfo file = new FileInfo(path);
        if (file.Exists)
        {
            // file.Delete();
            //  file.Refresh();
        }

        // 方法二
        if (File.Exists(path))
        {
            File.Delete(path);
        }
    }


    void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            Debug.Log("Log");
            Debug.LogError("LogError");
            Debug.LogWarning("LogError");
        }
    }


    void OnEnable()
    {
        Application.logMessageReceivedThreaded += OnLogMessageReceivedThreaded;
        System.AppDomain.CurrentDomain.UnhandledException += _OnUnresolvedExceptionHandler;
    }

    void OnDisable()
    {
        Application.logMessageReceivedThreaded -= OnLogMessageReceivedThreaded;
        System.AppDomain.CurrentDomain.UnhandledException -= _OnUnresolvedExceptionHandler;

    }

    private void OnLogMessageReceivedThreaded(string condition, string stackTrace, LogType type)
    {
        StringBuilder str = new StringBuilder();
        str.Append(type.ToString() + ":" + condition + "    堆栈信息:" + stackTrace);
        //   WriteIntoTxt(str.ToString());
        WriteIntoTxtTown(str.ToString());
    }

    private void _OnUnresolvedExceptionHandler(object sender, UnhandledExceptionEventArgs e)
    {
        Debug.LogError(sender);
    }

    // 方法一
    public void WriteIntoTxt(string message)
    {
        FileInfo file = new FileInfo(path);
        if (!file.Exists)
        {
            writer = file.CreateText();
        }
        else
        {
            writer = file.AppendText();
        }
        writer.WriteLine(message);
        writer.Flush();
        writer.Dispose();
        writer.Close();
    }

    // 方法二
    public void WriteIntoTxtTown(string message)
    {
        File.AppendAllText(path, message);
    }



    void SetPath()
    {
        if (Application.platform == RuntimePlatform.Android)
        {
            path = Application.persistentDataPath + "/logInfo.txt";
        }
        if (Application.platform == RuntimePlatform.WindowsEditor)
        {
            path = Application.streamingAssetsPath + "/logInfo.txt";
        }
    }
}


华为发布了跨平台开发的ArkUI-X,我不允许你学不会!

就在8月7日开源鸿蒙 OpenHarmony 4.0 Beta2 发布,多平台开发框架 ArkUI-X 首发。首先介绍下啥是 ArkUI:Ark

商弈网校开发:用户决策的不同模式及营销策略

编辑导语:影响用户决策的因素有很多,在面对不同价值、不同用途的商品时,用户会有不同的决策模式;比如你买一样很贵的商品时,你会经过多种对比,思前想后,最后决定下单;

某游戏服务运维架构进化史(上云方案)

网站架构百度百科:网站架构,一般认为是根据客户需求分析的结果,准确定位网站目标群体,设定网站整体架构,规划、设计网站栏目及其内容,制定网站开发流程及顺序,以最大限度地进行高效资源分配与管理的设计。

unity圆圈自动吸附屏幕边缘

效果: 设置如下:

Unity和Cocos2D在2D游戏开发上的对比

游戏开发的最好技术是什么:nity还是ocos?在网上你可以找到很多这两种技术的对比…。在我们开发游戏之前,我们要了解相关数据和信息并决定使用那种技术。但是人们对这两种技…术的对比大多都比较主观。擅长ocos的人会偏向于ocos。而使用nity的人则偏向于