using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Roation : MonoBehaviour {
//要找子物体的那个物体
private GameObject game;
public Transform parent, tracker;
//想找的子物体的名字
public string childName;
// Use this for initialization
void Start () {
childName = "Cube";
game = GameObject.Find ("Plan01");
tracker = GetTransform(game.transform, childName);
}
// Update is called once per frame
void Update () {
tracker.Rotate (new Vector3(0, 1, 0), 3);
tracker.RotateAround (new Vector3(0, 0, 0), new Vector3(0, 1, 0), 1);
}
Transform GetTransform(Transform check, string name)
{
foreach (Transform t in check.GetComponentsInChildren())
{
if (t.name == name)
{
//要做的事
Debug.Log(t.name);
return t;
}
}
return null;
}
}