Esempio n. 1
0
    void Awake()
    {
        manager = GameObject.FindObjectOfType <GuidManager>();

        if (manager != null && (id == null || id == "" || manager.IsRegisteredAlready(this)))
        {
            if (Application.isPlaying)
            {
                Debug.LogError("Bad Guid state for " + gameObject.name + ": " + id);
            }
            Debug.LogWarning("New ID for " + gameObject.name + " replacing " + id);
            // The following lines tell Unity to let the developer save the change.
            Undo.RecordObject(this, "New ID for " + gameObject.name);
            id = System.Guid.NewGuid().ToString();
        }

        manager.Register(this);
    }