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


C# GameObject.FindChildObjectByName方法代码示例

本文整理汇总了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." );
			}
		}
开发者ID:partial-pi,项目名称:pi.unity.spriteskeletondemo,代码行数:32,代码来源:SpriteSkeletonSkinAsset.cs

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


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