Unity3d 周分享(8期 2018.12.16)

本文汇总了Unity3d的多个技术要点,包括如何取消DontDestroyOnLoad的效果、实现反盗版APK检查、使用ADB的Unity过滤器、编辑器扩展来测量构建时间、初始化AnimationCurve的方法,以及优化IL2CPP构建时间和内存分析工具的预览版。此外,还涉及Unity的协程包、禁用垃圾回收的API、2D FPS套件、使用Stencil Comparison定义值等实用技巧。
摘要由CSDN通过智能技术生成

选自过去1~2周的内容: https://twitter.com/unity3d   和各种其他来源吧

 

1)、 取消DontDestroyOnLoad效果

DontDestroyOnLoad效果的原理是把物体移动到一个特殊的场景里,这个场景在加载场景时不会被卸载,这个场景里的物体也就不会随着加载场景被销毁。

取消DontDestroyOnLoad效果就是进行一个逆操作,把这个物体移回到活跃场景里。

 

 

 

 

2) Anti-piracy APK checking

an anti-piracy check, which is used to determine if your app was altered after it was submitted to the Google Play Store

 

Restrict features in your app like level progression or store fronts

反盗版APK检查

反盗版检查,用于确定您的应用在提交到Google Play商店后是否被更改

限制应用中的功能,例如关卡进度, 商店使用等等

https://docs.unity3d.com/ScriptReference/Application-genuine.html

https://docs.unity3d.com/ScriptReference/Application-genuineCheckAvailable.html

 

 

 

 

3)

安卓的 ADB 拥有专门为Unity 添加的过滤器

adb logcat -s Unity

 

 

 

4)、 http://baba-s.hatenablog.com/entry/2018/12/12/183000

编辑器扩展,输出日志用于测量构建所需的时间

usingSystem;
usingUnityEditor.Build;
usingUnityEditor.Build.Reporting;
usingUnityEngine;
publicclassExample : IPreprocessBuildWithReport, IPostprocessBuildWithReport {
    privateDateTimem_startTime;
    publicintcallbackOrder { get { return0; } }
    publicvoidOnPreprocessBuild (BuildReportreport) {
        m_startTime = DateTime.Now;
        Debug.LogFormat ("【ビルド】開始:{0}", m_startTime.ToString ("HH:mm:ss"));
    }
    publicvoidOnPostprocessBuild (BuildReportreport) {
        varendTime = DateTime.Now;
        vardeltaTime = endTime - m_startTime;
        varhours = deltaTime.Hours.ToString ("00");
        varminutes = deltaTime.Minutes.ToString ("00");
        varseconds = deltaTime.Seconds.ToString ("00");
        Debug.LogFormat ("【ビルド】終了:{0}", endTime.ToString ("HH:mm:ss"));
        Debug.LogFormat ("【ビルド】経過時間:{0}:{1}:{2}", hours, minutes, seconds);
    }
}

将上述脚本添加到Unity项目的“Editor”文件夹中

右键单击Console窗口的选项卡,选择“Open Editor Log”,然后按

“Editor.log”进行*** Completed 'Build.Player.搜索

***在7秒内完成'Build.Player.WindowsStandaloneSupport'(6905毫秒)

 

 

 

5)、 AnimationCurve 类型变量的初始化可以使用「AnimationCurve.Constant」「AnimationCurve.Linear」「AnimationCurve.EaseInOut」

 using UnityEngine;
 public class Example : MonoBehaviour {
     public AnimationCurve m_curve1 =
         AnimationCurve.Constant (0, 1, 0.5f);

     public AnimationCurve m_curve2 =
         AnimationCurve.Linear (0, 0, 1, 1);

     public AnimationCurve m_curve3 =
     
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值