個人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

相關文章
相關標籤/搜索