Example #1
0
    public void Return(GoItem item)
    {
        string path = item.resourcePath;

        if (path == null || path.Length == 0)
        {
            Destroy(item.gameObject);
            return;
        }

        if (item.gameObject.activeSelf == false)
        {
            return;
        }

        Stack stack = GetStack(path);

        stack.Push(new WeakReference(item.gameObject));
        item.OnGoingIntoPool();
        MatchParent(item);
        item.transform.localPosition = Vector3.up * 9999;
        item.gameObject.SetActive(false);
        Rigidbody rb = item.GetComponent <Rigidbody>();

        if (rb != null)
        {
            rb.velocity        = Vector3.zero;
            rb.angularVelocity = Vector3.zero;
        }
    }