unity disable parent object and enable child code example
Example 1: On add component unity
void Reset()
{
//Your code here
}
Example 2: unity prevent object from leaving camera view
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour {
void Update() {
Vector3 pos = Camera.main.WorldToViewportPoint (transform.position);
pos.x = Mathf.Clamp01(pos.x);
pos.y = Mathf.Clamp01(pos.y);
transform.position = Camera.main.ViewportToWorldPoint(pos);
}
}