本文整理汇总了C#中UnityEngine.GameObject.GetComponentsInImmediateChildren方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.GetComponentsInImmediateChildren方法的具体用法?C# GameObject.GetComponentsInImmediateChildren怎么用?C# GameObject.GetComponentsInImmediateChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.GameObject
的用法示例。
在下文中一共展示了GameObject.GetComponentsInImmediateChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeSecondaryMeshes
protected override void InitializeSecondaryMeshes(GameObject itemGo) {
base.InitializeSecondaryMeshes(itemGo);
_secondaryMeshRenderers = itemGo.GetComponentsInImmediateChildren<MeshRenderer>().Except(_primaryMeshRenderer);
if (_secondaryMeshRenderers.Any()) { // some planets may not have atmosphere or rings
_secondaryMeshRenderers.ForAll(smr => {
__ValidateAndCorrectMeshLayer(smr.gameObject);
smr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
smr.receiveShadows = true;
smr.enabled = false;
// Note: using custom SpaceUnity Shaders for now
});
}
}
示例2: InitializePrimaryMesh
protected override MeshRenderer InitializePrimaryMesh(GameObject itemGo) {
var meshRenderers = itemGo.GetComponentsInImmediateChildren<MeshRenderer>();
var primaryMeshRenderer = meshRenderers.Single(mr => {
Profiler.BeginSample("Editor-only GC allocation (GetComponent returns null)", (_trackedItem as Component).gameObject);
var ir = mr.GetComponent<IRevolver>();
Profiler.EndSample();
if (ir != null) {
return true;
}
return false;
});
primaryMeshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
primaryMeshRenderer.receiveShadows = true;
__ValidateAndCorrectMeshLayer(primaryMeshRenderer.gameObject);
// Note: using custom SpaceUnity Shaders for now
return primaryMeshRenderer;
}