本文整理汇总了C#中UnityEngine.Transform.DetachChildren方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.DetachChildren方法的具体用法?C# Transform.DetachChildren怎么用?C# Transform.DetachChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Transform
的用法示例。
在下文中一共展示了Transform.DetachChildren方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DestroyChildren
// Update is called once per frame
public static void DestroyChildren(Transform transform)
{
for (int i = transform.childCount - 1; i >= 0; --i) {
#if UNITY_EDITOR_WIN
transform.GetChild(i).gameObject.hideFlags = HideFlags.None;
#endif
GameObject.DestroyImmediate(transform.GetChild(i).gameObject);
}
transform.DetachChildren();
}
示例2: Start
// Use this for initialization
void Start () {
textMesh = this.GetComponent<TextMesh>();
textMesh.alignment = TextAlignment.Center;
parent = transform.parent;
//textMesh.text = Truncate(parent.GetComponent<HFTGamepad>().getNetPlayer().Name,6);
if (gameObject.transform.parent.tag == "Mario" || gameObject.transform.parent.tag == "YellowLuigi")
{
yOffset = 1.24f;
// What tween do I put here oh god
//gameObject.transform.DOPunchScale(new Vector3(0.12f,0.12f),0.6f,2,3);
//gameObject.transform.DOShakeRotation(0.3f);
}
if (gameObject.transform.parent.tag == "Luigi" || gameObject.transform.parent.tag == "PurpleMario")
{
yOffset = 1.75f;
}
color = parent.GetComponent<Movement>().pipeSpawnColor;
parent.DetachChildren();
StartCoroutine(DestroyAndWait());
}
示例3: DestroyAllChildren
/// <summary>
/// Destroys all children of the specified transform.
/// </summary>
/// <param name='trx'>
/// The transform whose children we want to destroy.
/// </param>
public static void DestroyAllChildren(Transform trx) {
if (trx.childCount > 0) {
Transform[] children = new Transform[trx.childCount];
int i = 0;
foreach (Transform child in trx) {
children[i++] = child;
}
trx.DetachChildren();
if (Application.isEditor && !Application.isPlaying) {
foreach (Transform child in children) {
Object.DestroyImmediate(child.gameObject);
}
}
else {
foreach (Transform child in children) {
Object.DestroyObject(child.gameObject);
}
}
}
}
示例4: ClearList
public static void ClearList(Transform tf)
{
if(tf.childCount == 0) return;
GameObject[] gos = new GameObject[tf.childCount];
for(int i = 0; i < gos.Length; i++){
gos[i] = tf.GetChild(i).gameObject;
}
tf.DetachChildren();
for(int i = 0; i < gos.Length; i++){
Destroy(gos[i]);
// DestroyImmediate(gos[i]);
}
}
示例5: ClearUpTransform
private void ClearUpTransform(Transform target)
{
for (int i = 0; i < target.childCount; i++)
{
Transform trs = target.GetChild(i);
GameObject.Destroy(trs.gameObject);
}
target.DetachChildren();
}
示例6: FixObjs
/// <summary>Fixes obj, fixes all of obj's children if fixChildren.</summary>
public void FixObjs(Transform obj)
{
// detach from parent/children
Transform parent = obj.parent;
obj.parent = null;
Transform[] children = new Transform[obj.childCount];
for (int i=0; i<children.Length; ++i)
children[i] = obj.GetChild(i);
obj.DetachChildren();
// fix
FixObj(obj);
// reattach parent/children
obj.parent = parent;
for (int i=0; i<children.Length; ++i)
children[i].parent = obj;
// fix children
if (fixChildren)
for (int i=obj.childCount-1; i>=0; --i)
FixObjs(obj.GetChild(i));
}