//**********************************************************************
// 文件名(File Name): CommomTranfrom.cs
// 作者(Author): 飞
// 创建时间(CreateTime): 1/18/2019
// **********************************************************************
using FrameWork;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace FrameWork_VR
{
public class CommomTranfrom : MonoBehaviour
{
public List<CommonTarget> targets;
private Coroutine coroutine;
public void OnEnable()
{
coroutine = StartCoroutine(Common());
}
public void OnDisable()
{
if (coroutine != null) StopCoroutine(coroutine);
}
IEnumerator Common()
{
if (targets == null || targets.Count <= 0) yield break;
while (true)
{
if (targets.Count <= 0) yield break;
foreach (var item in targets)
{
if (item == null) continue;
item.CommonTargt();
yield return null;
}
}
}
}
[Serializable]
public class CommonTarget
{
public Transform copyTarget;
public Transform goalTarget;
public void CommonTargt()
{
goalTarget.position = copyTarget.position;
goalTarget.rotation = copyTarget.rotation;
}
}
}