Gamerch
あかさ

関数その1

最終更新日時 :
1人が閲覧中
作成者: ユーザー98083
最終更新者: ユーザー98083

表示

static public void ログ表示<T>(T A)
{ Debug.Log(A); }
static public void テキスト表示<T>(GameObject A, T B)
{ if (A.GetComponent<Text>() != null)
A.GetComponent<Text>().text = B.ToString();
if(A.GetComponentInChildren<Text>()!=null)
A.GetComponentInChildren<Text>().text= B.ToString();
if(A.GetComponent<TextMeshProUGUI>()!=null)
A.GetComponent<TextMeshProUGUI>().text= B.ToString();
}
static public void 非表示(GameObject A) { A.SetActive(false); }
static public void 表示(GameObject A) { A.SetActive(true); }
public static void 削除(GameObject A, float 秒数 = 0)
{UnityEngine.Object.Destroy(A, 秒数); }
public static GameObject 作成(GameObject 物, Vector3 位置, Quaternion 回転)
{ return UnityEngine.Object.Instantiate(物, 位置, 回転); }

移動回転

static public void 移動(GameObject A, Vector3 方向, float 速度 = 3)
{ A.transform.Translate(方向.normalized * 速度 * Time.deltaTime, Space.World); }
static public void ローカル移動(GameObject A, Vector3 方向, float 速度 = 3)
{ A.transform.Translate(方向.normalized * 速度 * Time.deltaTime); }
static public void 瞬間移動(GameObject A, Vector3 座標)
{ A.transform.position = 座標; }
static public void 目的地移動(GameObject A, Vector3 座標,float 速度=5)
{
A.transform.position = Vector3.MoveTowards(
A.transform.position,
A.transform.position+座標,
速度* Time.deltaTime
);
}

static public void 拡大(GameObject A, float B, float 速度 = 5)
{
A.transform.localScale = Vector3.Lerp(
A.transform.localScale,
new Vector3(B, B, B),
Time.deltaTime * 速度);
}
static public void 回転(GameObject A, Vector3 角度, float 速度 = 90)
{
A.transform.rotation = Quaternion.RotateTowards(
A.transform.rotation,
Quaternion.Euler(角度),
速度 * Time.deltaTime
);
}
static public void 向く回転(GameObject A, Vector3 座標, float 速度 = 0.1f)
{
Vector3 向く方向 = 座標 - A.transform.position;
A.transform.rotation = Quaternion.Slerp(A.transform.rotation, Quaternion.LookRotation(向く方向), 速度); }

public static void クリック時(GameObject ボタン, Action 処理)
{
Button b = ボタン.GetComponent<Button>();
b.onClick.RemoveAllListeners();
b.onClick.AddListener(() => 処理() );
}
public static void BGM再生(GameObject A,AudioClip B)
{
A.GetComponent<AudioSource>().clip = B;
A.GetComponent<AudioSource>().Play();
}
public static void 効果音再生(GameObject A, AudioClip B)
{
A.GetComponent<AudioSource>().PlayOneShot(B);
}
コメント (関数その1)
  • 総コメント数0
この記事を作った人
やり込み度

Wikiにゲームが紐づいていません

編集者紹介

未登録

注目記事
ページトップへ