mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-24 02:15:38 +03:00
41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class Static : MonoBehaviour
|
|
{
|
|
static GameObject cabin;
|
|
private void Start()
|
|
{
|
|
cabin = GetRootObject("Cabin");
|
|
}
|
|
//все в кабине в "Ignore Raycast" или "Default"
|
|
public static void CabinLayer(string layer)
|
|
{
|
|
foreach (Transform _allPanels in cabin.transform.GetComponentsInChildren<Transform>())
|
|
{
|
|
_allPanels.gameObject.layer = LayerMask.NameToLayer(layer);
|
|
}
|
|
}
|
|
public static GameObject GetRootObject(string objName)
|
|
{
|
|
UnityEngine.SceneManagement.Scene activeScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
|
|
GameObject[] rootObjects = activeScene.GetRootGameObjects();
|
|
|
|
// GameObject res = new GameObject();
|
|
|
|
for (int i = 0; i < rootObjects.Length; i++)
|
|
{
|
|
//Debug.Log(rootObjects[i].name);
|
|
if (string.Compare(rootObjects[i].name, objName) == 0)
|
|
{
|
|
|
|
return (rootObjects[i]);
|
|
}
|
|
}
|
|
return (null);
|
|
}
|
|
}
|