为了账号安全,请及时绑定邮箱和手机立即绑定

为什么运行起来一直不对

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">寻找的物体名称</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 () {

}

}



正在回答

2 回答

具体说一下,或截个图

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为什么运行起来一直不对

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信