本文整理汇总了C#中UnityEngine.GameObject.FindChildObjectByName方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.FindChildObjectByName方法的具体用法?C# GameObject.FindChildObjectByName怎么用?C# GameObject.FindChildObjectByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.GameObject
的用法示例。
在下文中一共展示了GameObject.FindChildObjectByName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyRandom
/// <summary>
/// Applies random permutation of this skin to the set of renderers based on the given randomSeed.
/// </summary>
public void ApplyRandom( GameObject root, int randomSeed )
{
Assert.NotNull( root );
Assert.HasComponent<Animator>( root, "ApplyRandom, parameter needs to have an Animator component" );
if ( skeletonBones != null )
{
foreach ( SpriteSkeletonSkin mapping in skeletonBones )
{
GameObject child = root.FindChildObjectByName( mapping.name );
if ( child != null )
{
if ( colorOptions != null && colorOptions.Length > 0 )
{
mapping.ApplyRandom( child.GetComponent<SpriteRenderer>(), colorOptions, randomSeed );
}
else
{
mapping.ApplyRandom( child.GetComponent<SpriteRenderer>(), randomSeed );
}
}
}
}
else
{
Debug.LogWarning( "Apply random skin configuration: no bonemappings defined. No skin will be applied." );
}
}
示例2: Merge
/// <summary>
/// Merges the skin defined by the given skeleton with the current skin (much like a union).
/// </summary>
public void Merge( GameObject skeletonRoot )
{
Assert.NotNull( skeletonRoot );
Assert.HasComponent<Animator>( skeletonRoot, "ApplyRandom, parameter needs to have an Animator component" );
foreach ( SpriteSkeletonSkin mapping in skeletonBones )
{
GameObject bone = skeletonRoot.FindChildObjectByName( mapping.name );
if ( bone != null )
{
SpriteRenderer renderer = bone.GetComponent<SpriteRenderer>();
if ( renderer != null && !mapping.ContainsSprite( renderer.sprite ) )
{
mapping.AddBoneConfiguration( renderer.sprite, bone.transform, renderer.color );
Debug.Log ( "[Merge] Added sprite: " + renderer.sprite + " to " + mapping.name );
}
}
}
}