public string GetOrCreateUniqueID(GameObject go) { LSS_UID uid = go.GetComponent <LSS_UID> (); if (!uid) // If this object does not have a presistant unique id, then add one. { go.AddComponent <LSS_UID> (); return(go.GetComponent <LSS_UID> ().uniqueId); } return(uid.uniqueId); }
// Only compile the code in an editor build #if UNITY_EDITOR private void RecreateIfComponentsExist() { if (Application.isEditor || allowRecreate) { if (ObjectHasScenariosComponents()) { LSS_UID copy = gameObject.AddComponent <LSS_UID>(); if (copy != null) //Game starting? { copy.m_uniqueId = m_uniqueId; allGuids.Add(m_uniqueId, copy); EditorUtility.DisplayDialog( "Can't remove component", "Can't remove " + this.GetType() + " until all other Lighting Scenario Switcher (LSS) components have been removed.\n\nNote: If this unique ID is removed then all previously saved lighting scenarios will no longer sync with this object!", "OK"); } } } }
public void OnEnable() { targetObject = (LSS_UID)target; isScenariosManager = targetObject.GetComponent <LSS_FrontEnd> () != null; }