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


C# UnityEngine.GetComponentsInChildren方法代码示例

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


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

示例1: FindChild

    public static GameObject FindChild(UnityEngine.GameObject root, string name)
    {
        /*
        if (root == null)
            return null;

        Transform tran = root.transform.Find(name);

        if (tran)
            return tran.gameObject;

        Transform[] children = rootGameObject.transform.GetComponents<Transform>();
        UnityEngine.GameObject obj = null;

        for (int i = 0; i < children.Length; i++)
        {
            obj = FindChild(children[i].gameObject, name);
            if (obj != null)
                break;
        }*/

        Transform child = root.transform.Find(name);
        if (child)
            return child.gameObject;

        Transform[] trans = root.GetComponentsInChildren<Transform>();
        foreach(var tran in trans)
        {
            if (tran.name == name)
                return tran.gameObject;
        }

        return null;
    }
开发者ID:i-Designing,项目名称:KBengine-unity3d-demo,代码行数:34,代码来源:GameUtility.cs

示例2: HandleCustomProperties

    public void HandleCustomProperties(UnityEngine.GameObject gameObject,
	                                   IDictionary<string, string> props)
    {
        // Simply add a component to our GameObject
        if (props.ContainsKey ("PrefabPath")) {
            string path = props["PrefabPath"];
            UnityEngine.Object spawn =
                AssetDatabase.LoadAssetAtPath(path, typeof(GameObject));
            if (spawn != null)
            {
                GameObject spawnInstance =
                    (GameObject)GameObject.Instantiate(spawn);
                spawnInstance.name = spawn.name;

                // Use the position of the game object we're attached to
                spawnInstance.transform.parent = gameObject.transform;
                spawnInstance.transform.localPosition = Vector3.zero;
                gameObject.transform.localScale = Vector3.one * 100;
            }
        }
        if (props.ContainsKey ("Platform")) {
            gameObject.GetComponent<Collider2D>().usedByEffector = true;
            gameObject.AddComponent<PlatformEffector2D>().surfaceArc = 170f;
        }
        if(props.ContainsKey("ColliderMaterial"))
        {
            foreach(Collider2D collider in gameObject.GetComponentsInChildren<Collider2D>())
            {
                string path = props["ColliderMaterial"];
                collider.sharedMaterial = (PhysicsMaterial2D)AssetDatabase.LoadAssetAtPath(path, typeof(PhysicsMaterial2D));
            }
        }
    }
开发者ID:LUDUSLab,项目名称:Dinopixel,代码行数:33,代码来源:ICustomTiledImporter.cs

示例3: Update_EDITOR

		private void Update_EDITOR(UnityEngine.UI.Windows.WindowLayout _target) {
			
			foreach (var element in _target.elements) element.Update_EDITOR();
			
			#region COMPONENTS
			_target.canvas = _target.GetComponentsInChildren<Canvas>(true)[0];
			var raycasters = _target.GetComponentsInChildren<UnityEngine.EventSystems.BaseRaycaster>(true);
			if (raycasters != null && raycasters.Length > 0) _target.raycaster = raycasters[0];
			#endregion
			
			_target.initialized = (_target.canvas != null);
			
			#region SETUP
			if (_target.initialized == true) {
				
				WindowSystem.ApplyToSettings(_target.canvas);
				
				// Raycaster
				if ((_target.raycaster as GraphicRaycaster) != null) {
					
					(_target.raycaster as GraphicRaycaster).GetType().GetField("m_BlockingMask", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue((_target.raycaster as GraphicRaycaster), (LayerMask)(1 << _target.gameObject.layer));
					
				}
				
			}
			#endregion
			
		}
开发者ID:Trithilon,项目名称:Unity3d.UI.Windows,代码行数:28,代码来源:WindowLayoutEditor.cs

示例4: Setup_EDITOR

		private void Setup_EDITOR(UnityEngine.UI.Windows.WindowLayout _target) {
			
			var elements = _target.GetComponentsInChildren<WindowLayoutElement>(true);
			
			_target.elements = _target.elements.Where((e) => e != null).ToList();
			foreach (var e in elements) {
				
				if (_target.elements.Contains(e) == false) {
					
					// New elements will be added
					e.tag = LayoutTag.None;
					
				}
				
			}
			
			var usedTags = new List<LayoutTag>();
			_target.elements = _target.elements.Where((e) => elements.Contains(e)).ToList();
			
			foreach (var element in elements) {
				
				if (usedTags.Contains(element.tag) == true) {
					
					element.Reset();
					
				} else {
					
					if (element.tag != LayoutTag.None) usedTags.Add(element.tag);
					
				}
				
				if (_target.elements.Contains(element) == true) {
					
					continue;
					
				}
				
				if (element.tag == LayoutTag.None) {
					
					// Element not installed
					_target.elements.Add(element);
					
					this.isDirty = true;
					
				}
				
			}
			
			// Update
			foreach (var element in _target.elements) {
				
				if (element.tag == LayoutTag.None) element.tag = this.GetTag(usedTags);
				
			}
			
		}
开发者ID:Trithilon,项目名称:Unity3d.UI.Windows,代码行数:56,代码来源:WindowLayoutEditor.cs

示例5: HandleSkinnedMeshRendererInfo

    // SkinnedMeshRenderer
    private void HandleSkinnedMeshRendererInfo(UnityEngine.GameObject go, ref int vertices, ref int skinnedMeshTriangles, ref int meshCount)
    {

        Component[] skinnedMeshes = go.GetComponentsInChildren(typeof(SkinnedMeshRenderer));

        for (int skinnedMeshIndex = 0; skinnedMeshIndex < skinnedMeshes.Length; skinnedMeshIndex++)
        {
            SkinnedMeshRenderer skinnedMeshRenderer = (SkinnedMeshRenderer)skinnedMeshes[skinnedMeshIndex];
            vertices += skinnedMeshRenderer.sharedMesh.vertexCount;
            skinnedMeshTriangles += skinnedMeshRenderer.sharedMesh.triangles.Length / 3;
            meshCount++;
        }
    }
开发者ID:lbddk,项目名称:ahzs-client,代码行数:14,代码来源:UIPara.cs

示例6: HandleMeshFilterInfo

    // MeshFilter
    private void HandleMeshFilterInfo(UnityEngine.GameObject go, ref int vertices, ref int meshTriangles, ref int meshCount)
    {

        Component[] meshFilters = go.GetComponentsInChildren(typeof(MeshFilter));

        for (int meshFiltersIndex = 0; meshFiltersIndex < meshFilters.Length; meshFiltersIndex++)
        {
            MeshFilter meshFilter = (MeshFilter)meshFilters[meshFiltersIndex];
            vertices += meshFilter.sharedMesh.vertexCount;
            meshTriangles += meshFilter.sharedMesh.triangles.Length / 3;
            meshCount++;
        }
    }
开发者ID:lbddk,项目名称:ahzs-client,代码行数:14,代码来源:UIPara.cs


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