Last active
March 8, 2024 00:05
-
-
Save baba-s/a39a0cf70407b3464990bc55c85ccf69 to your computer and use it in GitHub Desktop.
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
using Unity.Collections; | |
using UnityEngine; | |
public class Example : MonoBehaviour | |
{ | |
[SerializeField] private GameObject[] m_gameObjects; | |
private void Start() | |
{ | |
var instanceIDs = new NativeArray<int> | |
( | |
m_gameObjects.Length, | |
Allocator.Temp | |
); | |
try | |
{ | |
for ( var i = 0; i < m_gameObjects.Length; i++ ) | |
{ | |
instanceIDs[ i ] = m_gameObjects[ i ].GetInstanceID(); | |
} | |
GameObject.SetGameObjectsActive( instanceIDs, false ); | |
} | |
finally | |
{ | |
instanceIDs.Dispose(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment