// Autoassign id and UID for a newely created item. private void Reset() { var mapHolder = UnityEngine.Object.FindObjectOfType <MapHolder>(); id = IdGenerator.AutogenerateNextId <MapSignal>(idPrefix); if (string.IsNullOrEmpty(UID)) { UID = Guid.NewGuid().ToString(); } }
// When scene is opened, go over all objects of same type and assign ids if missing. static void OnEditorSceneManagerSceneOpened(UnityEngine.SceneManagement.Scene scene, UnityEditor.SceneManagement.OpenSceneMode mode) { var mapHolder = UnityEngine.Object.FindObjectOfType <MapHolder>(); if (mapHolder == null) { return; } // If there is no ID set, set autogenerated ones. foreach (var sign in mapHolder.transform.GetComponentsInChildren <MapLane>()) { if (string.IsNullOrEmpty(sign.id)) { sign.id = IdGenerator.AutogenerateNextId <MapLane>(idPrefix); } } }
// Autoassign id for a newely created item. private void Reset() { var mapHolder = UnityEngine.Object.FindObjectOfType <MapHolder>(); id = IdGenerator.AutogenerateNextId <MapLane>(idPrefix); }