• 代码优化


    优化:
    unity只维护localPos, localeRot, local Scale,所以尽量避免直接只用position, rotation, scale. 如果必须要使用,则可以使用caching防止同一帧里多次修改transform
    1 UpdateLateUpdateFixedUpdateStart
    2 GameObject.Find
    3 Component cache, GetComponent("")
    4 DistToHost Change to SqrMagnitude, magnitude所有地方 Update中(替换)
    5 caching transform changes
    6 gameObject != null --> !System.Object.ReferenceEquals(gameObject, null) 减少native-managerment bridge (数量巨大才会有效果)

    7.频繁实例化,销毁的类缓存

    7.On** 空函数移除

    8.Dictionary的foreach遍历优化改成获取迭代器去while去执行

    9,减少GC,减少new,代码不需要了回收,下次继续使用

    OnRenderObject
    OnTriggerExit
    OnTriggerEnter
    OnPreRender
    OnPreCull
    OnPostRender
    OnMouseOver
    OnMouseUp
    OnMouseExit
    OnMouseEnter
    OnMouseDrag
    OnMouseDown
    OnLevelWasLoaded
    OnEnable
    OnDisable
    OnDestroy
    OnCollisionEnter
    OnAnimatorIK
    OnApplicationFocus
    OnApplicationPause
    OnApplicationQuit
    OnAudioFilterRead
    OnBecameInvisible
    OnBecameVisible

  • 相关阅读:
    10.19的一些题
    10.18 模拟赛
    bzoj 2212 Tree Rotations
    10.11的一些题
    10.15 模拟赛
    bzoj 5329 战略游戏
    php面向对象基础(二)
    php面向对象基础(一)
    PHP基础-数组与数据结构
    php基础-字符串处理
  • 原文地址:https://www.cnblogs.com/mttnor/p/6860025.html
Copyright © 2020-2023  润新知