public void ForceGuid(byte[] new_guid_bytes) { if (base.gameObject.activeSelf) { Debug.LogError("Object active when assigning guid!"); } if (this.serializedGuid == null || this.serializedGuid.Length != GuidComponent.GUID_BYTES_CNT) { this.serializedGuid = new byte[GuidComponent.GUID_BYTES_CNT]; } new_guid_bytes.CopyTo(this.serializedGuid, 0); this.guid = new Guid(new_guid_bytes); GuidManager.Add(this); }
public void ForceGuid(Guid new_guid) { if (this.guid.CompareTo(new_guid) == 0) { return; } if (base.gameObject.activeSelf) { Debug.LogError("Object active when assigning guid!"); } this.serializedGuid = new_guid.ToByteArray(); this.guid = new_guid; GuidManager.Add(this); }
//------------------------------------------------------------------------- // Unity API //------------------------------------------------------------------------- private void Awake() { GuidComponent guid = GetComponent <GuidComponent>(); if (guid != null) { GuidManager.Add(guid); } else { Debug.LogWarning("Dialog Graph \"" + name + "\" is missing a GuidComponent! Add one in the unity editor."); } RefreshNodeList(); }
// When de-serializing or creating this component, we want to either restore our serialized GUID // or create a new one. protected virtual void CreateGuid() { // if our serialized data is invalid, then we are a new object and need a new GUID if (serializedGuid == null || serializedGuid.Length != 16) { #if UNITY_EDITOR // if in editor, make sure we aren't a prefab of some kind if (IsAssetOnDisk()) { return; } Undo.RecordObject(this, "Added GUID"); #endif guid = System.Guid.NewGuid(); serializedGuid = guid.ToByteArray(); #if UNITY_EDITOR // If we are creating a new GUID for a prefab instance of a prefab, but we have somehow lost our prefab connection // force a save of the modified prefab instance properties if (PrefabUtility.IsPartOfNonAssetPrefabInstance(this)) { PrefabUtility.RecordPrefabInstancePropertyModifications(this); } #endif } else if (guid == System.Guid.Empty) { // otherwise, we should set our system guid to our serialized guid guid = new System.Guid(serializedGuid); } // register with the GUID Manager so that other components can access this if (guid != System.Guid.Empty) { if (!GuidManager.Add(this)) { // if registration fails, we probably have a duplicate or invalid GUID, get us a new one. serializedGuid = null; guid = System.Guid.Empty; CreateGuid(); } } #if UNITY_EDITOR CreatedInEditor = true; #endif }
private void CreateGuid() { if (this.serializedGuid == null || this.serializedGuid.Length != GuidComponent.GUID_BYTES_CNT) { this.guid = Guid.NewGuid(); this.serializedGuid = this.guid.ToByteArray(); } else if (this.guid == Guid.Empty) { this.guid = new Guid(this.serializedGuid); } if (this.guid != Guid.Empty && !GuidManager.Add(this)) { this.serializedGuid = null; this.guid = Guid.Empty; this.CreateGuid(); } }
// When deserializaing or creating this component, we want to either restore our serialized GUID // or create a new one. private void CreateGuid() { // if our serialized data is invalid, then we are a new object and need a new GUID if (serializedGuid == null || serializedGuid.Length != 16) { guid = Guid.NewGuid(); serializedGuid = guid.ToByteArray(); #if UNITY_EDITOR // If we are creating a new GUID for a prefab instance of a prefab, but we have somehow lost our prefab connection // force a save of the modified prefab instance properties PrefabType prefabType = PrefabUtility.GetPrefabType(this); if (prefabType == PrefabType.PrefabInstance) { PrefabUtility.RecordPrefabInstancePropertyModifications(this); } #endif } else if (guid == Guid.Empty) { // otherwise, we should set our system guid to our serialized guid guid = new Guid(serializedGuid); } // register with the GUID Manager so that other components can access this if (guid != Guid.Empty) { if (!GuidManager.Add(this)) { // if registration fails, we probably have a duplicate or invalid GUID, get us a new one. serializedGuid = null; guid = Guid.Empty; CreateGuid(); } } }
public async Task <ActionResult <GuidAPIModel> > PostGuid(GuidAPIModel inputModel) { GuidDataModel guidModel = await _manager.Add(inputModel); return(guidModel.ToAPIModel()); }
public void Add_ThrowsArgumentNullException_WhenProvideNullGameObject() { Assert.Throws <ArgumentNullException>(() => guidManager.Add(Guid.NewGuid(), null)); }