- Home /
The question is answered, right answer was accepted
Help required please. Unity suggests I use 'Find([mscorlib]) System.String' instead of "obsolete' FindChild... I have no idea how to do this. Would love help please.
Hi guys, I'm new here and I am hoping that I can find some help...
this line:
// Vector3 curPos = this.transform.FindChild ("Plane").position;
is throwing a warning in unity saying that the:
'UnityEngine.Transform.FindChild' is obsolete; 'FindChild has been depreceated. Use Find instead (UnityUpgradable)-> Find([mscorlib] System.String)'.
I'm following a vid on PluralSight for creating a light switch puzzle game. However, it seems Unity no longer uses FindChild, but I don't know how to use the alternative that Unity has suggested. I have added the code the vid used and continued on with. None of the previous comments on the course mention having this error, though the last comment made was a year ago and Unity has updated since. the 3 instances of FindChild in the code each call up the previously mentioned warning.
public void change(){ // Lights will change position as they change between on and off. Updated plane from cube.
Vector3 curPos = this.transform.FindChild ("Plane").position;
if(isOn){
isOn = false; // lights off.
this.transform.FindChild ("Plane").position = new Vector3(curPos.x,curPos.y,curPos.z +.5f);
}else{
isOn =true; // Lights on
this.transform.FindChild ("Plane").position = new Vector3(curPos.x,curPos.y,curPos.z -.5f);
}
}
Answer by ShadyProductions · Feb 12, 2018 at 07:42 AM
Well, just use 'Find' as suggested.
this.transform.Find("Plane")
https://docs.unity3d.com/ScriptReference/Transform.Find.html
I'm new to scripting, the mscorlib bit had me thinking it was something very complicated. I do love simple!
mscorlib: $$anonymous$$ulti-language Standard Common Object Runtime Library
Basically it's the heart of the .net framework
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Restricting movement with Mathf.Clamp 4 Answers
How can i prevent from mouse to collide with thirdpersoncontroller ? 0 Answers
How to Find gameObject child. 3 Answers