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


C# GameObject.GetComponentsInChildren方法代码示例

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


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

示例1: RefreshShader

    public static void RefreshShader(GameObject obj)
    {
        List<Renderer> meshrs = new List<Renderer>(obj.GetComponentsInChildren<Renderer>(false));
        List<Material> mats = new List<Material>();
        //meshrs.Add(obj.GetComponent<Renderer>());
        for (int i = 0; i < meshrs.Count; i++)
        {
            Material[] mat = meshrs[i].sharedMaterials;
            if (mat == null) mat = meshrs[i].materials;
            if (mat != null)
            {
                mats.AddRange(mat);
            }
        }

        for (int i = 0; i < mats.Count; i++)
        {
            Material mat = mats[i];
            if (mat != null)
            {
                string shaderName = mat.shader.name;
                Shader newShader = Shader.Find(shaderName);
                if (newShader != null)
                {
                    mat.shader = newShader;
                }
            }
        }
    }
开发者ID:FlameskyDexive,项目名称:hugula,代码行数:29,代码来源:LuaHelper.cs

示例2: RegisterPrefab

 internal static void RegisterPrefab(GameObject prefab)
 {
   NetworkIdentity component = prefab.GetComponent<NetworkIdentity>();
   if ((bool) ((Object) component))
   {
     if (LogFilter.logDebug)
       Debug.Log((object) ("Registering prefab '" + prefab.name + "' as asset:" + (object) component.assetId));
     NetworkScene.s_GuidToPrefab[component.assetId] = prefab;
     if (prefab.GetComponentsInChildren<NetworkIdentity>().Length <= 1 || !LogFilter.logWarn)
       return;
     Debug.LogWarning((object) ("The prefab '" + prefab.name + "' has multiple NetworkIdentity components. There can only be one NetworkIdentity on a prefab, and it must be on the root object."));
   }
   else
   {
     if (!LogFilter.logError)
       return;
     Debug.LogError((object) ("Could not register '" + prefab.name + "' since it contains no NetworkIdentity component"));
   }
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:19,代码来源:NetworkScene.cs

示例3: ScaledVersionLoader

            // Runtime Constructor, uses CelestialBody
            public ScaledVersionLoader(CelestialBody body)
            {
                // Get the scaled version object
                scaledVersion = body.scaledBody;
                owner = body;

                // Figure out what kind of body we are
                if (scaledVersion.GetComponentsInChildren<SunShaderController>(true).Length > 0)
                    type = BodyType.Star;
                else if (owner.atmosphere)
                    type = BodyType.Atmospheric;
                else
                    type = BodyType.Vacuum;
            }
开发者ID:Kerbas-ad-astra,项目名称:Kopernicus,代码行数:15,代码来源:ScaledVersionLoader.cs


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