Skip to content

Instantly share code, notes, and snippets.

@peroon
Last active July 12, 2016 08:37
Show Gist options
  • Select an option

  • Save peroon/2d7815b4ed8a009457503b1d257378e4 to your computer and use it in GitHub Desktop.

Select an option

Save peroon/2d7815b4ed8a009457503b1d257378e4 to your computer and use it in GitHub Desktop.
SetPass CallとFPSの関係を調べる.cs
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Test : MonoBehaviour {
public GameObject meshPrefab;
public Transform cubeRoot;
public InputField generateNum;
void Start () {
}
void Update () {
}
public void OnClickGenerate(){
// 数値
int num = int.Parse(generateNum.text);
Debug.Log (num + "個生成します");
// 子供全削除
foreach (Transform t in cubeRoot) {
Destroy (t.gameObject);
}
// 生成
for (int i = 0; i < num; i++) {
// 位置
var t = i / (float)num;
float x = Mathf.Lerp(-8.0f, 8.0f, t);
float y = 4.0f * Mathf.Sin (i / 10.0f);
var position = new Vector3 (x, y, 0);
var go = Instantiate (meshPrefab, position, Quaternion.identity) as GameObject;
go.GetComponent<Renderer> ().material.color = new Color (Random.value, Random.value, Random.value);
// 親につける
go.transform.SetParent (cubeRoot);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment