Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class ClearMissingReferenceExample : MonoBehaviour
- {
- public List<GameObject> gameObjects;
- [ContextMenu ("Create GOs")]
- void CreateGOs ()
- {
- for (int i = 0; i < 5; i++)
- {
- GameObject go = new GameObject ();
- go.name = "GameObject" + go.GetInstanceID ();
- go.transform.SetParent (transform);
- gameObjects.Add (go);
- }
- }
- [ContextMenu ("Clear MissingReference")]
- void ClearMissingReference ()
- {
- gameObjects.RemoveAll (item => item == null);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement