是否有使用C#委託的Unity3D補間庫?我一直在使用iTween和LeanTween,但代替它們需要方法名稱以字符串形式調用,這會導致代碼非常難看。我想用苗條lambda來替換所有的自定義方法,但是這些庫不提供這樣的功能。使用C#委託的Unity3D吐溫庫
0
A
回答
0
不知道的代表,但是這個小班從來沒有讓我失望
public class Tween {
public static float TweenValue (float from,float to,float time)
{
if (from != to)
{
if (Mathf.Abs(to-from) > 1.0)
{
from = Mathf.Lerp(from, to, time*Time.deltaTime);
}
else
{
from = to;
}
}
return from;
}
public static Rect TweenRect (Rect from,Rect to,float time){
if (from != to)
{
from.x = TweenValue (from.x,to.x,time*Time.deltaTime);
from.y = TweenValue (from.y,to.y,time*Time.deltaTime);
from.width = TweenValue (from.width,to.width,time*Time.deltaTime);
from.height = TweenValue (from.height,to.height,time*Time.deltaTime);
}
return from;
}
public static Vector3 TweenVector3 (Vector3 from ,Vector3 to,float time)
{
if (from != to)
{
if (Mathf.Abs((to-from).magnitude) > 0.2)
{
from = Vector3.Slerp(from, to, time);
}
else
{
from = to;
}
}
return from;
}
public static Quaternion TweenQuaternion (Quaternion from,Quaternion to,float time)
{
if (from != to)
{
if (Mathf.Abs((to.eulerAngles-from.eulerAngles).magnitude) > 0.2)
{
from = Quaternion.Slerp(from, to, time);
}
else
{
from = to;
}
}
return from;
}
}
0
LeanTween的新版本提供的onComplete和的onUpdate代表不依賴於字符串名稱。瞭解關於LeanTween 2.0中所有新功能的更多信息:http://dentedpixel.com/developer-diary/leantween-2-0-faster-type-safe-and-c/
相關問題
- 1. Unity3D:使用委託返回值
- 2. 使用委託C#
- 3. C# - 使用委託
- 4. 委託不使用C#
- 5. 使用委託在C#
- 6. C++委託行使
- 7. FLEX - 吐溫videoPlayer.seek()
- 8. 吐溫動畫
- 9. Unity3d訪問int字段與button.onClick.AddListner(委託...)
- 10. 委託幫助 - 使用類委託用於委託內部
- 11. 使用委託
- 12. 使用委託
- 13. 如何在CLI :: C++中使用委託 - 匿名委託?
- 14. C#Func委託
- 15. LibGdx:吐溫引擎上的吐溫回調
- 16. C#:行動委託vs明確委託
- 17. 吐溫sprite或uicomponent?
- 18. AS3吐溫陣列
- 19. AS3吐溫凍結
- 20. Mootools吐溫問題
- 21. AS3吐溫緩解
- 22. 使用GreenSock,吐溫函數參數
- 23. 爲吐溫開發模擬或虛擬吐溫源
- 24. AS2 TweenLite的:吐溫到幀
- 25. 庫更改委託簽名使用它
- 26. C#GetDelegateForFunctionPointer與通用委託
- 27. C#從調用,委託
- 28. C#委託調用兩次?
- 29. 使用委託者
- 30. 使用System.Window.Forms.Invoke(委託)
我不知道。誠實補間並不難,而且很有趣。我個人實現了我自己的lib(當然使用代表)。你爲什麼不嘗試編寫自己的代碼? – Heisenbug
因爲我喜歡使用現有的解決方案,而不是再發明它們;) –
您是否嘗試過Prime31的GoKit? http://prime31.com/docs#goKit它似乎使用'Action onComplete'作爲Tweens的參數。 –
Calvin