Download data/Assets/Editor/TrainingAreaLayerEditorWindow.cs from introvoyz042/CRESSim: direct link, hf CLI and curl.
- Browser
- Download file 1.92 kB
-
https://huggingface.co/datasets/introvoyz042/CRESSim/resolve/main/data/Assets/Editor/TrainingAreaLayerEditorWindow.cs
- Command line
-
hf download hf://datasets/introvoyz042/CRESSim/data/Assets/Editor/TrainingAreaLayerEditorWindow.cs
-
curl -L -o TrainingAreaLayerEditorWindow.cs https://huggingface.co/datasets/introvoyz042/CRESSim/resolve/main/data/Assets/Editor/TrainingAreaLayerEditorWindow.cs
1.92 kB
| using UnityEngine; | |
| using UnityEditor; | |
| public class TrainingAreaLayerEditorWindow : EditorWindow | |
| { | |
| [] | |
| public static void ShowWindow() | |
| { | |
| GetWindow<TrainingAreaLayerEditorWindow>("Training Area Layer Editor"); | |
| } | |
| private void OnGUI() | |
| { | |
| m_selectedGameObject = Selection.activeGameObject; | |
| if (m_selectedGameObject == null) | |
| { | |
| EditorGUILayout.LabelField("No GameObject selected."); | |
| return; | |
| } | |
| EditorGUILayout.LabelField("Select Layer:"); | |
| for (int i = 0; i < 32; i++) | |
| { | |
| string layerName = LayerMask.LayerToName(i); | |
| if (!string.IsNullOrEmpty(layerName)) | |
| { | |
| if (GUILayout.Button(layerName)) | |
| { | |
| // selectedGameObject.layer = i; | |
| AssignLayer(m_selectedGameObject, i); | |
| } | |
| } | |
| } | |
| } | |
| private void OnSelectionChange() | |
| { | |
| m_selectedGameObject = Selection.activeGameObject; | |
| } | |
| public void OnInspectorUpdate() | |
| { | |
| Repaint(); | |
| } | |
| static void AssignLayer(GameObject gameObject, int layer) | |
| { | |
| if (layer == -1) return; | |
| Transform[] allTransforms = gameObject.GetComponentsInChildren<Transform>(true); | |
| foreach (Transform t in allTransforms) | |
| { | |
| t.gameObject.layer = layer; | |
| EditorUtility.SetDirty(t.gameObject); | |
| } | |
| Light[] lights = gameObject.GetComponentsInChildren<Light>(true); | |
| foreach (Light light in lights) | |
| { | |
| light.cullingMask = 1 << layer; | |
| EditorUtility.SetDirty(light.gameObject); | |
| } | |
| // Transform visualTable = gameObject.transform.Find("Suction Area/Visual Table"); | |
| // visualTable.gameObject.layer = 0; | |
| } | |
| private GameObject m_selectedGameObject = null; | |
| } | |