Пример #1
0
    public void RegisterObject(GameObject g, bool isStatic = false)
    {
        objects.Add(g);

        WrapClones newClones = new WrapClones(g, bounds, isStatic);

        cloneList.Add(newClones);
        newClones.UpdateClones();
    }
Пример #2
0
    public void UnRegisterObject(GameObject g)
    {
        objects.Remove(g);
        WrapClones clones = cloneList.Find(x => x.original == g);

        if (clones == null)
        {
            return;
        }
        clones.DestroyClones();
        cloneList.Remove(clones);
    }
Пример #3
0
    public void StopClonesUpdate(GameObject g)
    {
        GameObject.Destroy(g.GetComponent <SheetAnimation>());
        WrapClones clones = cloneList.Find(x => x.original == g);

        for (int i = clones.clones.Length - 1; i >= 0; i--)
        {
            GameObject clone = clones.clones[i];
            if (clone == null)
            {
                continue;
            }
            if (Mathf.Abs(clone.transform.position.x - bounds.center.x) - 0.16f > bounds.size.x / 2f ||
                Mathf.Abs(clone.transform.position.y - bounds.center.y) - 0.16f > bounds.size.y / 2f)
            {
                GameObject.Destroy(clone);
            }
        }
        objects.Remove(g);
        cloneList.Remove(clones);
    }