个人Unity冷知识记录

  • UGUI图片沿X或Y翻转180°后会失去射线检测效果[2018.1]
缘由: Canvas的GraphicRaycaster的`Ignore Reversed Graphics`选项决定反转的Graphic是否会被射线检测忽略
  • Mask组件的Show Mask Graphic属性在Animation动画中改变后无效 [2018.2]
多是bug
  • Editor中RectTransform的锚点消失[2018.2].
Bug: 重启Editor没用,须要关闭Scene标签后从新打开.或者试试在[Window]—>[Layouts]中从新应用窗口布局
  • Animator.Rebind()
在animator组件disable以前调用它,回滚动画到动画开始的状态.
Description 描述
Rebind all the animated properties and mesh data with the Animator.

从新绑定动画器的全部动画的属性和网格数据。

This function can be used when you manually change your GameObject hierarchy by script, like combining meshes or swap a complete transform hierarchy.

这个函数用于当你手动经过脚本修改对象的层级时使用,像合并网格或交换一个完整的变换层级。
  • Animator is not playing an AnimatorController.
若是gameobject的activeSelf=false,当你播放animator时,会获得此警告而且,设置参数是无效的.
  • Selectable 是先调用前一个的OnDeselect,而后再将Event System的SelectObject设为此物体,调用此物体OnSelect
// Event System
   public void SetSelectedGameObject(GameObject selected, BaseEventData pointer)
    {
      if (this.m_SelectionGuard)
      {
        Debug.LogError((object) ("Attempting to select " + (object) selected + "while already selecting an object."));
      }
      else
      {
        this.m_SelectionGuard = true;
        if ((UnityEngine.Object) selected == (UnityEngine.Object) this.m_CurrentSelected)
        {
          this.m_SelectionGuard = false;
        }
        else
        {
          ExecuteEvents.Execute<IDeselectHandler>(this.m_CurrentSelected, pointer, ExecuteEvents.deselectHandler);
          this.m_CurrentSelected = selected;
          ExecuteEvents.Execute<ISelectHandler>(this.m_CurrentSelected, pointer, ExecuteEvents.selectHandler);
          this.m_SelectionGuard = false;
        }
      }
    }
  • 在Scence视图中选中Object以后,层级视图中被选中的物体没有被高亮[?].
多是层级视图标签激活了Lock:右键点击层级视图,去掉Lock的勾选.
  • Ps中F8查看选中图层的大小,作UI动画的时候很方便.
  • Android studio 默认SDK路径C:\Users\adminxxx\AppData\Local\Android\Sdk
  • 脚本在Inspector中没有勾选框?

MonoBehaviour is the base class from which every Unity script derives. When you use C#, you must explicitly derive from MonoBehaviour. This class doesn't support the null-conditional operator (?.) and the null-coalescing operator (??). Note: There is a checkbox for disabling MonoBehaviour on the Unity Editor. It disables functions when unticked. If none of these functions are present in the script, the Editor does not display the checkbox. The functions are: Start() Update() FixedUpdate() LateUpdate() OnGUI() OnDisable() OnEnable()html

  • Awake()和Start()的区别?(颇有用,但容易被忽略) Generally the main difference is:
    Awake: Here you setup the component you are on right now (the "this" object) Start: Here you setup things that depend on other components.
    if you split it that way you can always be sure that the other object is ready to work with you as game objects in scenes on scene load are loaded in blocks:ide

    1. All awake are executed
    2. All start are executed
    3. all go into update
  • OnApplicationPause(bool)与Application.IsPlaying( Unity执行顺序OnApplicationPausse)函数

OnAppllicationPause被调用是在Pause指令发生后的一帧,可是在实际暂停的前一帧.Applcation.IsPlaying只在Editor中有用,在游戏端永远是True.
    Note:在Android上,当启用屏幕键盘时,它会致使OnApplicationFocus(false)事件。此外,若是在启用键盘时按“Home”,则不会调用OnApplicationFocus()事件,而是调用OnApplicationPause().
    Note:OnApplicationPause能够被协程.
  • 插件
- Mesh Baker 	烘培
- NSpeex		语音
- PoolManager 	对象池

快捷键相关

  • 动画窗口热键布局

    • K - Key all animated. Adds an keyframe for all animated properties at the current position of the playback head in the animation window.
    • Shift-K - Key all modified. Adds an keyframe for only those animated properties which have been modified at the current position of the playback head in the animation window.
    • R - Ripple editing(波纹编辑).Press and hold the R key while dragging inside the Box Selection to perform a Ripple Move.Press and hold the R key while dragging a Box Selection handle to perform a Ripple Scale.
  • UnityEDior在调试时报错:Fatal error in gc: GetThreadContext failed”,有多是杀毒或360软件引发的,关闭这些软件动画

  • 若是在Dotween的OnComplete()中调用DoRewind(),那么这个Tween的将不会完成,若是在协程中Yield Tween.WaitForCompletion(),则永远不会走到下一步!!this

相关文章
相关标签/搜索