예제 #1
0
    private void OnCollisionExit2D(Collision2D other)
    {
        foreach (parentEntry e in parents)
        {
            if (e.gameObject == other.gameObject)
            {
                e.gameObject.transform.parent = e.previous;
                Debug.Log(e.gameObject.name + " is getting un-childed from" + gameObject.name);
            }
        }
        parents.RemoveAll(parentEntry => parentEntry.gameObject == other.gameObject);

        if (other.gameObject.transform.position.y > gameObject.transform.position.y)
        {
            moveObjectsOnTop script = other.gameObject.GetComponent <moveObjectsOnTop>();
            if (script != null)
            {
                if (script.addedDynamically)
                {
                    script.resetParents();
                    Destroy(script);
                    Debug.Log(other.gameObject.name + " is losing its script from " + gameObject.name);
                }
            }
        }
    }
예제 #2
0
    public void resetParents()
    {
        Debug.Log(gameObject.name + " is having all parents reset");
        foreach (parentEntry e in parents)
        {
            e.gameObject.transform.parent = e.previous;
            moveObjectsOnTop script = e.gameObject.GetComponent <moveObjectsOnTop>();
            if (script != null)
            {
                if (script.addedDynamically)
                {
                    script.resetParents();
                }
            }
        }

        parents.Clear();
    }