-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCylinderSpawner.cs
65 lines (56 loc) · 1.92 KB
/
CylinderSpawner.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CylinderSpawner : MonoBehaviour
{
public GameObject LEDPrefab;
public float radiusTop = 0.03f;
public float radiusBottom = 0.75f;
public List<Vector3> positions;
void Start()
{
positions = new List<Vector3>();
for(int ii = 0; ii <10; ii ++)
{ var trns = transform.position;
if (ii == 0)
{
var pos = new Vector3(trns.x + radiusTop, trns.y, trns.z);
positions.Add(pos);
}
else if (ii < 2)
{
var pos = new Vector3(trns.x + radiusTop + (0.075f * (ii)), trns.y - (0.055f * (ii)), trns.z);
positions.Add(pos);
}
else if (ii < 7)
{
var pos = new Vector3(trns.x + radiusTop + (0.075f * (ii)), trns.y - (0.065f * (ii)), trns.z);
positions.Add(pos);
}
else
{
var pos = new Vector3(trns.x + radiusTop + (0.075f * (ii)), trns.y - (0.06f * (ii)), trns.z);
positions.Add(pos);
}
}
for (int ii = 0; ii < 10; ii++)
{
const float xadd = 0.075f * 9f + 0.0325f;
const float ysub = 0.065f * 9.0f + 0.048f;
var trns = transform.position;
var pos = new Vector3(trns.x + radiusTop + xadd, trns.y-ysub-0.06f*ii, trns.z);
positions.Add(pos);
}
int num = 0;
foreach(Vector3 pos in positions)
{
if (LEDPrefab != null)
{
var led = Instantiate(LEDPrefab, pos, transform.rotation);
led.name = num.ToString();
led.transform.SetParent(transform);
num++;
}
}
}
}