91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

unity3d學習GUIFly腳本

發布時間:2020-02-27 04:00:33 來源:網絡 閱讀:428 作者:xiaoxuanyunmeng 欄目:游戲開發

用途:一個GUI對象在屏幕中飛行,用GameObject.SendMessage告訴GUI對象何時飛行。

使用:把該腳本拖到一個GameObject上,用另一個腳本GameObject.SendMessage發送飛行消息。

unity3d學習GUIFly腳本代碼 :

[javascript] view plaincopy
             
  //Attach this to the same as the GUIFly is attached to.
             
  // Fly in
             
  gameObject.SendMessage(“Fly”, true);
             
  // Wait 5 seconds
             
  yield new WaitForSeconds(5);
             
  // Fly out
             
  gameObject.SendMessage(“Fly”, false);
             
  [c-sharp] view plaincopy
             
  using UnityEngine;
             
  using System.Collections;
             
  public class GUIFly : MonoBehaviour
             
  {
             
  public enum InterpolationType
             
  {
             
  Linear,
             
  Sinusoidal,
             
  Hermite
             
  }
             
  public Vector3 m_InPosition;
             
  public Vector3 m_OutPosition;
             
  public float m_TravelTime = 0.5f;
             
  public float m_DelayToStartTravelingAfterMessageReceived = 0.1f;
             
  public bool m_StartWithInPosition = false;
             
  public InterpolationType m_InterpolationType = InterpolationType.Sinusoidal;
             
  void Start ()
             
  {
             
  transform.position = (m_StartWithInPosition) ? m_InPosition : m_OutPosition;
             
  }
             
  IEnumerator Fly(bool flyIn)
             
  {
             
  yield return new WaitForSeconds(m_DelayToStartTravelingAfterMessageReceived);
             
  Vector3 targetPosition = (flyIn) ? m_InPosition : m_OutPosition;
             
  float startTime = Time.time;
             
  Vector3 startPosition = transform.position;
             
  while (Time.time < startTime + m_TravelTime)
             
  {
             
  switch (m_InterpolationType)
             
  {
             
  case InterpolationType.Linear:
             
  transform.position = Vector3.Lerp(startPosition, targetPosition, (Time.time - startTime) / m_TravelTime);
             
  break;
             
  case InterpolationType.Sinusoidal:
             
  transform.position = Sinerp(startPosition, targetPosition, (Time.time - startTime) / m_TravelTime);
             
  break;
             
  case InterpolationType.Hermite:
             
  transform.position = Hermite(startPosition, targetPosition, (Time.time - startTime) / m_TravelTime);
             
  break;
             
  }
             
  yield return 0;
             
  }
             
  transform.position = targetPosition;
             
  }
             
  void Reset()
             
  {
             
  m_InPosition = transform.position;
             
  }
             
  private static Vector3 Sinerp(Vector3 start, Vector3 end, float value)
             
  {
             
  return new Vector3(Sinerp(start.x, end.x, value), Sinerp(start.y, end.y, value), Sinerp(start.z, end.z, value));
             
  }
             
  private static Vector3 Hermite(Vector3 start, Vector3 end, float value)
             
  {
             
  return new Vector3(Hermite(start.x, end.x, value), Hermite(start.y, end.y, value), Hermite(start.z, end.z, value));
             
  }
             
  /* The following functions are also in the Mathfx script on the UnifyWiki, but are included here so the script is self sufficient. */
             
  private static float Sinerp(float start, float end, float value)
             
  {
             
  return Mathf.Lerp(start, end, Mathf.Sin(value * Mathf.PI * 0.5f));
             
  }
             
  private static float Hermite(float start, float end, float value)
             
  {
             
  return Mathf.Lerp(start, end, value * value * (3.0f - 2.0f * value));
             
  }
             
  }


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

祁阳县| 双鸭山市| 昌黎县| 屯留县| 海门市| 兰溪市| 宁阳县| 顺平县| 时尚| 南乐县| 宜兴市| 怀安县| 米易县| 福州市| 静宁县| 台前县| 区。| 长春市| 定远县| 舞阳县| 桐梓县| 大化| 镇江市| 安陆市| 德江县| 小金县| 漯河市| 德兴市| 大田县| 杭锦旗| 寻甸| 万宁市| 老河口市| 包头市| 望谟县| 鹤壁市| 古交市| 开阳县| 阿拉善右旗| 台东县| 密山市|