Unity GameObject拓展API

编程入门 行业动态 更新时间:2024-10-28 08:16:38

<a href=https://www.elefans.com/category/jswz/34/1771418.html style=Unity GameObject拓展API"/>

Unity GameObject拓展API

此拓展主要处理GameObject的子节点
1.激活状态
2.脱离源对象
3.层Layer
4.粒子系统
5.音源
6.相机的视野内

using UnityEngine;
using System.Collections;
using System.Collections.Generic;//此拓展主要处理GameObject的子节点
//1.激活状态
//2.脱离源对象
//3.层Layer
//4.粒子系统
//5.音源
//6.相机的视野内
public static class GameObjectExtensions : System.Object
{#region 扩展方法:GameObject/// <summary>/// 递归设置所有子节点显示隐藏状态/// </summary>/// <param name="theGameObject">父节点</param>/// <param name="theActive">显示隐藏状态</param>public static void SetChildrenActiveRecursively(this GameObject theGameObject, bool theActive){foreach (Transform aChildTransform in theGameObject.transform){aChildTransform.gameObject.SetActive(theActive);}}/// <summary>/// 递归设置所有子节点的层/// </summary>/// <param name="aGameObject">父节点</param>/// <param name="theLayer">层级</param>public static void SetLayerRecursively(this GameObject aGameObject, int theLayer){aGameObject.layer = theLayer;foreach (Transform aTransform in aGameObject.transform){GameObject gameObject = aTransform.gameObject;SetLayerRecursively

更多推荐

Unity GameObject拓展API

本文发布于:2024-02-25 07:33:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1698242.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Unity   GameObject   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!