You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.6 KiB

7 years ago
  1. #pragma strict
  2. import DentedPixel;
  3. #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5
  4. public var button:RectTransform;
  5. function Start () {
  6. Debug.Log("For better examples see the 4.6_Examples folder!");
  7. if(button==null){
  8. Debug.LogError("Button not assigned! Create a new button via Hierarchy->Create->UI->Button. Then assign it to the button variable");
  9. return;
  10. }
  11. // Tweening various values in a block callback style
  12. LeanTween.value(button.gameObject, button.anchoredPosition, new Vector2(200f,100f), 1f ).setOnUpdateVector3(
  13. function(val:Vector3){
  14. button.anchoredPosition = new Vector2(val.x, val.y);
  15. }
  16. );
  17. LeanTween.value(gameObject, 1f, 0.5f, 1f ).setOnUpdate(
  18. function(volume:float){
  19. Debug.Log("volume:"+volume);
  20. }
  21. );
  22. LeanTween.value(gameObject, gameObject.transform.position, gameObject.transform.position + new Vector3(0,1f,0), 1f ).setOnUpdateVector3(
  23. function(val:Vector3){
  24. gameObject.transform.position = val;
  25. }
  26. );
  27. LeanTween.value(gameObject, Color.red, Color.green, 1f ).setOnUpdateColor(
  28. function(val:Color){
  29. var image:UnityEngine.UI.Image = button.gameObject.GetComponent( UnityEngine.UI.Image );
  30. image.color = val;
  31. }
  32. );
  33. // Tweening Using Unity's new Canvas GUI System
  34. LeanTween.move(button, new Vector3(200f,-100f,0f), 1f).setDelay(1f);
  35. LeanTween.rotateAround(button, Vector3.forward, 90f, 1f).setDelay(2f);
  36. LeanTween.scale(button, button.localScale*2f, 1f).setDelay(3f);
  37. LeanTween.rotateAround(button, Vector3.forward, -90f, 1f).setDelay(4f).setEase(LeanTweenType.easeInOutElastic);
  38. }
  39. #endif