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
. There are two necessary conditions for this situation.
- Canvas zoom is not 1
- DotweenPath checked Relative
2. Solution
- Open the Script Execution Order
and add the Path, it must be大于0
, and then there is no error in the operation! - Then remove the option
3. Why does this happen
I decompiled the dotweenpath code, and found that checking Relative
is actually adding an offset to the original position. The
problem lies in this Vector3 position = base.transform.position
and lastSrcpostion
above. The
default lastSrcpostion=0
, but Vector3 position = base.transform.position
the 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,
and then I wrote the Test.cs
script and hung it on it. The
print result:
You can see to lastSrcPosition
get that RectTransform.anchoredPosition3D
value. so has led to the emergence of this problem.
when it is time to 1 Canvas does not appear
Digression
dotween
The author did not consider applying dotweenpath
it to UGUI