"Difficult and miscellaneous"
0. Introduction
I have encountered some "difficult and miscellaneous" Problems in my recent work. I would like to make a simple note here, and I am sorry for this ~
1. It's all about waitforseconds ~
Currently, hotween is used in many developed games. I personally think it is quite good (in other words, hotween's second version of dotween should soon be officially release, and various improvements are coming soon :)), if you are interested in the recommendation, try it. Although you feel that hotween is still quite smooth, you still have to step on the following:
For some continuous tween effects, the combination of hotween + yield return New waitforseconds is quite easy to understand. As a result, code similar to the following occurs in many parts of the project:
Hotween. To (<effect run duration time> );
Yield return New waitforseconds (<duration time> );
Hotween. (...);
In most cases, the above Code runs well, but in rare cases (especially in real machine testing), there will be an animation (Tween) error, moreover, it is extremely difficult to reproduce and very random. I checked it intermittently for a long time. I imagined many possible reasons and made many fixes accordingly. I still felt uneasy, because the "root" of the disease did not find it, and then after a lot of tests to find some ways, "Shun Teng touch melon" finally "diagnosed" the cause, it turns out that all of this is caused by waitforseconds :)
I have probably learned some of the hotween implementation source code. In principle, it is quite traditional. It is probably that hotween keeps updating through an update. to or from Apis such as the generated abstweencomponent (hotween in the Tweener, sequence are inherited from him), of course, a lot of details, here will not be repeated, it is worth mentioning that hotween depends on the time logic of unity. That is to say, if the above code is used as an example:
Hotween. To (<effect run duration time> );
Among them, the animation (Tween) time duration, hotween is offset by time. time-tweenstarttime is a type of control. This control method is intuitive and generally no problem. However, when waitforseconds is used together, it becomes a problem ......
The problem is that the waitforseconds timing method is different from that of hotween! (I am not very clear about how to make a difference, and some people who know it may as well tell me) "Naive" I guess it is likely that the waitforseconds timing is slightly faster than that of hotween, that is, if waitforseconds shows that the time has passed 1 s, hotween may still feel that the time has only passed 0.9 s ...... Of course, the gap between the two is far from so exaggerated in the actual program running, but it is basically certain that they will not be consistent. When the gap between the two is occasionally too large, for example, when there is more than one frame, the "weird" animation problem may occur. Consider the above Code:
Hotween. To (<effect run duration time> );
Yield return New waitforseconds (<duration time> );
// Previous Tweener cocould still running ......
Hotween. (...);
Although you have used waitforseconds to wait for the duration time, but in fact, the animation will continue to run after yield, as compared to hotween, the duration time has not yet reached (feeling a bit of relativity, this is contrary to the logic assumption of your code. Naturally, there will be or this or that strange problem ......
Based on this, I changed the animation control mode. The code is like this:
Bool istweenend = false;
Hotween. To (<effect run duration time when end it will set "istweenend" to true> );
While (! Istweenend ){
Yield return NULL;
}
Hotween. (...);
After this change, all the strange animation problems were "STOPPED ......
2. WTF, Android version crashes randomly !?
Currently, an android test version is released for the game. It can be run on Galaxy Note (Android 4.1.1), but it can be run on Red Rice note (Android 4.4.2) various crashes (almost "anytime, anywhere" crash). The log shows that it is a block error, which is really confusing. After several attempts by Google and multiple parties, to find a fix solution:
Here is a detailed discussion (the above is also from here). If you are interested, you can check it out :)
OK. That's all ~
"Difficult and miscellaneous"