Пример #1
0
    // Update is called once per frame
    void Update()
    {
        frag = (Mathf.Sin(Time.time) + 1) / 2.0f;
        this.transform.position = Vector3.Lerp(pos1, pos2, frag);

        time += Time.deltaTime;

        if (time > 0.15f)
        {
            GameObject go = UGBObjectPool.GetObjectInstance(1);
            go.transform.position = this.transform.position;
            instances.Add(go);
            time = 0;
            Stack <GameObject> stack = new Stack <GameObject>(instances);
            while (stack.Count > 0)
            {
                GameObject el = stack.Pop();
                if (el.transform.position.y < -1500)
                {
                    el.transform.rigidbody.velocity        = Vector3.zero;
                    el.transform.rigidbody.angularVelocity = Vector3.zero;
                    UGBObjectPool.ReturnObjectInstance(el, 1);
                }
            }
        }
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        GameObject pr = GameObject.CreatePrimitive(PrimitiveType.Cube);

        UGBObjectPool.AddObjectDefinition(pr, 1);
    }