為什么運(yùn)行起來(lái)一直不對(duì)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour {
Transform translight;
Transform translight2;
public Transform ?TransRoot;
// Use this for initialization
void Start () {
? ? ? ? FindChild(TransRoot, "Light1", ref translight);
? ? ? ? FindChild(TransRoot, "Light2", ref translight2);
? ? ? ? translight.GetComponent<Light>().color = Color.red;
}
? ? /// <summary>
? ? /// 尋找物體
? ? /// </summary>
? ? /// <param name="trans">作為父物體的transform</param>
? ? /// <param name="findName">尋找的物體名稱(chēng)</param>
? ? /// <param name="_trans">找到的物體</param>
void FindChild(Transform trans,string findName,ref Transform _trans)
? ? {
? ? ? ? if (trans.name.Equals(findName))
? ? ? ? {
? ? ? ? ? ? _trans = trans.transform;
? ? ? ? ? ? return;
? ? ? ? }
? ? ? ? if (trans.childCount != 0)
? ? ? ? {
? ? ? ? ? ? for(int i = 0, length = trans.childCount; i <length; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? FindChild(trans.GetChild(i), findName, ref _trans);
? ? ? ? ? ? }
? ? ? ? }
? ? }
// Update is called once per frame
void Update () {
}
}
2017-04-30
具體說(shuō)一下,或截個(gè)圖