コード例 #1
0
    public void MakeItem()
    {
        GameObject item = GoodsCupObjectPool.GetObject();

        item.transform.position = Vector3.zero;
        float ranScale = Random.Range(0.1f, 0.7f);

        item.transform.localScale = new Vector3(ranScale, ranScale, 0.3f);
        Rigidbody2D itemRigid = item.GetComponent <Rigidbody2D>();

        Vector2 popVect = new Vector2(Random.Range(-1f, 1f), Random.Range(2f, 3f));

        itemRigid.AddForce(popVect, ForceMode2D.Impulse);

        StartCoroutine("DestroyGoods", item);
    }
コード例 #2
0
 private void Awake()
 {
     Instance = this;
     Initialize(30);
 }
コード例 #3
0
    IEnumerator DestroyGoods(GameObject returnThis)
    {
        yield return(new WaitForSeconds(3f));

        GoodsCupObjectPool.ReturnObject(returnThis);
    }