本文整理汇总了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);
}
}
}
示例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
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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));
}
}
示例7: ChangeAllWidget
void ChangeAllWidget(Transform rootTrans)
{
for (int i = 0; i < rootTrans.GetChildCount(); ++i)
{
ChangeWidgetAtlas(rootTrans.GetChild(i).gameObject);
ChangeAllWidget(rootTrans.GetChild(i));
}
}
示例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;
}
}
}
示例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;
}
示例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);
}
示例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];
}
示例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);
}
}
}
示例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));
}
}
示例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;
}
示例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);
}
}
}