AnimGlyphs.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. // ----------------------------------------------------------------------
  2. // File: VTextEditorLayout
  3. // Organisation: Virtence GmbH
  4. // Department: Simulation Development
  5. // Copyright: © 2014 Virtence GmbH. All rights reserved
  6. // Author: Silvio Lange (dirk.schulz@virtence.com)
  7. // ----------------------------------------------------------------------
  8. using UnityEngine;
  9. using System.Collections;
  10. namespace Virtence.VText.Demo {
  11. /// <summary>
  12. /// Simple Animation for glyphs.
  13. /// Just a sinus wave on y-axis...
  14. /// </summary>
  15. public class AnimGlyphs : MonoBehaviour {
  16. #region Publics
  17. public float Amplitude = 0.02f; //the amplitude defines the moving range on y-axis
  18. public float FrequencyFactor = 1.0f; //the frequency factor defines the sinus strech on x-axis
  19. #endregion //Publics
  20. #region METHODS
  21. void Update () {
  22. for(int k=0; k < this.transform.childCount; k++) {
  23. Transform t = this.transform.GetChild(k);
  24. float dist = (t.localPosition.x + FrequencyFactor*Mathf.PI * Time.time);
  25. t.localPosition = new Vector3(t.localPosition.x,
  26. t.localPosition.y + (Mathf.Sin(dist)*Amplitude),
  27. t.localPosition.z);
  28. }
  29. }
  30. #endregion //Methods
  31. }
  32. }