public void GetGuid_ReturnsUniqueGuid_WhenNewGameObjectCreated() { GuidComponent guid1 = guidBase; GuidComponent guid2 = CreateNewGuid(); Assert.AreNotEqual(guid1.GetGuid(), guid2.GetGuid()); }
private bool InternalAdd(GuidComponent guidComponent) { Guid guid = guidComponent.GetGuid(); GuidManager.GuidInfo guidInfo = new GuidManager.GuidInfo(guidComponent); if (!this.guidToObjectMap.ContainsKey(guid)) { this.guidToObjectMap.Add(guid, guidInfo); return(true); } GuidManager.GuidInfo guidInfo2 = this.guidToObjectMap[guid]; if (guidInfo2.go != null && guidInfo2.go != guidComponent.gameObject) { if (Application.isPlaying) { Debug.LogWarningFormat("Guid Collision Detected between {0} and {1}.\nAssigning new Guid. Consider tracking runtime instances using a direct reference or other method.", new object[] { (this.guidToObjectMap[guid].go != null) ? this.guidToObjectMap[guid].go.name : "NULL", (guidComponent != null) ? guidComponent.name : "NULL" }); } else { Debug.LogWarningFormat(guidComponent, "Guid Collision Detected while creating {0}.\nAssigning new Guid.", new object[] { (guidComponent != null) ? guidComponent.name : "NULL" }); } return(false); } guidInfo2.go = guidInfo.go; guidInfo2.HandleAddCallback(); this.guidToObjectMap[guid] = guidInfo2; return(true); }
public ReplicatedGameObject(GameObject obj) { this.m_IsNull = true; this.m_Resolved = true; this.m_ResolvedObj = obj; byte[] gameObjectBytes; if (obj == null) { gameObjectBytes = null; } else { GuidComponent component = obj.GetComponent<GuidComponent>(); gameObjectBytes = ((component != null) ? component.GetGuidBytes() : null); } this.m_GameObjectBytes = gameObjectBytes; if (this.m_GameObjectBytes != null) { for (int i = 0; i < this.m_GameObjectBytes.Length; i++) { if (this.m_GameObjectBytes[i] != 0) { this.m_IsNull = false; return; } } } }
public void GetGuid_ReturnsUniqueGuid_WhenInstantiatedFromPrefab() { GuidComponent instance = Object.Instantiate <GuidComponent>(guidPrefab); Assert.AreNotEqual(guidBase.GetGuid(), instance.GetGuid()); Assert.AreNotEqual(instance.GetGuid(), guidPrefab.GetGuid()); }
//------------------------------------------------------------------------- // Unity API //------------------------------------------------------------------------- private void Awake() { guid = GetComponent <GuidComponent>(); if (guid == null) { Debug.LogWarning("Game object \"" + name + "\" is missing a GUID component! Add one in the inspector."); } string keyBase = guid.ToString() + Keys.ENABLED; keys = new List <string>(); foreach (MonoBehaviour comp in ComponentsToTrack) { if (comp != null) { keys.Add(keyBase + comp.GetType().ToString()); } } if (RestoreOn == APICall.Awake) { Retrieve(); } }
public static bool Add(GuidComponent guidComponent) { if (GuidManager.Instance == null) { GuidManager.Instance = new GuidManager(); } return(GuidManager.Instance.InternalAdd(guidComponent)); }
public void OneTimeSetup() { GuidManagerSingleton.SetInstance(new GuidManager()); guidBase = CreateNewGuid(); prefab = PrefabUtility.CreatePrefab(PrefabPath, guidBase.gameObject); guidPrefab = prefab.GetComponent <GuidComponent>(); }
public void GuidReference_ReturnsGameObject_WhenValidReference() { GuidComponent newGuid = GuidComponentTests.CreateNewGuid(); GuidReference reference = new GuidReference(newGuid.GetGuid()); guidManagerMock.ResolveGuidResult = newGuid.gameObject; Assert.AreEqual(newGuid.gameObject, reference.gameObject); }
//------------------------------------------------------------------------- // Unity API //------------------------------------------------------------------------- private void Awake() { guid = GetComponent <GuidComponent>(); foreach (PuzzleElement element in Elements) { element.SetPuzzle(this); } }
public override void OnInspectorGUI() { if (guidComp == null) { guidComp = (GuidComponent)target; } EditorGUILayout.LabelField("Guid:", guidComp.GuidString); }
public void Setup() { prefabPath = "Assets/TemporaryTestGuid.prefab"; guidBase = CreateNewGuid(); prefab = PrefabUtility.SaveAsPrefabAsset(guidBase.gameObject, prefabPath); guidPrefab = prefab.GetComponent <GuidComponent>(); }
public IEnumerator GuidPrefabInstance() { GuidComponent instance = GameObject.Instantiate <GuidComponent>(guidPrefab); Assert.AreNotEqual(guidBase.GetGuid(), instance.GetGuid()); Assert.AreNotEqual(instance.GetGuid(), guidPrefab.GetGuid()); yield return(null); }
public IEnumerator GuidCreation() { GuidComponent guid1 = guidBase; GuidComponent guid2 = CreateNewGuid(); Assert.AreNotEqual(guid1.GetGuid(), guid2.GetGuid()); yield return(null); }
public override void OnInspectorGUI() { if (_guid == null) { _guid = (GuidComponent)target; } using (new EditorGUI.DisabledScope(true)) EditorGUILayout.TextField("Guid:", _guid.GetGuid().ToString()); }
public void GetGuid_ReturnsUniqueGuid_WhenInstantiatedFromGameObject() { LogAssert.Expect(LogType.Warning, "Guid Collision Detected while creating GuidTestGO(Clone).\nAssigning new Guid."); GuidComponent clone = Object.Instantiate <GuidComponent>(guidBase); Assert.AreNotEqual(guidBase.GetGuid(), clone.GetGuid()); }
public IEnumerator GuidDuplication() { LogAssert.Expect(LogType.Warning, "Guid Collision Detected while creating GuidTestGO(Clone).\nAssigning new Guid."); GuidComponent clone = GameObject.Instantiate <GuidComponent>(guidBase); Assert.AreNotEqual(guidBase.GetGuid(), clone.GetGuid()); yield return(null); }
public override void OnInspectorGUI() { if (guidComp == null) { guidComp = (GuidComponent)target; } // Draw label EditorGUILayout.LabelField("Guid:", guidComp.GetGuid().ToString()); }
public void GuidReference_ReturnsNull_WhenTargetGameObjectDestroyed() { GuidComponent newGuid = GuidComponentTests.CreateNewGuid(); GuidReference reference = new GuidReference(newGuid.GetGuid()); // todo Object.DestroyImmediate(newGuid); Assert.IsNull(reference.gameObject); }
//------------------------------------------------------------------------- // Unity API //------------------------------------------------------------------------- private void Awake() { originalPosition = transform.position; guid = GetComponent <GuidComponent>(); if (guid == null) { Debug.LogWarning("Game object \"" + name + "\" is missing a GUID component! Add one in the inspector."); } Retrieve(); }
public IEnumerator GuidInvalidReference() { GuidComponent newGuid = CreateNewGuid(); GuidReference reference = new GuidReference(newGuid); Object.DestroyImmediate(newGuid); Assert.IsNull(reference.gameObject); yield return(null); }
// Start is called before the first frame update void Start() { GameObject main = GameObject.Find("BattleSetup"); gc = GetComponent <GuidComponent>(); if (main != null) { sr = main.GetComponent <SetupRouter>(); if (sr.battleSetup.GuidInList(gc.GetGuid())) { Destroy(gameObject); } } }
//------------------------------------------------------------------------- // 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(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (guidComp == null) { guidComp = (GuidComponent)target; } // Draw label EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUI.enabled = false; EditorGUILayout.LabelField("Guid", guidComp.GetGuid().ToString(), EditorStyles.miniLabel); GUI.enabled = true; }
private P2PNetworkWriter BuildSpawnWriter(GameObject obj, bool give_ownership) { ReplicationComponent replComponentForGameObject = this.GetReplComponentForGameObject(obj, true); if (replComponentForGameObject == null) { if (P2PLogFilter.logError) { Debug.LogError("Replicator::Spawn called for non-replicable object " + obj.name + "!"); } return(null); } if (!replComponentForGameObject.enabled) { return(null); } GuidComponent component = obj.GetComponent <GuidComponent>(); if (component == null) { if (P2PLogFilter.logError) { Debug.LogError("Replicator::Spawn called for object " + obj.name + " without guid!", obj); } return(null); } if (P2PLogFilter.logPedantic) { Debug.Log(string.Concat(new string[] { "Replicator::BuildSpawnWriter called for ", obj.name, " with asset id ", replComponentForGameObject.AssetId.ToString(), "!" }), obj); } Replicator.s_ObjectSpawnMessage.assetId = replComponentForGameObject.AssetId; Replicator.s_ObjectSpawnMessage.guid_bytes = component.GetGuidBytes(); Replicator.s_ObjectSpawnMessage.position = obj.transform.position; Replicator.s_ObjectSpawnMessage.payload = replComponentForGameObject.Serialize(true); P2PNetworkWriter p2PNetworkWriter = new P2PNetworkWriter(); p2PNetworkWriter.StartMessage(give_ownership ? 9 : 2); Replicator.s_ObjectSpawnMessage.Serialize(p2PNetworkWriter); p2PNetworkWriter.FinishMessage(); return(p2PNetworkWriter); }
//------------------------------------------------------------------------- // Unity API //------------------------------------------------------------------------- private void Awake() { GuidComponent guidComponent = gameObject.GetComponent <GuidComponent>(); if (guidComponent != null) { guid = guidComponent.GetGuid().ToString(); if (VSave.Get <bool>(StaticFolders.DESTRUCTIBLE, guid + Keys.KEEP_DESTROYED)) { Destroy(this.gameObject, Delay); } } else { Debug.LogWarning("SelfDestructing object \"" + gameObject.name + "\" needs a GuidComponent!"); } }
//------------------------------------------------------------------------- // Unity API //------------------------------------------------------------------------- private void Awake() { guid = GetComponent <GuidComponent>(); if (guid == null) { Debug.LogWarning("Game object \"" + name + "\" is missing a GuidComponent! Add one in the inspector."); } anim = GetComponent <Animator>(); if (anim == null) { Debug.LogWarning("Game object \"" + name + "\" is missing an Animator Component! Add one in the inspector."); } parameters = anim.parameters; // Load the previous state. Retrieve(); }
public void Write(Transform value) { if (value == null || value.gameObject == null) { this.WritePackedUInt32(0u); return; } GuidComponent component = value.gameObject.GetComponent <GuidComponent>(); if (component != null) { this.Write(component); return; } if (P2PLogFilter.logWarn) { Debug.LogWarning("NetworkWriter " + value + " has no GuidComponent"); } this.WritePackedUInt32(0u); }
public void Write(GameObject value) { if (value == null) { this.Write(P2PNetworkWriter.EMTY_GUID_BYTES, GuidComponent.GUID_BYTES_CNT); return; } GuidComponent component = value.GetComponent <GuidComponent>(); if (component == null) { if (P2PLogFilter.logError) { Debug.LogError("P2PNetworkWriter writing GameObject " + value.name + " without GuidComponent"); } this.Write(P2PNetworkWriter.EMTY_GUID_BYTES, GuidComponent.GUID_BYTES_CNT); return; } this.Write(component.GetGuidBytes(), GuidComponent.GUID_BYTES_CNT); }
private void OnTriggerEnter2D(Collider2D collider) { if (enabled) { GuidComponent guid = GetObjectReference(collider); string key = guid != null?guid.ToString() : ""; if (guid != null && deliveryStatus.ContainsKey(key)) { deliveryStatus[key] = true; CheckAllInside(); if (allInside && (!fired || FireEveryTime)) { fired = true; Actions.Invoke(); } } } }
//------------------------------------------------------------------------- // Unity API //------------------------------------------------------------------------- private void Awake() { particles = GetComponent <ParticleSystem>(); guid = GetComponent <GuidComponent>(); if (particles != null && guid != null) { Retrieve(); } else { if (particles == null) { Debug.LogWarning("There's no particle system to retrieve on object \"" + name + ".\""); } else { Debug.LogWarning("You need to attach a GUID Component onto object \"" + name + ".\""); } } }