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


C# GameObject.GetComponentsInChildren方法代码示例

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


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

示例1: ClearTextsAndSprite

 public void ClearTextsAndSprite(GameObject _targ)
 {
     new OTTween(DarkBG, 1f).Tween("alpha", 0f);
     if (_targ.GetComponentsInChildren<OTSprite>() != null)
     {
         foreach (OTSprite _spr in _targ.GetComponentsInChildren<OTSprite>())
         {
             _spr.alpha = 0f;
         }
     }
     if (_targ.GetComponentsInChildren<TextUI>() != null)
     {
         foreach (TextUI _txt in _targ.GetComponentsInChildren<TextUI>())
         {
             _txt.makeFadeOut();
         }
     }
     if (_targ.GetComponentsInChildren<UIBtn>() != null)
     {
         foreach (UIBtn _btn in _targ.GetComponentsInChildren<UIBtn>())
         {
             _btn.reDisable();
         }
     }
 }
开发者ID:Tavrox,项目名称:PuzzleRunner,代码行数:25,代码来源:UI.cs

示例2: OnPostprocessModel

    void OnPostprocessModel(GameObject go)
    {
        MeshRenderer[] meshComponents = go.GetComponentsInChildren<MeshRenderer>();
        SkinnedMeshRenderer[] skinMeshComponents = go.GetComponentsInChildren<SkinnedMeshRenderer>();

        bool isAnim = false;
        if(meshComponents.Length == 0 && skinMeshComponents.Length == 0)
        {
            isAnim = true;
        }

        ModelImporter importer = assetImporter as ModelImporter;
        if(isAnim)
        {
            importer.optimizeMesh = false;
            importer.importMaterials = false;
            importer.normalImportMode = ModelImporterTangentSpaceMode.None;
            importer.tangentImportMode = ModelImporterTangentSpaceMode.None;
            importer.splitTangentsAcrossSeams = false;
        }

        //
        importer.importAnimation = isAnim;

        go.tag = isAnim ? EAssetType.Anim.ToString() : EAssetType.Model.ToString();
    }
开发者ID:hismile06jf,项目名称:sgqy8,代码行数:26,代码来源:ModelPostprocessor.cs

示例3: OnMouseDown

    void OnMouseDown()
    {
        if (!GameObject.Find ("Popup(Clone)") && !GameObject.Find ("Map(Clone)") && !GameObject.Find ("EncounterBox(Clone)") && !GameObject.Find ("gradList(Clone)") && !GameObject.Find ("gratzPop(Clone)") && !GameObject.Find ("TutorialBox(Clone)")) {
            mainVar.selectedStudent = this.name;
            Debug.Log (this);
            studentData = this.GetComponent<StudentData> ();
            if (mainVar.gameState) {
                newPopup = Instantiate (Resources.Load ("Popup"))as GameObject;
                newPopup.GetComponentsInChildren<TextMesh> () [1].text = studentData.name;
                newPopup.GetComponentsInChildren<TextMesh> () [2].text = studentData.major;
                newPopup.GetComponentsInChildren<TextMesh> () [0].text = "'" + studentData.tagline + "'";
                //			cgpaBar = studentData.CGPA;

                //			cgpaBar = (cgpaBar - 0) / (12 - 0) * (3 - 0) + 0;

                //			newPopup.GetComponentsInChildren<Transform> () [10].localScale = new Vector3 (cgpaBar, 3f, 3f);
                //			newPopup.AddComponent<BoxCollider2D> ();
                //			newPopup.layer = 5;
                //			newPopup.GetComponent<BoxCollider2D> ().isTrigger = true;
                //			newPopup.GetComponent<BoxCollider2D> ().size = new Vector2 (5, 3);

                AudioSource[] audioSources = GameObject.Find ("Main Camera").GetComponents<AudioSource> ();
                audioSources [1].Play ();

                //			newPopup.AddComponent<AudioSource>();
                //			newPopup.GetComponent<AudioSource>().clip = Resources.Load("Audio/blip") as AudioClip;
                //			newPopup.GetComponent<AudioSource>().Play ();

                newPopup.AddComponent<DestoryPopup> ();
                mainVar.gameState = false;
            }
        }

        //		Debug.Log (this.name);
    }
开发者ID:Tambora,项目名称:HowToStudent,代码行数:35,代码来源:showPopup.cs

示例4: initialise

        public void initialise(ASPPainter painter)
        {
            _painter = painter;

            ScreenMessages.PostScreenMessage("Paint Pointer - RMB or Escape to exit", 5, ScreenMessageStyle.UPPER_CENTER);

            if (_pointer == null)
            {
                GameObject modelObject = GameDatabase.Instance.GetModel(_pointerModel).gameObject;
                _pointer = Instantiate(modelObject) as GameObject;

                Collider[] colliders = _pointer.GetComponentsInChildren<Collider>(true);
                foreach (Collider collider in colliders)
                {
                    Destroy(collider);
                }

                _meshRenderers = _pointer.GetComponentsInChildren<MeshRenderer>(true);
                foreach (MeshRenderer mesh in _meshRenderers)
                {
                    mesh.material = new Material(Shader.Find("Transparent/Diffuse"));
                }

                _pointer.SetActive(true);
            }

            GameEvents.onVesselChange.Add(new EventData<Vessel>.OnEvent(this.OnVesselChange));
        }
开发者ID:panteras1000,项目名称:TheWriteStuff,代码行数:28,代码来源:PaintPointer.cs

示例5: Start

    void Start()
    {
        if (particle != null)
        {
            GO = Instantiate(particle) as GameObject;

                GO.transform.SetParent(transform, false);

            if (autoStart)
            {
                foreach (ParticleSystem ps in GO.GetComponentsInChildren<ParticleSystem>())
                {
                    ps.loop = true;
                    ps.playOnAwake = true;
                    GO.SetActive(false);
                    GO.SetActive(true);
                }
            }
            else
            {
                foreach (ParticleSystem ps in GO.GetComponentsInChildren<ParticleSystem>())
                {
                    ps.loop = false;
                    ps.playOnAwake = false;
                    GO.SetActive(false);
                    GO.SetActive(true);
                }
            }
        }
    }
开发者ID:taboo1,项目名称:arena,代码行数:30,代码来源:Particle.cs

示例6: FindMesh1

    public Mesh FindMesh1(GameObject go, out GameObject obj)
    {
        if ( go )
        {
            MeshFilter[] filters = (MeshFilter[])go.GetComponentsInChildren<MeshFilter>(true);

            if ( filters.Length > 0 )
            {
                if ( filters[0].gameObject != go )
                    obj = filters[0].gameObject;
                else
                    obj = null;
                return filters[0].mesh;
            }

            SkinnedMeshRenderer[] skins = (SkinnedMeshRenderer[])go.GetComponentsInChildren<SkinnedMeshRenderer>(true);
            if ( skins.Length > 0 )
            {
                if ( skins[0].gameObject != go )
                    obj = skins[0].gameObject;
                else
                    obj = null;
                return skins[0].sharedMesh;
            }
        }

        obj = null;
        return null;
    }
开发者ID:mobeid,项目名称:NP_SIMULATOR,代码行数:29,代码来源:MegaModifyObject.cs

示例7: EnableRagdoll

        /// <summary>
        /// Enables the ragdool.
        /// </summary>
        /// <remarks>
        /// The GameObject must have a Collider and a Rigidbody.
        /// </remarks>
        /// <param name="enable">If set to <c>true</c> enable.</param>
        public static void EnableRagdoll(GameObject gameObject, bool enable)
        {
            var bones = gameObject.GetComponentsInChildren<Rigidbody>();

            for (var boneIndex = 0; boneIndex < bones.Length; boneIndex++) {
                var bone = bones[boneIndex];
                var collider = bone.GetComponent<Collider>();
                if (collider != null) {
                    collider.enabled = enable;
                }
                bone.isKinematic = !enable;
                bone.mass = (enable ? 0.1f : 0.01f);
            }
            gameObject.GetComponent<Collider>().enabled = !enable;

            var rigidbody = gameObject.GetComponent<Rigidbody>();
            if (enable) {
                rigidbody.useGravity = false;
                rigidbody.isKinematic = true;
            } else {
                rigidbody.mass = 1.0f;
                rigidbody.useGravity = true;
                rigidbody.isKinematic = false;
            }

            var animators = gameObject.GetComponentsInChildren<Animator>();
            for (var animatorIndex = 0; animatorIndex < animators.Length; animatorIndex++) {
                animators[animatorIndex].enabled = !enable;
            }
        }
开发者ID:intentor,项目名称:sensewizard,代码行数:37,代码来源:RagdollUtils.cs

示例8: InitializeDialoguePanel

    protected override void InitializeDialoguePanel()
    {
        m_currentState = DialogueTreeStates.RUNNING;

        m_dialoguePanel = Instantiate((GameObject)Resources.Load("DialoguePanel", typeof(GameObject)));
        Text[] messages = m_dialoguePanel.GetComponentsInChildren<Text>();

        for(int i=0; i<messages.Length;i++)
        {
            if(messages[i].gameObject.name == "Message")
            {
                messages[i].text = m_singleMessage;
                break;
            }

        }

        Button[] buttons = m_dialoguePanel.GetComponentsInChildren<Button>();

        for (int i = 0; i < buttons.Length; i++)
        {
            if (buttons[i].gameObject.name == "ButtonOptionA")
            {
                buttons[i].onClick.AddListener(() => OnOptionClicked());
            }
            else if (buttons[i].gameObject.name == "ButtonOptionB")
            {
                buttons[i].onClick.AddListener(() => OnOptionClicked());
            }
        }
    }
开发者ID:arcticmicho,项目名称:dialogParty,代码行数:31,代码来源:SingleDialogueNode.cs

示例9: Awake

		void Awake(){
			thisObj=gameObject;
			thisT=transform;
			
			thisObj.layer=LayerManager.LayerShootObject();
			
			if(autoSearchLineRenderer){
				LineRenderer[] lines = thisObj.GetComponentsInChildren<LineRenderer>(true);
				for(int i=0; i<lines.Length; i++) lineList.Add(lines[i]);
			}
			
			TrailRenderer[] trails = thisObj.GetComponentsInChildren<TrailRenderer>(true);
			for(int i=0; i<trails.Length; i++) trailList.Add(trails[i]);
			
			if(type==_ShootObjectType.FPSProjectile){
				SphereCollider sphereCol=GetComponent<SphereCollider>();
				if(sphereCol==null){
					sphereCol=thisObj.AddComponent<SphereCollider>();
					sphereCol.radius=0.15f;
				}
				hitRadius=sphereCol.radius;
			}
			
			if(shootEffect!=null) ObjectPoolManager.New(shootEffect);
			if(hitEffect!=null) ObjectPoolManager.New(hitEffect);
		}
开发者ID:ahvdesign,项目名称:Tower-Defense-Q,代码行数:26,代码来源:ShootObject.cs

示例10: Start

	void Start () {
		shadowRoot = (GameObject)Instantiate(gameObject);
		if (hideShadow)
			shadowRoot.hideFlags = HideFlags.HideInHierarchy;

		shadowRoot.transform.parent = transform.root;

		shadowTable = new Dictionary<Transform, Transform>();

		Destroy(shadowRoot.GetComponent<SkeletonUtilityKinematicShadow>());

		shadowRoot.transform.position = transform.position;
		shadowRoot.transform.rotation = transform.rotation;

		Vector3 scaleRef = transform.TransformPoint(Vector3.right);
		float scale = Vector3.Distance(transform.position, scaleRef);
		shadowRoot.transform.localScale = Vector3.one;

		var shadowJoints = shadowRoot.GetComponentsInChildren<Joint>();
		foreach (Joint j in shadowJoints) {
			j.connectedAnchor *= scale;
		}

		var joints = GetComponentsInChildren<Joint>();
		foreach (var j in joints)
			Destroy(j);

		var rbs = GetComponentsInChildren<Rigidbody>();
		foreach (var rb in rbs)
			Destroy(rb);

		var colliders = GetComponentsInChildren<Collider>();
		foreach (var c in colliders)
			Destroy(c);


		//match by bone name
		var shadowBones = shadowRoot.GetComponentsInChildren<SkeletonUtilityBone>();
		var bones = GetComponentsInChildren<SkeletonUtilityBone>();

		//build bone lookup
		foreach (var b in bones) {
			if (b.gameObject == gameObject)
				continue;

			foreach (var sb in shadowBones) {
				if (sb.rigidbody == null)
					continue;

				if (sb.boneName == b.boneName) {
					shadowTable.Add(sb.transform, b.transform);
					break;
				}
			}
		}

		foreach (var b in shadowBones)
			Destroy(b);
	}
开发者ID:onepenny,项目名称:manual_dota,代码行数:59,代码来源:SkeletonUtilityKinematicShadow.cs

示例11: Start

 void Start()
 {
     hinweis = GameObject.Find ("Hinweis");
     hinweisText = hinweis.GetComponentsInChildren<Text> ();
     hinweisBild = hinweis.GetComponentsInChildren<Image> ();
     showHinweis(false, "");
     showtime = 0;
 }
开发者ID:KevinTaron,项目名称:AloneOnIsland,代码行数:8,代码来源:UIScript.cs

示例12: SetEnabledForGameObject

 private void SetEnabledForGameObject(GameObject go, bool enabled)
 {
     go.GetComponent<Movement>().enabled = enabled;
     go.GetComponent<PlayerController>().enabled = enabled;
     go.GetComponent<Rigidbody>().useGravity = enabled;
     go.GetComponentsInChildren<MeshRenderer>().SetEnabled(enabled);
     go.GetComponentsInChildren<Collider>().SetEnabled(enabled);
 }
开发者ID:JustoSenka,项目名称:Cell-Stage,代码行数:8,代码来源:PlayerController.cs

示例13: InputRegister

        // InputManagerSetup
        internal static void InputRegister( GameObject gameObject )
        {
            controllers = gameObject.GetComponentsInChildren<ControllerBase>();
            controllersCount = controllers.Length;

            buttons = gameObject.GetComponentsInChildren<ButtonBase>();
            buttonsCount = buttons.Length;
        }
开发者ID:ifty420,项目名称:Fuel-Truck-Eugene-2,代码行数:9,代码来源:InputManager.cs

示例14: GridSetUp

 private void GridSetUp(GameObject gridObject, GameObject spriteObject)
 {
     for (int i = 0; i < gridObject.GetComponentsInChildren<Image>().Length; i++) {
         if (gridObject.GetComponentsInChildren<Image>()[i].tag == "Sprite") {
             gridObject.GetComponentsInChildren<Image>()[i].sprite = spriteObject.GetComponent<Image>().sprite;
         }
     }
 }
开发者ID:psuong,项目名称:viacom-dora,代码行数:8,代码来源:GridGenerator.cs

示例15: Start

		void Start () {
			// Duplicate this gameObject as the "shadow" with a different parent.
			shadowRoot = Instantiate<GameObject>(this.gameObject);
			Destroy(shadowRoot.GetComponent<SkeletonUtilityKinematicShadow>());

			// Prepare shadow gameObject's properties.
			var shadowRootTransform = shadowRoot.transform;
			shadowRootTransform.position = transform.position;
			shadowRootTransform.rotation = transform.rotation;

			Vector3 scaleRef = transform.TransformPoint(Vector3.right);
			float scale = Vector3.Distance(transform.position, scaleRef);
			shadowRootTransform.localScale = Vector3.one;

			if (!detachedShadow) {
				// Do not change to null coalescing operator (??). Unity overloads null checks for UnityEngine.Objects but not the ?? operator.
				if (parent == null)
					shadowRootTransform.parent = transform.root;  
				else
					shadowRootTransform.parent = parent;
			}

			if (hideShadow)
				shadowRoot.hideFlags = HideFlags.HideInHierarchy;
			
			var shadowJoints = shadowRoot.GetComponentsInChildren<Joint>();
			foreach (Joint j in shadowJoints)
				j.connectedAnchor *= scale;

			// Build list of bone pairs (matches shadow transforms with bone transforms)
			var bones = GetComponentsInChildren<SkeletonUtilityBone>();
			var shadowBones = shadowRoot.GetComponentsInChildren<SkeletonUtilityBone>();
			foreach (var b in bones) {
				if (b.gameObject == this.gameObject)
					continue;
				
				foreach (var sb in shadowBones) {
					if (sb.GetComponent<Rigidbody>() != null && sb.boneName == b.boneName) {
						shadowTable.Add(new TransformPair {
							dest = b.transform,
							src = sb.transform
						});
						break;
					}
				}

			}

			// Destroy conflicting and unneeded components
			DestroyComponents(shadowBones);

			DestroyComponents(GetComponentsInChildren<Joint>());
			DestroyComponents(GetComponentsInChildren<Rigidbody>());
			DestroyComponents(GetComponentsInChildren<Collider>());
		}
开发者ID:EsotericSoftware,项目名称:spine-runtimes,代码行数:55,代码来源:SkeletonUtilityKinematicShadow.cs


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