Space Ad Mobile 9.5.1
Space Ad Mobile makes ads easy to add into your mobile game: one unified workflow for LevelPlay, AdMob, Yandex.Ads across banners, interstitials and rewarded.
Loading...
Searching...
No Matches
IdentifierUtility.cs
1using System;
2using UnityEngine;
3
4namespace SCG.SpaceAdMobile
5{
10 public abstract class IdentifierUtility : MonoBehaviour
11 {
16 [field:SerializeField]
17 [field: Tooltip("The unique ID of the object.")]
18 public virtual string Id { get; protected set; }
19
20#if UNITY_EDITOR
25 protected virtual void Reset() => OnValidate();
26
31 protected virtual void OnValidate()
32 {
33 // If the object is part of a prefab that is not instantiated in a scene, skip ID generation
34 if (UnityEditor.PrefabUtility.IsPartOfPrefabAsset(gameObject))
35 return;
36
37 // Sets the ID to a new GUID if it is not already set.
38 if (string.IsNullOrEmpty(Id))
39 {
40 Id = Guid.NewGuid().ToString();
41 }
42 }
43#endif
44 }
45}
virtual string Id
The unique identifier for the object instance. It is serialized and can be viewed and modified in the...
Provides a base class for objects requiring a unique identifier, using MonoBehaviour as its foundatio...