关于 int Mathf.PingPong(t, length); 原理,相当于
#include <iostream> #include <vector> int test(int t, int length) { if(t / length % 2 == 1) return length - t % length; else return t % length; } int main() { int length = 3; std::vector<int> vect{0,1,2,3,4,5,6,7,8}; for(auto& item : vect) { std::cout<<test(item,length)<<","; } }
说明参见:http://forum.unity3d.com/threads/mathf-repeat-vs-mathf-pingpong.1388/
原文:http://www.cnblogs.com/tianyajuanke/p/5161969.html