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
发布评论