当前位置: 首页>>代码示例>>C#>>正文


C# Transform.DetachChildren方法代码示例

本文整理汇总了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();
 }
开发者ID:Howard-Day,项目名称:PixelArt,代码行数:11,代码来源:FlareControl.cs

示例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());
	}
开发者ID:carriercomm,项目名称:mario-party,代码行数:22,代码来源:SpawnText.cs

示例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);
                }
            }
        }
    }
开发者ID:Maxii,项目名称:CodeEnv.Master,代码行数:28,代码来源:CtxHelper.cs

示例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]);
        }
    }
开发者ID:streetlab,项目名称:Liveball_baseball,代码行数:14,代码来源:UtilMgr.cs

示例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();
 }
开发者ID:xiangyuan,项目名称:TinyReplaySystem,代码行数:9,代码来源:TinyReplayManager.cs

示例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));
    }
开发者ID:shadowseer99,项目名称:clockwork,代码行数:24,代码来源:Rotator2D.cs


注:本文中的UnityEngine.Transform.DetachChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。