using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; namespace DTYJ { public class LingShiChuLi : MonoBehaviour { [ContextMenu("处理")] public void Handle000() { } private void 处理站台门模型名称() { for (int i = 0; i < 30; i++) { //transform.GetChild(i).GetChild(0).name = "0"; //transform.GetChild(i).GetChild(1).name = "1"; //transform.GetChild(i).localPosition = new Vector3(0, 0, -4.4122f * i); GameObject goNew = GameObject.Instantiate(transform.GetChild(0).gameObject) as GameObject; goNew.transform.SetParent(transform, false); goNew.name = (i + 1).ToString(); goNew.transform.localPosition = new Vector3(0, 0, -4.4122f * i); } } private void 处理电梯动画() { var origDown = transform.Find("Escalator1DirectionDown"); var origUp = transform.Find("Escalator1DirectionUp"); for (int i = 1; i <= 6; i++) { var down = transform.Find("Escalator" + i + "DirectionDown"); var up = transform.Find("Escalator" + i + "DirectionUp"); CreateOne(origDown.gameObject, down.gameObject, down.name); CreateOne(origUp.gameObject, up.gameObject, up.name); } Debug.Log("Done!!"); } private void CreateOne(GameObject orig, GameObject target, string nameNew) { var targetPosition = target.transform.GetChild(0).GetChild(0); var goNew = Instantiate(orig, targetPosition.position, targetPosition.rotation, target.transform.parent); goNew.transform.GetChild(0).GetChild(0).localPosition = Vector3.zero; goNew.transform.GetChild(0).GetChild(0).localRotation = Quaternion.identity; goNew.name = nameNew; goNew.SetActive(true); target.SetActive(false); } } }