Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Repozitorijs ir arhivēts. Tam var aplūkot failus un to var klonēt, bet nevar iesūtīt jaunas izmaiņas, kā arī atvērt jaunas problēmas/izmaiņu pieprasījumus.

49 rindas
1.3KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. /// <summary>
  7. /// Fades the target to the given alpha value. The tartet shaders should support transparency in order to use this action.
  8. /// </summary>
  9. class ActionFadeTo : ActionInterval
  10. {
  11. protected float value;
  12. protected float delta;
  13. public ActionFadeTo(float tgtValue, float tgtDuration)
  14. : base(tgtDuration)
  15. {
  16. value = tgtValue;
  17. }
  18. /// <summary>
  19. /// Returns a copy of the action.
  20. /// </summary>
  21. public override ActionInstant clone()
  22. {
  23. return new ActionFadeTo(value, duration);
  24. }
  25. /// <summary>
  26. /// This method is called at the action start.
  27. /// </summary>
  28. public override void start()
  29. {
  30. base.start();
  31. delta = value - renderer.material.color.a;
  32. }
  33. /// <summary>
  34. /// This method is called every frame update.
  35. /// </summary>
  36. public override void stepInterval(float dt)
  37. {
  38. float d = dt / duration;
  39. Color tgtColor = renderer.material.color;
  40. tgtColor[3] += delta * d;
  41. renderer.material.color = tgtColor;
  42. }
  43. }
  44. }