区别与联系:SetVility()实现的更加广泛一些,而SetHiddenInGame()则是只在SceneComponent中有实现,意味着SetHiddenInGame()只能隐藏SceneComponent。SetVisibility()可以隐藏包括SceneComponent在内的很多东西(如UI组件)。一般来说能在场景中显示(看的见的)物体,都有SceneComponent,两种方法都可以达到目的,但是如果是一些SWeiget,SPanel,UWeiget等就只能通过SetVisibility()来做。
另外,在SceneComponent中两种方法的实现几乎是相同的。
void USceneComponent::SetVisibility(const bool bNewVisibility, const USceneComponent::EVisibilityPropagation PropagateToChildren)
{bool bRecurseChildren = (PropagateToChildren == EVisibilityPropagation::Propagate);if ( bNewVisibility != GetVisibleFlag() ){bRecurseChildren = bRecurseChildren || (PropagateToChildren == EVisibilityPropagation::DirtyOnly);SetVisibleFlag(bNewVisibility);OnVisibilityChanged();}const TArray<USceneComponent*>& AttachedChildren = GetAttachChildren();if (bRecurseChildren && AttachedChildren.Num() > 0){// fully traverse down the attachment tree// we do it entirely inline here instead of recursing in case a primitivecomponent is a child of a non-primitivecomponentTInlineComponentArray<USceneComponent*, NumInlinedActorComponents> ComponentStack;// prime the pumpComponentStack.Append(AttachedChildren);while (ComponentStack.Num() > 0){USceneComponent* const CurrentComp = ComponentStack.Pop(/*bAllowShrinking=*/ false);if (CurrentComp){ComponentStack.Append(CurrentComp->GetAttachChildren());if (PropagateToChildren == EVisibilityPropagation::Propagate){CurrentComp->SetVisibility(bNewVisibility, EVisibilityPropagation::NoPropagation);}// Render state must be dirtied if any parent component's visibility has changed. Since we can't easily track whether // any parent in the hierarchy was dirtied, we have to mark dirty always.CurrentComp->MarkRenderStateDirty();}}}
}

void USceneComponent::SetHiddenInGame(const bool bNewHiddenGame, const USceneComponent::EVisibilityPropagation PropagateToChildren)
{bool bRecurseChildren = (PropagateToChildren == EVisibilityPropagation::Propagate);if ( bNewHiddenGame != bHiddenInGame ){bRecurseChildren = bRecurseChildren || (PropagateToChildren == EVisibilityPropagation::DirtyOnly);bHiddenInGame = bNewHiddenGame;OnHiddenInGameChanged();}const TArray<USceneComponent*>& AttachedChildren = GetAttachChildren();if (bRecurseChildren && AttachedChildren.Num() > 0){// fully traverse down the attachment tree// we do it entirely inline here instead of recursing in case a primitivecomponent is a child of a non-primitivecomponentTInlineComponentArray<USceneComponent*, NumInlinedActorComponents> ComponentStack;// prime the pumpComponentStack.Append(AttachedChildren);while (ComponentStack.Num() > 0){USceneComponent* const CurrentComp = ComponentStack.Pop(/*bAllowShrinking=*/ false);if (CurrentComp){ComponentStack.Append(CurrentComp->GetAttachChildren());if (PropagateToChildren == EVisibilityPropagation::Propagate){CurrentComp->SetHiddenInGame(bNewHiddenGame, EVisibilityPropagation::NoPropagation);}// Render state must be dirtied if any parent component's visibility has changed. Since we can't easily track whether // any parent in the hierarchy was dirtied, we have to mark dirty always.CurrentComp->MarkRenderStateDirty();}}}
}

UE4 SetVisibility()和SetHiddenInGame()的比较相关推荐

  1. ue4渲染速度太慢_[UE4]性能优化指南(程序向)

    封面来源:A Cold Stop(Mixer 制作材质.UE4渲染 ) [UE4]性能优化指南(美术向)玄冬Wong:[UE4]性能优化指南(美术向)​zhuanlan.zhihu.com 内容都是处 ...

  2. UE4 C++ 笔记

    文章目录 VS 编辑器 运行调试 VSCode VA 蓝图 Actor Component Pawn/Character And Controller AI 光照 数学 Other API UMG F ...

  3. ue4 4.24启动无响应_UE4项目问题集合

    debugeditor模式下,在LoadPackage过程中crash,vs报出Stack overflow的错误 这是由于Package层数过多,vs栈不够用导致的.而ue4用UBT导致不能直接修改 ...

  4. ue4 曲线图实现 蓝图_UE4蓝图解析(一)

    简介 蓝图是一类特殊的asset,可以使用直观.基于节点的方式创建逻辑,或者设置一些变量数据.策划可以创建自定义的Actor.Event.函数等等,快速的做Gameplay迭代,不需要写任何代码. 蓝 ...

  5. UE4材质着色器全面学习教程

    你会学到什么 通过所有着色器类型和设计的实际演示,学习创建材质 要求 对虚幻的基本理解会有所帮助 了解纹理的一般知识(不仅限于UE4)也很有用 描述 在这个系列中,我将带你设置大量不同的材料,教你如何 ...

  6. UE4制作程序背景游戏 Make a game with Procedural Backgrounds in UE4

    使用虚幻引擎4蓝图创建一个程序背景的游戏 你会学到什么 学习虚幻引擎4要领 使用程序切片创建标高 保存并加载某些游戏元素 创造一个无止境的跑步者角色 创建和完成游戏的良好习惯和实践 MP4 |视频:h ...

  7. UE4蓝图无代码编程游戏开发技能学习教程

    在虚幻引擎4中创建.设计和开发自己的游戏,无需编码 你会学到什么 虚幻引擎4中使用蓝图的游戏开发(无代码编程) 使用行业标准方法的游戏设计 使用Maya进行三维设计 在本课程中创建您的第一个游戏 Ga ...

  8. UE4风格化场景设计入门指南 Stylized Station – The Environment Artist’s Survival Kit

    持续时间13h 1920X1080 .ts 包含项目文件 大小解压后:4.9G 语言:英语+中文字幕(人工校对) 标题:风格化的车站--环境艺术家的生存工具包 信息: 环境艺术很难. 尤其是作为初学者 ...

  9. 在UE4中创建CG动画 How to create a movie in Unreal Engine 4 using Metahuman

    MP4 |视频:h264,1280×720 |音频:AAC,44.1 KHz 语言:英语+中英文字幕(根据原英文字幕机译更准确)|大小解压后:1.55 GB |时长:1h 16m 你会学到什么 如何在 ...

最新文章

  1. IE8的parseInt
  2. 互联网技术架构的启示
  3. C++对C的加强之 “实用性”增加
  4. Keil4编译原子哥的SYSTEM出现错误 Inline assembler not permitted when generating Thumb code
  5. leetcode 542. 01 Matrix | 542. 01 矩阵(图解,广度优先搜索)
  6. 最全Pycharm教程
  7. 20应用统计考研复试要点(part31)--简答题
  8. SAP CRM WebClient UI上文本是否可编辑,取决于哪些条件
  9. phoenix Explain Plan 翻译
  10. AI 垃圾分类指日可待?
  11. SpringBoot2.0应用(五):SpringBoot2.0整合MyBatis
  12. idea编译器没有tomcat的选项解决方案
  13. jQuery:基础知识学习
  14. Excel怎么批量删除开头文本
  15. ios android 图文混排,[分享]iOS开发-50行代码实现图文混排
  16. VC++:菜单的使用总结
  17. 重启镜像DOCKER
  18. 赵小楼《天道》《遥远的救世主》深度解析(135)观念,传统观念,传统观念有没有用取决于观念,而不在传统
  19. Android四大组件Service之AIDL详解
  20. Ubuntu系统安装webrtc

热门文章

  1. 为什么要学习一个适合自己的编码方案
  2. Camtasia studio2023录屏和后期剪辑的软件
  3. GIS技术在石油工业中有哪些应用?
  4. IEC61850笔记--开源代码libIEC61850(二)
  5. bzoj 2844 albus就是要第一个出场
  6. WebMatrix开发ASP.NET试用手记[转帖]
  7. Teradata数据库简介
  8. teradata 查看 表定义_teradata查询所有表
  9. User Namespace
  10. android全屏视频播放,JieCaoVideoPlayer真正实现Android的全屏视频播放