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


C# GameObject.GetComponentsInParent方法代码示例

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


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

示例1: IsRobot

	// Returns true if the given game object is part of a Robot
	private bool IsRobot(GameObject gObject){
		if (gObject.tag.Equals("Circle")){
			return false;
		}

		if (gObject.tag.Equals("Robot")){
			return true;
		}
		else {
			
			foreach (Transform childTrans in gObject.GetComponentsInChildren<Transform>()){
				if (childTrans.gameObject.tag.Equals("Robot")){
					return true;
				}
			}

			foreach (Transform parentTrans in gObject.GetComponentsInParent<Transform>()){
				if (parentTrans.gameObject.tag.Equals("Robot")){
					return true;
				}
			}

		}

		return false;
	}
开发者ID:james-sullivan,项目名称:StickeyBallGame,代码行数:27,代码来源:CircleAttach.cs

示例2: FindGameObjectWithTagInParents

	private GameObject FindGameObjectWithTagInParents(GameObject start, string tag)
	{
		Transform[] parents = start.GetComponentsInParent<Transform>();
		foreach (Transform parent in parents) 
		{
			if (parent.gameObject.CompareTag (tag))
				return parent.gameObject;
		}
		return null;
	}
开发者ID:kafedorov89,项目名称:ElectroLab3D_TechShowroom,代码行数:10,代码来源:SystemBrowser.cs

示例3: trapOther

 private void trapOther(GameObject thing)
 {
     if (thing.rigidbody)
     {
         thing.rigidbody.velocity = Vector3.zero;
         thing.rigidbody.useGravity = false;
         trappedRigidbodies.Add(thing.rigidbody);
     }
     if (thing.GetComponentsInChildren<Rigidbody>().Length > 0)
     {
         foreach (Rigidbody body in thing.GetComponentsInChildren<Rigidbody>())
         {
             body.velocity = Vector3.zero;
             body.useGravity = false;
             trappedRigidbodies.Add(body);
         }
     }
     if (thing.GetComponentsInParent<Rigidbody>().Length > 0)
     {
         foreach (Rigidbody body in thing.GetComponentsInParent<Rigidbody>())
         {
             body.velocity = Vector3.zero;
             body.useGravity = false;
             trappedRigidbodies.Add(body);
         }
     }
     trappedThings.Add(thing);
 }
开发者ID:ZPZ-Gr2,项目名称:AwesomeGameInSpace,代码行数:28,代码来源:Trap.cs

示例4: GetDirectFocusContainerComponent

	public static FocusContainer GetDirectFocusContainerComponent(GameObject p_child)
	{
		if(p_child != null)
		{
			FocusContainer[] v_parentsFocus = p_child.GetComponentsInParent<FocusContainer>();
			FocusContainer v_directParentFocus = null;
			foreach(FocusContainer v_parentFocus in v_parentsFocus)
			{
				if(v_parentFocus != null && v_parentFocus.enabled)
				{
					v_directParentFocus = v_parentFocus;
					break;
				}
			}
			return v_directParentFocus;
		}
		return null;
	}
开发者ID:claudia-gp,项目名称:oblivious-oscar,代码行数:18,代码来源:FocusContainer.cs


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