Unity uses DotweenPath on UGUI to have a path offset problem

1. Offset problem

Because I want to make a path animation on ugui, the edited path will be offset as soon as it runs. The situation is as follows
Insert picture description here
. There are two necessary conditions for this situation.

  1. Canvas zoom is not 1
    Insert picture description here
  2. DotweenPath checked Relative
    Insert picture description here

2. Solution

  1. Open the Script Execution Order
    Insert picture description here
    and add the Path, it must be 大于0, and then there is no error in the operation!
  2. Then remove the option
    Insert picture description here

3. Why does this happen

I decompiled the dotweenpath code, and found that checking Relativeis actually adding an offset to the original position. The
Insert picture description here
Insert picture description here
problem lies in this Vector3 position = base.transform.positionand lastSrcpostionabove. The
default lastSrcpostion=0, but Vector3 position = base.transform.positionthe value obtained during execution is UI RectTransform的anchoredPosition3D, then at this time lastSrcpostion=RectTransform.anchoredPosition3D, but in dotweenpath The point information of is calculated according to the world coordinates. At this time, there is a problem with the calculated offset, which causes the entire coordinate point to be offset., the example in the figure below,
The picture coordinates are (100, 200), and the canvas zoom is 2.44
and then I wrote the Test.csscript and hung it on it. The
Insert picture description here
print result:
Insert picture description here
You can see to lastSrcPositionget that RectTransform.anchoredPosition3Dvalue. so has led to the emergence of this problem.
when it is time to 1 Canvas does not appear
Insert picture description here

Digression

dotweenThe author did not consider applying dotweenpathit to UGUI
Insert picture description here

Guess you like

Origin blog.csdn.net/K20132014/article/details/106270360