///Created by Neodrop neodrop@unity3d.ru
// Freez object in scene to avoid undesirable changes
@script ExecuteInEditMode()
function Start()
{
	if (!Application.isPlaying)
	{
		Reset();
	}
	else RestoreEditing();
}

@ContextMenu ("Restore Editing Mode")
function RestoreEditing()
{
	gameObject.hideFlags = 0;
	var childsCount = transform.childCount;
	for (var i : int = 0; i < childsCount; i++) transform.GetChild(i).gameObject.GetComponent(TakeYourHandOFF).RestoreEditing();
}

function Reset()
{
	var childsCount = transform.childCount;
	for (var i : int = 0; i < childsCount; i++)
	{
		if(!transform.GetChild(i).GetComponent(TakeYourHandOFF))
		transform.GetChild(i).gameObject.AddComponent(TakeYourHandOFF);
		else transform.GetChild(i).GetComponent(TakeYourHandOFF).gameObject.hideFlags = HideFlags.NotEditable ;
	}
	gameObject.hideFlags = HideFlags.NotEditable ;
}