//很多脚本里需要有个对象池的引用,所以统一通过该方法获取对池子的引用 //因为池子只用一个(或者说需要大家使用同一个池子),如果每次都调用GameObject.Find()方法有性能损失,所以使用了一种类似单例的方式实现 public static Ponds getBulletsPond() { if (singletonPonds == null) { singletonPonds = GameObject.Find("EnemyBulletPond").GetComponent <Ponds>(); } return(singletonPonds); }
void Start() { bulletsPond = Ponds.getBulletsPond(); }
void Start() { bulletParent = GameObject.Find("EnemyController"); bulletsPond = Ponds.getBulletsPond(); }
void Awake() { bulletsPond = Ponds.getBulletsPond(); }
void Start() { body = GetComponent <Rigidbody2D>(); bulletsPond = Ponds.getBulletsPond(); }
void Start() { bulletsPondObject = GameObject.Find("EnemyBulletPond"); bulletsPond = bulletsPondObject.GetComponent <Ponds>(); nextFire = Time.time + fireRate; }