I have a script inside a child gameobject , I want to disable it through coding on the parent Object ,help will be much appreciated,thanks.
edit:the script I want to carry out all the actions is not attached to the parent gameobject.
I have a script inside a child gameobject , I want to disable it through coding on the parent Object ,help will be much appreciated,thanks.
edit:the script I want to carry out all the actions is not attached to the parent gameobject.
I hope this code is self commenting ;)
using UnityEngine;
using System.Collections;
public class ScriptAttachedToParent : MonoBehaviour
{
void Start ()
{
transform.GetChild (0).GetComponent<ScriptAttachedToChild> ().enabled = false;
// OR
//transform.Find("ChildGameObject").GetComponent<ScriptAttachedToChild> ().enabled = false;
}
}