TextureKeyframeGroup.cs 865 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace Funly.SkyStudio
  6. {
  7. [Serializable]
  8. public class TextureKeyframeGroup : KeyframeGroup<TextureKeyframe>
  9. {
  10. public TextureKeyframeGroup(string name, TextureKeyframe keyframe) : base(name)
  11. {
  12. AddKeyFrame(keyframe);
  13. }
  14. public Texture TextureForTime(float time)
  15. {
  16. if (keyframes.Count == 0)
  17. {
  18. Debug.LogError("Can't return texture without any keyframes");
  19. return null;
  20. }
  21. if (keyframes.Count == 1)
  22. {
  23. return GetKeyframe(0).texture;
  24. }
  25. int beforeIndex, afterIndex;
  26. GetSurroundingKeyFrames(time, out beforeIndex, out afterIndex);
  27. TextureKeyframe before = GetKeyframe(beforeIndex);
  28. return before.texture;
  29. }
  30. }
  31. }