public void GetGuid_ReturnsUniqueGuid_WhenNewGameObjectCreated()
        {
            GuidComponent guid1 = guidBase;
            GuidComponent guid2 = CreateNewGuid();

            Assert.AreNotEqual(guid1.GetGuid(), guid2.GetGuid());
        }
Ejemplo n.º 2
0
    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());
        }
Ejemplo n.º 5
0
        //-------------------------------------------------------------------------
        // 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();
            }
        }
Ejemplo n.º 6
0
 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);
        }
Ejemplo n.º 9
0
 //-------------------------------------------------------------------------
 // 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);
        }
Ejemplo n.º 11
0
    public void Setup()
    {
        prefabPath = "Assets/TemporaryTestGuid.prefab";

        guidBase = CreateNewGuid();
        prefab   = PrefabUtility.SaveAsPrefabAsset(guidBase.gameObject, prefabPath);

        guidPrefab = prefab.GetComponent <GuidComponent>();
    }
Ejemplo n.º 12
0
    public IEnumerator GuidPrefabInstance()
    {
        GuidComponent instance = GameObject.Instantiate <GuidComponent>(guidPrefab);

        Assert.AreNotEqual(guidBase.GetGuid(), instance.GetGuid());
        Assert.AreNotEqual(instance.GetGuid(), guidPrefab.GetGuid());

        yield return(null);
    }
Ejemplo n.º 13
0
    public IEnumerator GuidCreation()
    {
        GuidComponent guid1 = guidBase;
        GuidComponent guid2 = CreateNewGuid();

        Assert.AreNotEqual(guid1.GetGuid(), guid2.GetGuid());

        yield return(null);
    }
Ejemplo n.º 14
0
        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());
        }
Ejemplo n.º 16
0
    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);
    }
Ejemplo n.º 17
0
    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);
        }
Ejemplo n.º 19
0
        //-------------------------------------------------------------------------
        // 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();
        }
Ejemplo n.º 20
0
    public IEnumerator GuidInvalidReference()
    {
        GuidComponent newGuid   = CreateNewGuid();
        GuidReference reference = new GuidReference(newGuid);

        Object.DestroyImmediate(newGuid);

        Assert.IsNull(reference.gameObject);

        yield return(null);
    }
Ejemplo n.º 21
0
    // 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);
            }
        }
    }
Ejemplo n.º 22
0
        //-------------------------------------------------------------------------
        // 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();
        }
Ejemplo n.º 23
0
        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;
        }
Ejemplo n.º 24
0
    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);
    }
Ejemplo n.º 25
0
        //-------------------------------------------------------------------------
        // 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!");
            }
        }
Ejemplo n.º 26
0
        //-------------------------------------------------------------------------
        // 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();
        }
Ejemplo n.º 27
0
    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);
    }
Ejemplo n.º 28
0
    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);
    }
Ejemplo n.º 29
0
        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();
                    }
                }
            }
        }
Ejemplo n.º 30
0
        //-------------------------------------------------------------------------
        // 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 + ".\"");
                }
            }
        }