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


C# Transform.GetChildCount方法代码示例

本文整理汇总了C#中UnityEngine.Transform.GetChildCount方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.GetChildCount方法的具体用法?C# Transform.GetChildCount怎么用?C# Transform.GetChildCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Transform的用法示例。


在下文中一共展示了Transform.GetChildCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateInstanceIndexing

    //    [HideInInspector]
    // static init ------------------------------------------------------------------------
    public static void CreateInstanceIndexing(Transform oriTrans, Transform insTrans, bool bSameValueRecursively, bool bRuntimeCreatedObj)
    {
        if (insTrans == null)
            return;

        FxmInfoIndexing com = insTrans.gameObject.AddComponent<FxmInfoIndexing>();
        com.SetOriginal(oriTrans, bRuntimeCreatedObj);
        com.OnAutoInitValue();

        // Dup process
        NcDuplicator dupCom = com.GetComponent<NcDuplicator>();
        if (dupCom != null)
        {
            GameObject clone = dupCom.GetCloneObject();
            if (clone != null)
                CreateInstanceIndexing(oriTrans, clone.transform, bSameValueRecursively, false);
        }

        if (bSameValueRecursively)
        {
            for (int n = 0; n < insTrans.GetChildCount(); n++)
                CreateInstanceIndexing(oriTrans, insTrans.GetChild(n), bSameValueRecursively, true);
        } else {
            for (int n = 0; n < oriTrans.GetChildCount(); n++)
            {
                if (n < insTrans.GetChildCount())
                    CreateInstanceIndexing(oriTrans.GetChild(n), insTrans.GetChild(n), bSameValueRecursively, bRuntimeCreatedObj);
            }
        }
    }
开发者ID:hugobozzshih007,项目名称:BattleCard,代码行数:32,代码来源:FxmInfoIndexing.cs

示例2: Activate

	/// <summary>
	/// Activate the specified object and all of its children.
	/// </summary>

	static void Activate(Transform t)
	{
		SetActiveSelf(t.gameObject, true);

		// Prior to Unity 4, active state was not nested. It was possible to have an enabled child of a disabled object.
		// Unity 4 onwards made it so that the state is nested, and a disabled parent results in a disabled child.
#if UNITY_3_5
		for (int i = 0, imax = t.GetChildCount(); i < imax; ++i)
		{
			Transform child = t.GetChild(i);
			Activate(child);
		}
#else
		// If there is even a single enabled child, then we're using a Unity 4.0-based nested active state scheme.
		for (int i = 0, imax = t.GetChildCount(); i < imax; ++i)
		{
			Transform child = t.GetChild(i);
			if (child.gameObject.activeSelf) return;
		}

		// If this point is reached, then all the children are disabled, so we must be using a Unity 3.5-based active state scheme.
		for (int i = 0, imax = t.GetChildCount(); i < imax; ++i)
		{
			Transform child = t.GetChild(i);
			Activate(child);
		}
#endif
	}
开发者ID:JustSAT,项目名称:Tower-Defence,代码行数:32,代码来源:TWTools.cs

示例3: getComponentInChildrenNotSelf

 public static Component getComponentInChildrenNotSelf(Transform t1, string scriptName)
 {
     Component rc = null;
     for(int i=0; i<t1.GetChildCount(); i++)
     {
         Transform t0 = t1.GetChild(i);
         if(t0!=t1)
         {
             rc = t0.GetComponent(scriptName);
             i = t1.GetChildCount();
         }
     }
     return rc;
 }
开发者ID:DavidIllidge,项目名称:Portfolio,代码行数:14,代码来源:Misc.cs

示例4: BakeRecursive

	static void BakeRecursive(Transform node, Vector3 accumulatedScale)
	{
		accumulatedScale = new Vector3(accumulatedScale.x * node.localScale.x,
									   accumulatedScale.y * node.localScale.y,
									   accumulatedScale.z * node.localScale.z);
		
		tk2dBaseSprite sprite = node.GetComponent<tk2dBaseSprite>();
		tk2dTextMesh textMesh = node.GetComponent<tk2dTextMesh>();
		if (sprite)
		{
			Vector3 spriteAccumScale = new Vector3(accumulatedScale.x * sprite.scale.x,
										   		   accumulatedScale.y * sprite.scale.y,
										   		   accumulatedScale.z * sprite.scale.z);
			node.localScale = Vector3.one;
			sprite.scale = spriteAccumScale;
		}
		if (textMesh)
		{
			Vector3 spriteAccumScale = new Vector3(accumulatedScale.x * textMesh.scale.x,
										   		   accumulatedScale.y * textMesh.scale.y,
										   		   accumulatedScale.z * textMesh.scale.z);
			node.localScale = Vector3.one;
			textMesh.scale = spriteAccumScale;
			textMesh.Commit();
		}
		
		for (int i = 0; i < node.GetChildCount(); ++i)
		{
			BakeRecursive(node.GetChild(i), accumulatedScale);
		}
	}
开发者ID:Ahere,项目名称:UnityIsometric,代码行数:31,代码来源:tk2dScaleUtility.cs

示例5: FillFullNameData

 public static void FillFullNameData(Transform rootTransform,Transform thisTransform)
 {
     for (int i = 0; i < rootTransform.GetChildCount(); ++i)
     {
         AddWigetToFullNameData(rootTransform.GetChild(i).name, GetFullName(rootTransform.GetChild(i), thisTransform));
         FillFullNameData(rootTransform.GetChild(i), thisTransform);
     }
 }
开发者ID:lbddk,项目名称:ahzs-client,代码行数:8,代码来源:MFUIUtils.cs

示例6: FillFullNameData

 private void FillFullNameData(Transform rootTransform)
 {
     for (int i = 0; i < rootTransform.GetChildCount(); ++i)
     {
         AddWigetToFullNameData(rootTransform.GetChild(i).name, GetFullName(rootTransform.GetChild(i)));
         FillFullNameData(rootTransform.GetChild(i));
     }
 }
开发者ID:lbddk,项目名称:ahzs-client,代码行数:8,代码来源:RuneUIViewManager.cs

示例7: ChangeAllWidget

 void ChangeAllWidget(Transform rootTrans)
 {
     for (int i = 0; i < rootTrans.GetChildCount(); ++i)
     {
         ChangeWidgetAtlas(rootTrans.GetChild(i).gameObject);
         ChangeAllWidget(rootTrans.GetChild(i));
     }
 }
开发者ID:lbddk,项目名称:ahzs-client,代码行数:8,代码来源:MogoChangeAtlas.cs

示例8: AssignTarget

 public void AssignTarget(Transform target)
 {
     for(int i=0; i<target.GetChildCount(); ++i) {
       if(target.GetChild(i).name == shoulder) {
     this.target = target.GetChild(i);
     break;
       }
     }
 }
开发者ID:shawnmiller,项目名称:Capstone,代码行数:9,代码来源:FollowScript.cs

示例9: Activate

    /// <summary>
    /// Activate the specified object and all of its children.
    /// </summary>
    static void Activate(Transform t)
    {
        for (int i = 0, imax = t.GetChildCount(); i < imax; ++i)
        {
            Transform child = t.GetChild(i);
            Activate(child);
        }

        t.gameObject.active = true;
    }
开发者ID:koalaylj,项目名称:electric,代码行数:13,代码来源:UITool.cs

示例10: Deactivate

	/// <summary>
	/// Deactivate the specified object and all of its children.
	/// </summary>

	static void Deactivate(Transform t)
	{
#if UNITY_3_5
		for (int i = 0, imax = t.GetChildCount(); i < imax; ++i)
		{
			Transform child = t.GetChild(i);
			Deactivate(child);
		}
#endif
		SetActiveSelf(t.gameObject, false);
	}
开发者ID:JustSAT,项目名称:Tower-Defence,代码行数:15,代码来源:TWTools.cs

示例11: Start

 // Use this for initialization
 void Start()
 {
     MyTransform = transform;
     for(int i = 0 ; i < transform.childCount ; i++)
     {
         //MyTransform.GetChild(i).collider.enabled = false;
         MyTransform.GetChild(i).collider.isTrigger = true;
         MyTransform.GetChild(i).name = ""+i;
     }
     ChildCount = MyTransform.GetChildCount();
     CountArray = new int[ChildCount];
 }
开发者ID:BBJV,项目名称:camachi,代码行数:13,代码来源:RoadTriggerManager.cs

示例12: ToggleVisibility

    void ToggleVisibility(Transform obj, bool state)
    {
        for (int i = 0; i < obj.GetChildCount(); i++)
        {
            if (obj.GetChild(i).guiTexture != null)
                obj.GetChild(i).guiTexture.enabled = state;
            if (obj.GetChild(i).guiText != null)
                obj.GetChild(i).guiText.enabled = state;

            if (obj.GetChild(i).GetChildCount() > 0)
            {
                ToggleVisibility(obj.GetChild(i), state);
            }
        }
    }
开发者ID:bwrsandman,项目名称:Stream-Game,代码行数:15,代码来源:MenuInGameHandler.cs

示例13: FillFullNameData

    /// <summary>
    /// 保存子transform在一个dic下
    /// </summary>
    /// <param name="rootTransform"></param>
    private void FillFullNameData(Transform rootTransform)
    {
        for (int i = 0; i < rootTransform.GetChildCount(); ++i)
        {
            try
            {
                m_widgetToFullName.Add(rootTransform.GetChild(i).name, Utils.GetFullName(transform, rootTransform.GetChild(i)));
            }
            catch
            {
                Mogo.Util.LoggerHelper.Debug("rootTransform.GetChild(i):" + rootTransform.GetChild(i).name);
            }

            FillFullNameData(rootTransform.GetChild(i));
        }
    }
开发者ID:lbddk,项目名称:ahzs-client,代码行数:20,代码来源:MogoUIParent.cs

示例14: getChildren

    public static List<Transform> getChildren(Transform parent, bool recurse)
    {
        List<Transform> children = new List<Transform>();

        int count = parent.GetChildCount();
        if (count == 0) return children;

        Transform child;
        for (int i=0; i<count; i++) {
            child = parent.GetChild(i);
            children.Add(child);

            if (recurse && child.GetChildCount() > 0) {
                List<Transform> subChildren = getChildren(child, recurse);
                children.AddRange(subChildren);
            }
        }

        return children;
    }
开发者ID:Wttewaall,项目名称:3dhype-gamejam,代码行数:20,代码来源:ChildUtils.cs

示例15: GetRendererBoundsInChildren

    static void GetRendererBoundsInChildren(Matrix4x4 rootWorldToLocal, Vector3[] minMax, HashSet<Transform> ignoreItems, Transform t, bool includeAllChildren) {
        if (!ignoreItems.Contains(t)) {
            MeshFilter mf = t.GetComponent<MeshFilter>();
            if (mf != null && mf.sharedMesh != null) {
                Bounds b = mf.sharedMesh.bounds;
                Matrix4x4 relativeMatrix = rootWorldToLocal * t.localToWorldMatrix;
                for (int j = 0; j < 8; ++j) {
                    Vector3 localPoint = b.center + Vector3.Scale(b.extents, boxExtents[j]);
                    Vector3 pointRelativeToRoot = relativeMatrix.MultiplyPoint(localPoint);
                    minMax[0] = Vector3.Min(minMax[0], pointRelativeToRoot);
                    minMax[1] = Vector3.Max(minMax[1], pointRelativeToRoot);
                }
            }
            for (int i = 0; i < t.GetChildCount(); ++i) {
                Transform child = t.GetChild(i);

                if (!includeAllChildren && child.GetComponent<Collider>() != null) {
                    continue;
                }

                GetRendererBoundsInChildren(rootWorldToLocal, minMax, ignoreItems, child, includeAllChildren);
            }
        }
    }
开发者ID:sundayliu,项目名称:HelloWorld-unity3d,代码行数:24,代码来源:tk2dUIItemBoundsHelper.cs


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