public void init() { if (_prototype == null) { GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.transform.parent = this.transform; _prototype = cube.AddComponent <VoxelPoolObject> (); //Renderer renderer = cube.GetComponent<Renderer> (); //renderer.material = material; } if (_reserve == -1) { _reserve = 10; } _prototype.gameObject.SetActive(false); VoxelPoolObject[] list = new VoxelPoolObject[_reserve]; for (int i = 0; i < _reserve; ++i) { list[i] = this.create(); list[i].gameObject.SetActive(true); } for (int i = 0; i < _reserve; ++i) { list[i].gameObject.SetActive(false); } }
public VoxelPoolObject create() { VoxelPoolObject obj = null; if (_pool.Count == 0) { obj = GameObject.Instantiate(_prototype); obj.transform.parent = this.transform; obj.doDisable += delegate(VoxelPoolObject po){ if (doDisable != null) { doDisable(po); } this.destory(po); }; obj.doEnable += delegate(VoxelPoolObject po){ if (doEnable != null) { doEnable(po); } }; } else { obj = _pool.Pop(); } return(obj); }
public void Awake() { _prototype.gameObject.SetActive (false); VoxelPoolObject[] list = new VoxelPoolObject[_reserve]; for (int i =0; i <_reserve; ++i) { list[i] = this.create(); list[i].gameObject.SetActive(true); } for (int i =0; i <_reserve; ++i) { list[i].gameObject.SetActive(false); } }
public void Awake() { _prototype.gameObject.SetActive(false); VoxelPoolObject[] list = new VoxelPoolObject[_reserve]; for (int i = 0; i < _reserve; ++i) { list[i] = this.create(); list[i].gameObject.SetActive(true); } for (int i = 0; i < _reserve; ++i) { list[i].gameObject.SetActive(false); } }
private GameObject getCharObject(char ch) { if (map_.ContainsKey(ch)) { VoxelPoolObject obj = map_[ch]._pool._pool.create(); return(obj.gameObject); } for (int i = 0; i < _chars.Count; ++i) { if (_chars[i]._char == ch) { VoxelPoolObject obj = _chars[i]._pool._pool.create(); return(obj.gameObject); } } return(null); }
public void emission() { for (int i = 0; i < _parameter._count; ++i) { VoxelPoolObject obj = _pool.create(); VoxelParticle particle = obj.GetComponent <VoxelParticle>(); particle.gameObject.SetActive(true); Vector3 director = new Vector3(Random.Range(_parameter._beginDirector.x / 2, _parameter._endDirector.x / 2), Random.Range(_parameter._beginDirector.y / 2, _parameter._endDirector.y / 2), Random.Range(_parameter._beginDirector.z / 2, _parameter._endDirector.z / 2)); particle.director = director.normalized; if (_parameter._shape == null) { particle.position = this.transform.position; } else { particle.position = _parameter._shape.getPosition(this.transform); } particle.speed = Random.Range(_parameter._speed.x, _parameter._speed.y); particle.time = Random.Range(_parameter._time.x, _parameter._time.y); if (_parameter._color == null) { particle.beginColor = _parameter._beginColor; particle.endColor = _parameter._endColor; } else { VoxelEmitterColor.Pair pair = _parameter._color.color(); particle.beginColor = pair.begin; particle.endColor = pair.end; } particle.beginScale = _parameter._beginScale; particle.endScale = _parameter._endScale; particle.method = _parameter._method; particle.gameObject.layer = this.gameObject.layer; particle.emission(); } }
public void destory(VoxelPoolObject obj) { _pool.Push(obj); }
public void destory(VoxelPoolObject obj) { //obj.transform.SetParent(this.transform); _pool.Push (obj); }