Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
Ce dépôt est archivé. Vous pouvez voir les fichiers et le cloner, mais vous ne pouvez pas pousser ni ouvrir de ticket/demande d'ajout.

47 lignes
1.3KB

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