示例#1
0
        public void TestSpawnWithPositionAndRotationAndPriorityAndLifetime()
        {
            GameObject gameObject = new GameObject();

            Assert.IsNotNull(gameObject);
            gameObject.name = "LifetimeObject";
            gameObject.AddComponent <LifetimeComponent>();
            LifetimeComponent component = gameObject.GetComponent <LifetimeComponent>();

            Assert.IsNotNull(component);
            component.SetLifetime(1f);
            gameObject.AddComponent <PriorityComponent>();
            PriorityComponent component2 = gameObject.GetComponent <PriorityComponent>();

            Assert.IsNotNull(component2);
            component2.Priority           = 1;
            m_objectPool.PrefabToInstance = Object.Instantiate(gameObject);
            Assert.IsNotNull(m_objectPool.PrefabToInstance);
            m_objectPool.OnEnable();
            Vector3    position = new Vector3(0f, 0f, 0f);
            Quaternion rotation = Quaternion.Euler(new Vector3(0f, 0f, 0f));

            for (int i = 0; i < InitialPoolSize; i++)
            {
                Assert.IsNotNull(m_objectPool.Spawn(position, rotation, 4, 1f));
            }
            Object.DestroyImmediate(m_objectPool.PrefabToInstance);
            Object.DestroyImmediate(gameObject);
        }
示例#2
0
        public void TestSpawnWithTrandformAndPriorityAndLifetime()
        {
            GameObject gameObject = new GameObject();

            Assert.IsNotNull(gameObject);
            gameObject.name = "LifetimeObject";
            gameObject.AddComponent <LifetimeComponent>();
            LifetimeComponent component = gameObject.GetComponent <LifetimeComponent>();

            Assert.IsNotNull(component);
            component.SetLifetime(1f);
            gameObject.AddComponent <PriorityComponent>();
            PriorityComponent component2 = gameObject.GetComponent <PriorityComponent>();

            Assert.IsNotNull(component2);
            component2.Priority           = 1;
            m_objectPool.PrefabToInstance = Object.Instantiate(gameObject);
            Assert.IsNotNull(m_objectPool.PrefabToInstance);
            m_objectPool.OnEnable();
            for (int i = 0; i < InitialPoolSize; i++)
            {
                Assert.IsNotNull(m_objectPool.Spawn(m_objectPool.transform, 4, 1f));
            }
            Object.DestroyImmediate(m_objectPool.PrefabToInstance);
            Object.DestroyImmediate(gameObject);
        }