using UnityEngine;
using System.Collections;
public class ExCube : MonoBehaviour {
public GameObject[] Cubes;
float scale = 1.0f;
bool isAdd = true;
// Use this for initialization
void Start () {
for(int i = 1; i <=10; i++){
Cubes[ i -1] = GameObject.Find ("Cube" + i);
Move(Cubes[ i -1 ], 2 * i, 0, 0);
}
}
void Move(GameObject object1, float x, float y, float z){
Vector3 pos = object1.transform.position;
object1.transform.position = new Vector3(pos.x + x, pos.y + y, pos.z + z);
}
void Set(GameObject object1, float x, float y, float z){
object1.transform.position = new Vector3(x, y, z);
}
// Update is called once per frame
void Update () {
for(int i = 0; i < Cubes.Length; i++){
if(Time.time < 5.0f){
Move(Cubes[i], 0.001f, 0, 0);
}
else if(Time.time < 10.0f){
scale += 0.001f;
Scale(Cubes[i], scale, scale, scale);
}
}
/*
scale += 0.01f;
if(isAdd)
scale += 0.01f;
else
scale -= 0.01f;
if(scale >= 1.0f)
isAdd = false;
if(scale <= 0)
isAdd = true;
for(int i = 0; i < 10; i++){
//Move(Cubes[i], 2 * i + Time.time * 1.5f, 0, 0);
//Scale(Cubes[i], i * 2 + Time.time, 1, 1);
Scale(Cubes[i], scale, scale, scale);
}
*/
}
void Scale(GameObject object1, float x, float y, float z){
object1.transform.localScale = new Vector3(x, y, z);
}
}
'Computer Language > 유니티' 카테고리의 다른 글
string 삭제 & 삽입 (0) | 2014.04.15 |
---|---|
letter (0) | 2014.04.15 |
아이템 배열 Out 을 참조 (0) | 2014.04.14 |
parameter (0) | 2014.04.14 |
out참조 (변수가 좀더 필요로 할때.) (0) | 2014.04.14 |