Created
April 29, 2016 16:29
-
-
Save divide-by-zero/88e86bd99160f10af2a85babd3b9709e to your computer and use it in GitHub Desktop.
指定した一つ以上のGameObjectのlayerを一括で変更する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MyUtil | |
| { | |
| /// <summary> | |
| /// 指定した1つ以上のGameObjectのlayerを一括で変更する | |
| /// </summary> | |
| /// <param name="layer">変更したいlayerId</param> | |
| /// <param name="targetObjects">レイヤーを変更したい1つ以上のGameObject</param> | |
| /// </summary> | |
| public static void SetLayer(int layer,params GameObject[] targetObjects) | |
| { | |
| foreach (var targetObject in targetObjects) | |
| { | |
| targetObject.layer = layer; | |
| } | |
| } | |
| /// <summary> | |
| /// 指定した1つ以上のGameObjectのlayerを一括で変更する | |
| /// </summary> | |
| /// <param name="layerName">変更したいレイヤー名</param> | |
| /// <param name="targetObjects">レイヤーを変更したい1つ以上のGameObject</param> | |
| public static void SetLayer(string layerName,params GameObject[] targetObjects) | |
| { | |
| SetLayer(LayerMask.NameToLayer(layerName),targetObjects); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment