using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

[ExecuteInEditMode]
public class SetAsLastScript : MonoBehaviour {
#if UNITY_EDITOR
	[HideInInspector]
	public List<Transform> myChildren;

	void Update () {
		transform.SetAsLastSibling ();
		foreach (Transform t in transform) {
			bool belongsHere = false;
			for (int i = 0; i < myChildren.Count; i++) {
				if (t == myChildren [i]) {
					belongsHere = true;
					break;
				}
			}
			if (!belongsHere) {
				t.parent = null;
			}
		}
	}
#endif
}
