示例#1
0
 public void RemoveLastSpawned()
 {
     if (lastSpawned)
     {
         clothPool.ReturnToPool(lastSpawned);
         lastSpawned = null;
     }
 }
示例#2
0
    public void Spawn(int number)
    {
        if (!lastSpawned || lastSpawned.number != number)
        {
            RemoveLastSpawned();

            PoolableCloth instance = clothPool.GetPrefabInstance(number);
            //instance.transform.position = transform.position; // set instance transform position to model position
            lastSpawned = instance;
        }
    }
示例#3
0
    // returns instance of prefab
    public PoolableCloth GetPrefabInstance(int number)
    {
        PoolableCloth instance;

        if (reusableInstances[number])
        {
            instance = reusableInstances[number];
            instance.gameObject.SetActive(true);
        }
        else
        {
            instance = Instantiate(prefabs[number], PoolableCloth.GetParentTransform(number));
            instance.AttachColliders();
        }
        return(instance);
    }
示例#4
0
 //returns prefab to pool
 public void ReturnToPool(PoolableCloth instance)
 {
     instance.gameObject.SetActive(false);
     // reset size and stretchiness
     reusableInstances[instance.number] = instance;
 }