Skip to content

Instantly share code, notes, and snippets.

@baba-s
Last active March 8, 2024 00:05
Show Gist options
  • Save baba-s/a39a0cf70407b3464990bc55c85ccf69 to your computer and use it in GitHub Desktop.
Save baba-s/a39a0cf70407b3464990bc55c85ccf69 to your computer and use it in GitHub Desktop.
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