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


C# Transform.GetComponents方法代码示例

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


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

示例1: CreateActionPrefabPool

 public static void CreateActionPrefabPool(Transform action)
 {
     if (action == null)
     {
         return;
     }
     InstantiateBase[] components = action.GetComponents<InstantiateBase>();
     for (int i = 0; i < components.Length; i++)
     {
         if (components[i].prefab != null)
         {
             PoolMgr.CreatePrefabPool(components[i].prefab.transform, 2, 5);
         }
     }
     MissileAction[] components2 = action.GetComponents<MissileAction>();
     for (int j = 0; j < components2.Length; j++)
     {
         if (components2[j].MissilePrefab != null)
         {
             PoolMgr.CreatePrefabPool(components2[j].MissilePrefab.transform, 2, 5);
         }
         if (components2[j].explodePrefab != null)
         {
             PoolMgr.CreatePrefabPool(components2[j].explodePrefab.transform, 2, 5);
         }
     }
     if (EffectSoundManager.IsEffectSoundOptionOn())
     {
         PlaySoundAction[] components3 = action.GetComponents<PlaySoundAction>();
         for (int k = 0; k < components3.Length; k++)
         {
             Globals.Instance.EffectSoundMgr.CacheSoundResourceSync(components3[k].soundName, 360f);
         }
     }
 }
开发者ID:floatyears,项目名称:Decrypt,代码行数:35,代码来源:PoolMgr.cs

示例2:

    void I_ActorState.OnEnter(Transform actor)
    {
        actor.GetComponent<Animator>().SetBool("IsHit", true);
        actor.GetComponentInChildren<ParticleSystem>().Play();
        actor.GetComponents<AudioSource>()[0].Play();

        actor.GetComponent<ActorStats>().Hurt(damage);
    }
开发者ID:Ethanmn,项目名称:TurkeyJam2015,代码行数:8,代码来源:Santa_HitState.cs

示例3: FindAllComponents

 private List<Component> FindAllComponents(System.Type typ, Transform trans)
 {
     List<Component> comps = new List<Component>();
     comps.AddRange((Component[])trans.GetComponents(typ));
     foreach (Transform child in trans)
     {
         comps.AddRange(FindAllComponents(typ, child));
     }
     return comps;
 }
开发者ID:ConnectDeveloper01,项目名称:dorumon,代码行数:10,代码来源:PhotonViewInspector.cs

示例4:

    void I_ActorState.OnEnter(Transform actor)
    {
        //Debug.Log("Turkey entered hit state");
        actor.GetComponent<Animator>().SetBool("IsHit", true);
        actor.GetComponentInChildren<ParticleSystem>().Play();

        actor.GetComponents<AudioSource>()[0].Play();

        actor.GetComponent<SpriteRenderer>().sortingOrder = 0;

        actor.GetComponent<ActorStats>().Hurt(damage);
    }
开发者ID:Ethanmn,项目名称:TurkeyJam2015,代码行数:12,代码来源:Turkey_HitState.cs

示例5: CallIClickable

    private void CallIClickable(Transform go)
    {
        MonoBehaviour[] scripts = go.GetComponents<MonoBehaviour> ();
        foreach (MonoBehaviour m in scripts) {
            if (m is IClickable) {

                ((IClickable)m).NotifyClick ();
                if (go.tag == "decubePrefab"){
                    if (lastClicked != null){
                        ((IClickable)lastClicked).NotifyChange();
                    }
                    lastClicked = (IClickable)m;
                }

                break;
            }
        }
    }
开发者ID:rodrigod89,项目名称:project-decubed-online,代码行数:18,代码来源:MouseInputManager.cs

示例6: Awake

    void Awake()
    {
        handle = transform.Find("Handle");
        handleMat = handle.GetComponent<MeshRenderer>().material;
        output = transform.Find("Output").GetComponent<LogicOutput>();
        sound = handle.GetComponents<AudioSource>();
        timerSound = transform.Find("Timer/TimerAudio").GetComponents<AudioSource>();
        timerNeedle = transform.Find("Timer/TimerNeedle");
        timerFace = transform.Find("Timer/TimerFace").GetComponent<MeshRenderer>().material;
        if (!timerNeedle.gameObject.activeInHierarchy)
            timerNeedle = null;

        // If this switch is supposed to start on, make it flip immediately

        if (startOn)
        {
            flipTime = 0.01f;
            interact(0);
        }
    }
开发者ID:zehro,项目名称:Projects,代码行数:20,代码来源:LogicSwitch.cs

示例7: ObjectCopy

	public static Component ObjectCopy(Component src, Transform dstSelTrans, Object dstSelObj, bool bCreateNewTarget, bool bSearchTarComponent, bool bCopyAllTarComs)
	{
		Component[] tarComs	= null;
		Component	retCom	= null;

		// bCreateNewTarget ВьАМї©µµ, bSearchTarComponent ВьАМёй »х·О »эјєѕИЗФ

		if ((bCreateNewTarget == false) && src.GetType() == dstSelObj.GetType())	// ЅЕ±Ф»эјє Б¶°ЗАМ ѕЖґПёз, °°Ає°ФїЎ µе¶шБЯ
		{
// 			if (NgAssembly.IsValidCopy(dst, src))
			{
				tarComs		= new Component[1];
				tarComs[0]	= dstSelObj as Component;
			}
		} else {
			if (bSearchTarComponent)
				tarComs = dstSelTrans.GetComponents(src.GetType());
		}
		if (tarComs == null || tarComs.Length <= 0)					// ѕшґЩ ёёµйАЪ
		{
			tarComs		= new Component[1];
			tarComs[0]	= NgSerialized.AddComponent(dstSelTrans.gameObject, (src as Component));
		}
		if (tarComs != null)
		{
			foreach (Component tarcom in tarComs)					// і»їл є№»з
			{
				if (src != tarcom)
				{
					NgSerialized.CopySerialized(src as Component, tarcom);
					FXMakerHierarchy.inst.OnAddComponent(tarcom);
					retCom	= tarcom;
					if (bCopyAllTarComs == false)
						break;
				}
			}
		}
		return retCom;
	}
开发者ID:Kinderril,项目名称:p3,代码行数:39,代码来源:FXMakerClipboard.cs

示例8: DoUpdatePrefabContainingSpriteAccordinglyToAtlasChangeRecursively

	// Do Update all scene prefab containing at least a sprite accordingly to atlas change for a texture change
	private static void DoUpdatePrefabContainingSpriteAccordinglyToAtlasChangeRecursively(Transform a_rRoot, Uni2DTextureAtlas a_rAtlas)
	{	
		// loop through the sprite containing the changed texture
		foreach(Uni2DSprite rSpritePrefabInstance in a_rRoot.GetComponents<Uni2DSprite>())
		{
			if(rSpritePrefabInstance.SpriteSettings.atlas == a_rAtlas)
			{
				rSpritePrefabInstance.UpdateUvs();
			}
		}
		
		// Recursive call
		foreach(Transform rChild in a_rRoot)
		{	
			DoUpdatePrefabContainingSpriteAccordinglyToAtlasChangeRecursively(rChild, a_rAtlas);
		}
	}
开发者ID:kenzo0107,项目名称:MamekoRun2D,代码行数:18,代码来源:Uni2DEditorSpriteBuilderUtils.cs

示例9: DoUpdatePrefabContainingSpriteAccordinglyToTextureChangeRecursively

	// Do Update all scene prefab containing at least a sprite accordingly to texture change for a texture change
	private static void DoUpdatePrefabContainingSpriteAccordinglyToTextureChangeRecursively( Transform a_rRoot, Texture2D a_rTexture, string a_oNewTextureImportGUID )
	{	
		// loop through the sprite containing the changed texture
		foreach( Uni2DSprite rSpritePrefabInstance in a_rRoot.GetComponents<Uni2DSprite>( ) )
		{
			if( rSpritePrefabInstance.SpriteSettings.textureContainer.Texture == a_rTexture )
			{
				rSpritePrefabInstance.UpdateAccordinglyToTextureChange( a_oNewTextureImportGUID );
			}
		}
		
		// Recursive call
		foreach( Transform rChild in a_rRoot )
		{	
			DoUpdatePrefabContainingSpriteAccordinglyToTextureChangeRecursively( rChild, a_rTexture, a_oNewTextureImportGUID );
		}
	}
开发者ID:kenzo0107,项目名称:MamekoRun2D,代码行数:18,代码来源:Uni2DEditorSpriteBuilderUtils.cs

示例10: GetSpritesInResourceHierarchy

	// Get all the sprite mesh components in a resource hierarchy
	public static void GetSpritesInResourceHierarchy(Transform a_rRoot, ref List<Uni2DSprite> a_rSprites)
	{
		a_rSprites.AddRange(a_rRoot.GetComponents<Uni2DSprite>());
		
		// Recursive call
		foreach(Transform rChild in a_rRoot)
		{	
			GetSpritesInResourceHierarchy(rChild, ref a_rSprites);
		}
	}
开发者ID:kenzo0107,项目名称:MamekoRun2D,代码行数:11,代码来源:Uni2DEditorSpriteBuilderUtils.cs

示例11: dismantleEffect

    protected void dismantleEffect(Transform trans)
    {
        trans.parent = null;
        trans.gameObject.hideFlags |= HideFlags.HideInHierarchy;
        while (trans.childCount > 0)
            dismantleEffect(trans.GetChild(0));
        Collider [] cols = trans.GetComponents<Collider>();

        bool hasCollider = false;
        foreach (Collider col in cols) {

            if (col.isTrigger) {
                continue;
            } else {
                hasCollider = true;
                if (col as MeshCollider != null)
                    ((MeshCollider)col).convex = true;
                col.enabled = true;
            }
        }

        if (isServer || trans.GetComponent<NetworkIdentity>() == null) {
            if (hasCollider) {
                useAsTemporaryDebris(trans);
            } else {
                Destroy(trans.gameObject, lingerTime);
            }
        } else if (hasCollider) {
            convertToDebris(trans);
        }
    }
开发者ID:autarch-design-team,项目名称:OpenCircuit,代码行数:31,代码来源:AbstractRobotComponent.cs

示例12: ObjectCopy

	public static Component ObjectCopy(Component src, Transform dstSelTrans, Object dstSelObj, bool bCreateNewTarget, bool bSearchTarComponent, bool bCopyAllTarComs)
	{
		Component[] tarComs	= null;
		Component	retCom	= null;

		// bCreateNewTarget ÂüÀÌ¿©µµ, bSearchTarComponent ÂüÀÌ¸é »õ·Î »ý¼º¾ÈÇÔ

		if ((bCreateNewTarget == false) && src.GetType() == dstSelObj.GetType())	// ½Å±Ô»ý¼º Á¶°ÇÀÌ ¾Æ´Ï¸ç, °°Àº°Ô¿¡ µå¶øÁß
		{
// 			if (NgAssembly.IsValidCopy(dst, src))
			{
				tarComs		= new Component[1];
				tarComs[0]	= dstSelObj as Component;
			}
		} else {
			if (bSearchTarComponent)
				tarComs = dstSelTrans.GetComponents(src.GetType());
		}
		if (tarComs == null || tarComs.Length <= 0)					// ¾ø´Ù ¸¸µéÀÚ
		{
			tarComs		= new Component[1];
			tarComs[0]	= NgSerialized.AddComponent(dstSelTrans.gameObject, (src as Component));
		}
		if (tarComs != null)
		{
			foreach (Component tarcom in tarComs)					// ³»¿ë º¹»ç
			{
				if (src != tarcom)
				{
					NgSerialized.CopySerialized(src as Component, tarcom);
					FXMakerHierarchy.inst.OnAddComponent(tarcom);
					retCom	= tarcom;
					if (bCopyAllTarComs == false)
						break;
				}
			}
		}
		return retCom;
	}
开发者ID:sindain,项目名称:GDD450,代码行数:39,代码来源:FXMakerClipboard.cs

示例13: CheckMissing

	void CheckMissing(OBJECT_TYPE objType, Transform currentTrans, Object selObj, int nColumn, int nRow, int nSelIndex)
	{
		switch (objType)
		{
			case OBJECT_TYPE.OBJECT_GAMEOBJECT:
				{
					Component[]	coms = currentTrans.GetComponents<Component>();
					for (int n = 0; n < coms.Length; n++)
					{
						if (coms[n] == null)
						{
//							if (FXMakerMain.inst.IsFrameCreateInstance())
// 							Debug.LogWarning("Missage script !!! - GameObject : " + drawTrans.name);
							DrawWarringIcon(nColumn, nRow, "Missing script !!! - Index : " + n);
							continue;
						}
					}
					break;
				}
			case OBJECT_TYPE.OBJECT_TRANSFORM:
				{
					if (currentTrans.particleEmitter != null || currentTrans.particleSystem != null)
					{
						if (0.02f < Mathf.Abs(Vector3.Distance(currentTrans.lossyScale, Vector3.one)) && currentTrans.GetComponent<NcParticleSystem>() == null)
							DrawWarringIcon(nColumn, nRow, FXMakerTooltip.GetHsScriptMessage("SCRIPT_NEED_SCALEPARTICLE"));
					}
					break;
				}
			case OBJECT_TYPE.OBJECT_EASYEFFECT:
				{
					NcEffectBehaviour	com		= selObj as NcEffectBehaviour;
					if (com != null)
					{
						string				errKey	= com.CheckProperty();
						if (errKey != "")
							DrawWarringIcon(nColumn, nRow, FXMakerTooltip.GetHsScriptMessage(errKey));
					}
					break;
				}
			case OBJECT_TYPE.OBJECT_UNITYENGINE:
			case OBJECT_TYPE.OBJECT_OTHER:
				{
					Component com = selObj as Component;
					if (IsMeshFromMeshList(com))
						if (GetMeshFromMeshList(com) == false)
							DrawWarringIcon(nColumn, nRow, "Missing Mesh !!!");

					NcEffectBehaviour	ncCom = selObj as NcEffectBehaviour;
					if (ncCom != null)
					{
						string	errKey	= ncCom.CheckProperty();
						if (errKey != "")
							DrawWarringIcon(nColumn, nRow, FXMakerTooltip.GetHsScriptMessage(errKey));
					}
					break;
				}
			case OBJECT_TYPE.OBJECT_MATERIAL:
				{
					Material	mat = selObj as Material;
					if (mat == null)
						DrawWarringIcon(nColumn, nRow, "Missing Material !!! - Index : " + nSelIndex);
					else {
						if (mat.shader == null || mat.shader.name == "")
							DrawWarringIcon(nColumn, nRow, "Missing Shader !!! - Material : " + mat.name);
						if (NgMaterial.GetTexture(mat, false) == null)
							DrawWarringIcon(nColumn, nRow, "Missing Texture !!! - Material : " + mat.name);
						if (NgMaterial.IsMaskTexture(mat) && NgMaterial.GetTexture(mat, true) == null)
							DrawWarringIcon(nColumn, nRow, "Missing MaskTexture !!! - Material : " + mat.name);
					}
					break;
				}
			default: break;
		}
	}
开发者ID:ziyihu,项目名称:LordOfSinU3D,代码行数:74,代码来源:FXMakerHierarchy.cs

示例14: HitFlashMeshes

    void HitFlashMeshes(Transform root, Material[] hitFlashMaterials)
    {
        if (root.GetComponents<MeshRenderer>().Length != 0) {
            MeshRenderer meshRenderer = root.GetComponent<MeshRenderer>();
            List<Material> replacement = new List<Material>();
            _childMaterials.Add(meshRenderer.materials);
            foreach (Material m in meshRenderer.materials) replacement.Add(HitFlashMaterial);
            meshRenderer.materials = replacement.ToArray();
        }
        else if (root.GetComponents<SkinnedMeshRenderer>().Length != 0) {
            SkinnedMeshRenderer meshRenderer = root.GetComponent<SkinnedMeshRenderer>();
            List<Material> replacement = new List<Material>();
            _childMaterials.Add(meshRenderer.materials);
            foreach (Material m in meshRenderer.materials) replacement.Add(HitFlashMaterial);
            meshRenderer.materials = replacement.ToArray();
        }

        for (int i=0; i < root.childCount; i++) {
            HitFlashMeshes(root.GetChild(i), hitFlashMaterials);
        }
    }
开发者ID:bi3mer,项目名称:gmap377_leathGloves_inc,代码行数:21,代码来源:EnemyStats.cs

示例15: LinkObjects

    public static void LinkObjects(Transform a, Transform b, bool removeConnection)
    {
        NodeLink connecting = null;
        NodeLink[] conns = a.GetComponents<NodeLink> ();
        for (int i=0;i<conns.Length;i++) {
            if (conns[i].end == b) {
                connecting = conns[i];
                break;
            }
        }

        conns = b.GetComponents<NodeLink> ();
        for (int i=0;i<conns.Length;i++) {
            if (conns[i].end == a) {
                connecting = conns[i];
                break;
            }
        }

        if (removeConnection) {
            if (connecting != null) DestroyImmediate (connecting);
        } else {
            if (connecting == null) {
                connecting = a.gameObject.AddComponent<NodeLink> ();
                connecting.end = b;
            } else {
                connecting.deleteConnection = !connecting.deleteConnection;
            }
        }
    }
开发者ID:rmkeezer,项目名称:fpsgame,代码行数:30,代码来源:NodeLink.cs


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