public void BuildObject() { int index = GetIndex(); GameObject obj = new GameObject(); obj.AddComponent <TrackNode> (); obj.name = "TrackNode" + (index + 1); obj.transform.SetParent(transform.parent, true); TrackNode trackNode = obj.GetComponent <TrackNode>(); trackNode.Init(this); #if UNITY_EDITOR UnityEditor.Selection.activeGameObject = obj; #endif }