Unity关键细节整理

1.崩溃和报错

Application.logMessageReceived += unityLogHander;
private unityLogHander(string log_, string stackInfo_, LogType type_){
    if (
        type_ == LogType.Assert ||
        type_ == LogType.Error ||
        type_ == LogType.Exception
    ){
        //Editor + Debug 下弹出提示框
        //非 Editor + Debug 下报bugly
    }
}

2.运行时,跨环境调用

2 - 1 - IOS 交互

2 - 2 - Android 交互

2 - 3 - lua 交互

3.AssetsBundle相关

using UnityEditor;
using UnityEngine;
using System.IO;
using System.Linq; 
using System.Collections;
using System.Collections.Generic;
/*
工程目录 的 Assets 目录
    Application.dataPath
AB包构建需要的一些文件操作,详细操作方式查阅以下类的文档。
    File、FileInfo、Directory、DirectoryInfo
平台判断
    EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android
    EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS
*/
//获取工程相某个文件夹下的文件列表的相对路径
public static List<string> getRelativeFilePathList( string relativeFolder_ , List<string> filterList_ = null ){
    string _targetRelativeFolderPath = System.IO.Path.Combine( Application.dataPath , relativeFolder_ );
    List<string> _fileRelativePathList = new List<string>();
    DirectoryInfo _targetDirInfo = new DirectoryInfo( _targetRelativeFolderPath );//文件夹信息
    for (int _idx = 0; _idx < filterList_.Count; _idx++) {
        FileInfo[] _targetFileInfos = _targetDirInfo.GetFiles( filterList_[_idx] , SearchOption.AllDirectories );//满足后缀的文件信息列表
        for (int _j = 0; _j < _targetFileInfos.Length; _j++) {
            string _filePath = _targetFileInfos[ _j ].FullName;//绝对路径
            string _relativePath = _filePath.Substring( _filePath.IndexOf("Assets") );//相对路径
            _fileRelativePathList.Add(_relativePath);
        }
    }
    return _fileRelativePathList;
}
//获取其所依赖的文件列表
public static string[] getDependencies
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值