Example #1
0
 public void Dispose()
 {
     if (GameController.GetInstance().Player.life <= 0)
     {
         _blobAssetFly.Dispose();
         _blobAssetGround.Dispose();
         _blobAssetFlyBoss.Dispose();
         _blobAssetGroundBoss.Dispose();
     }
 }
    private void Awake()
    {
        World          destinationWorld = World.DefaultGameObjectInjectionWorld;
        BlobAssetStore blobAssetStore   = new BlobAssetStore();
        GameObjectConversionSettings gameObjectConversionSettings = GameObjectConversionSettings.FromWorld(destinationWorld, blobAssetStore);
        Entity           entity           = GameObjectConversionUtility.ConvertGameObjectHierarchy(prefab, gameObjectConversionSettings);
        SineMovementData sineMovementData = new SineMovementData()
        {
            moveSpeed = 10
        };

        for (int x = 0; x < count; x++)
        {
            for (int y = 0; y < count; y++)
            {
                Entity      instanceEntity = destinationWorld.EntityManager.Instantiate(entity);
                Translation translation    = new Translation()
                {
                    Value = new Unity.Mathematics.float3(x - count * 0.5f, 0, y - count * 0.5f)
                };

                sineMovementData.originalPosition = translation.Value;
                destinationWorld.EntityManager.SetComponentData(instanceEntity, translation);
                destinationWorld.EntityManager.SetComponentData(instanceEntity, sineMovementData);
            }
        }

        blobAssetStore.Dispose();
    }
Example #3
0
 private void OnDestroy()
 {
     if (blobAssetStore != null)
     {
         blobAssetStore.Dispose();
     }
 }
Example #4
0
        public void Dispose()
        {
            if (m_ClientWorlds != null)
            {
                for (int i = 0; i < m_ClientWorlds.Length; ++i)
                {
                    if (m_ClientWorlds[i] != null)
                    {
                        m_ClientWorlds[i].Dispose();
                    }
                }
            }
            if (m_ServerWorld != null)
            {
                m_ServerWorld.Dispose();
            }
            if (m_DefaultWorld != null)
            {
                m_DefaultWorld.Dispose();
            }
            m_ClientWorlds = null;
            m_ServerWorld  = null;
            m_DefaultWorld = null;
            ClientServerBootstrap.s_State = m_OldBootstrapState;

#if UNITY_EDITOR
            if (m_GhostCollection != null)
            {
                m_BlobAssetStore.Dispose();
            }
#endif
        }
Example #5
0
        void Start()
        {
            // Create entity prefab from the game object hierarchy once
            BlobAssetStore blobAsset = new BlobAssetStore();

            var settings      = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, blobAsset);
            var prefab        = GameObjectConversionUtility.ConvertGameObjectHierarchy(Prefab, settings);
            var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

            for (var x = 0; x < CountX; x++)
            {
                for (var y = 0; y < CountY; y++)
                {
                    // Efficiently instantiate a bunch of entities from the already converted entity prefab
                    var instance = entityManager.Instantiate(prefab);

                    // Place the instantiated entity in a grid with some noise
                    var position = transform.TransformPoint(new float3(x * 1.3F, noise.cnoise(new float2(x, y) * 0.21F) * 2, y * 1.3F));
                    entityManager.SetComponentData(instance, new Translation {
                        Value = position
                    });
                }
            }

            blobAsset.Dispose();
        }
Example #6
0
    // Start is called before the first frame update
    void Start()
    {
        BlobAssetStore blobAsset = new BlobAssetStore();

        manager = World.DefaultGameObjectInjectionWorld.EntityManager;
        var settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, blobAsset);
        var prefab   = GameObjectConversionUtility.ConvertGameObjectHierarchy(sheepPrefab, settings);

        for (int i = 0; i < numSheep; i++)
        {
            var instance = manager.Instantiate(prefab);
            var position = transform.TransformPoint(
                new float3(
                    UnityEngine.Random.Range(-50, 50),
                    UnityEngine.Random.Range(0, 100),
                    UnityEngine.Random.Range(-50, 50)));
            manager.SetComponentData(instance, new Translation {
                Value = position
            });
            manager.SetComponentData(instance, new Rotation {
                Value = new quaternion(0, 0, 0, 0)
            });
        }

        blobAsset.Dispose();
    }
Example #7
0
 protected override void OnDestroy()
 {
     if (HasSingleton <UIData>())
     {
         EntityManager.DestroyEntity(GetSingletonEntity <UIData>());
     }
     blobAssetStore.Dispose();
 }
Example #8
0
 void OnDestroy()
 {
     if (m_BlobAssetStore != null)
     {
         m_BlobAssetStore.Dispose();
         m_BlobAssetStore = null;
     }
 }
Example #9
0
 private void OnDestroy()
 {
     // Dispose of the BlobAssetStore, else we're get a message:
     // A Native Collection has not been disposed, resulting in a memory leak.
     if (blobAssetStore != null)
     {
         blobAssetStore.Dispose();
     }
 }
    private void OnDestroy()
    {
        foreach (Entity en in entities)
        {
            enManager.DestroyEntity(en);
        }

        entities.Clear();
        bStore.Dispose();
    }
    // Start is called before the first frame update
    void Start()
    {
        manager = World.DefaultGameObjectInjectionWorld.EntityManager;
        BlobAssetStore assetStore             = new BlobAssetStore();
        GameObjectConversionSettings settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, assetStore);

        srcEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy(entityPrefab, settings);
        assetStore.Dispose();
        AddEntities(entityCount);
        spawnedEntities = entityCount;
    }
 public void Dispose()
 {
     if (World == null)
     {
         return;
     }
     MissingRenderDataQuery.Dispose();
     MissingSceneQuery.Dispose();
     BlobAssets.Dispose();
     World.Dispose();
     BlobAssetStore.Dispose();
 }
Example #13
0
 public void TearDown()
 {
     EditorSceneManager.CloseScene(scene, true);
     if (blobAssetStore != null)
     {
         blobAssetStore.Dispose();
     }
     if (world != null)
     {
         world.Dispose();
     }
     entityManager = default;
 }
        private void Awake()
        {
            instance = this;
            entitiesByGoInstanceId = new Dictionary <int, Entity>();
            prefabAssetStore?.Dispose();
            prefabAssetStore = new BlobAssetStore();
            foreach (var spawnableEntity in spawnableEntityPrefabs)
            {
                var prefabEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy(spawnableEntity.gameObject,
                                                                                          GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, prefabAssetStore));

                entitiesByGoInstanceId[spawnableEntity.gameObject.GetInstanceID()] = prefabEntity;
            }
        }
        public void Dispose()
        {
            _BlobAssetStore.Dispose();
            _IncrementalConversionChangeTracker.Dispose();
#if UNITY_2020_2_OR_NEWER
            _IncrementalConversionDebug.Dispose();
#endif

            try
            {
                _LiveLinkDiffer.Dispose();
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            try
            {
                if (_GameObjectWorld != null && _GameObjectWorld.IsCreated)
                {
                    _GameObjectWorld.Dispose();
                }
                _GameObjectWorld = null;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            try
            {
                if (_ConvertedWorld != null && _ConvertedWorld.IsCreated)
                {
                    _ConvertedWorld.Dispose();
                }
                _ConvertedWorld = null;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
Example #16
0
    void Start()
    {
        entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

        var blob = new BlobAssetStore();

        var settings = GameObjectConversionSettings.FromWorld(
            World.DefaultGameObjectInjectionWorld, blob);

        for (int i = 0; i < spawnPrefabs.Length; i++)
        {
            spawnEntityPrefabs[i] = GameObjectConversionUtility.ConvertGameObjectHierarchy(
                spawnPrefabs[i], settings);
        }

        Spawn();

        blob.Dispose();
    }
    public void GenerateMap2()
    {
        _mapGeneratorSystem = World.DefaultGameObjectInjectionWorld.GetOrCreateSystem <MapGeneratorSystem>();

        World world = World.DefaultGameObjectInjectionWorld;

        blobAsset = new BlobAssetStore();
        var    conversionSetting = new GameObjectConversionSettings(world, GameObjectConversionUtility.ConversionFlags.AssignName, blobAsset);
        Entity mapEntity         = GameObjectConversionUtility.ConvertGameObjectHierarchy(mapPrefab, conversionSetting);

        _mapGeneratorSystem.mapPrefab = mapPrefab;

        _mapGeneratorSystem.mapEntity      = mapEntity;
        _mapGeneratorSystem.mapGenSettings = mapSettings;
        _mapGeneratorSystem.debugMaterial  = debugMaterial;


        _mapGeneratorSystem.GenerateMapMatchingSquares();

        blobAsset.Dispose();
    }
Example #18
0
 void Update()
 {
     if (data == 0)
     {
         //World.Active.EntityManager.Instantiate(World.Active.GetExistingSystem<GameObjectConversionSystem>().GetPrimaryEntity(Prefab));
         //Instantiate(Prefab);
         var    blob = new BlobAssetStore();
         Entity e    = GameObjectConversionUtility.ConvertGameObjectHierarchy(Prefab, GameObjectConversionSettings.FromWorld(
                                                                                  World.DefaultGameObjectInjectionWorld, blob
                                                                                  ));
         blob.Dispose();
         //World.Active.EntityManager.AddComponentData(e, new Unity.Transforms.NonUniformScale());
         //World.Active.EntityManager.GetComponentObject<Transform>(e);
         World.DefaultGameObjectInjectionWorld.EntityManager.AddComponentData(e, new Unity.Transforms.NonUniformScale());
         World.DefaultGameObjectInjectionWorld.EntityManager.RemoveComponent <Unity.Transforms.Parent>(e);
         World.DefaultGameObjectInjectionWorld.EntityManager.RemoveComponent <Unity.Transforms.LocalToParent>(e);
         Debug.Log("已生成");
         //World.Active.EntityManager.DestroyEntity(Prefab.GetComponent<WorldObject>().entity);
     }
     data += 1;
 }
        public void Dispose()
        {
            m_BlobAssetStore.Dispose();
            m_AssetDependencies.Dispose();

            try
            {
                _LiveLinkDiffer.Dispose();
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            try
            {
                if (_GameObjectWorld != null && _GameObjectWorld.IsCreated)
                {
                    _GameObjectWorld.Dispose();
                }
                _GameObjectWorld = null;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            try
            {
                if (_ConvertedWorld != null && _ConvertedWorld.IsCreated)
                {
                    _ConvertedWorld.Dispose();
                }
                _ConvertedWorld = null;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
Example #20
0
        private void Update()
        {
            // так спавнятся префабы с ConvertToEntity
            if (Input.GetKeyDown(KeyCode.Space))
            {
                Vector3 pos = new Vector3(UnityEngine.Random.Range(-10, 10), 0, UnityEngine.Random.Range(-10, 10));
                Instantiate(tankPrefabEntity, pos, Quaternion.identity);

                CountShip();
                CountTank();
            }

            // А так обычные префабы (такие танки не будут отображаться в счетчике,
            // т.к. у них нет TankData)
            if (Input.GetKeyDown(KeyCode.Q))
            {
                BlobAssetStore blobAsset = new BlobAssetStore();
                Vector3        pos       = new Vector3(UnityEngine.Random.Range(-10, 10),
                                                       0, UnityEngine.Random.Range(-10, 10));

                var settings = GameObjectConversionSettings.FromWorld(world, blobAsset);
                var prefab   = GameObjectConversionUtility.ConvertGameObjectHierarchy(tankPrefab, settings);
                var instance = entityManager.Instantiate(prefab);
                var position = transform.TransformPoint(new float3(pos.x, 0, pos.z));

                entityManager.SetComponentData(instance, new Translation {
                    Value = position
                });
                entityManager.SetComponentData(instance, new Rotation {
                    Value = new quaternion(0, 0, 0, 0)
                });

                blobAsset.Dispose();

                CountShip();
                CountTank();
            }
        }
Example #21
0
        void Start()
        {
            // setup references to World and EntityManager
            defaultWorld  = World.DefaultGameObjectInjectionWorld;
            entityManager = defaultWorld.EntityManager;
            BlobAssetStore blobAsset = new BlobAssetStore();

            // generate Entity Prefab
            if (gameObjectPrefab != null)
            {
                GameObjectConversionSettings settings =
                    GameObjectConversionSettings.FromWorld(defaultWorld, blobAsset);
                entityPrefab =
                    GameObjectConversionUtility.ConvertGameObjectHierarchy(gameObjectPrefab, settings);

                // spawn x by y grid of Entities
                InstantiateEntityGrid(xSize, ySize, spacing);

                //InstantiateEntity(new float3(2, 2, 2));
            }

            blobAsset.Dispose();
        }
Example #22
0
        // Start is called before the first frame update
        void Start()
        {
            BlobAssetStore blobAsset = new BlobAssetStore();

            manager = World.DefaultGameObjectInjectionWorld.EntityManager;
            var settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, blobAsset);
            var prefab   = GameObjectConversionUtility.ConvertGameObjectHierarchy(asteroidPrefab, settings);

            for (int i = 0; i < numAsteroids; i++)
            {
                var   instance = manager.Instantiate(prefab);
                float x        = Mathf.Sin(i) * UnityEngine.Random.Range(25, 50);
                float y        = UnityEngine.Random.Range(-5, 5);
                float z        = Mathf.Cos(i) * UnityEngine.Random.Range(25, 50);
                var   position = transform.TransformPoint(new float3(x, y, z));
                manager.SetComponentData(instance, new Translation {
                    Value = position
                });

                var q = Quaternion.Euler(new Vector3(0, 0, 0));
                manager.SetComponentData(instance, new Rotation {
                    Value = new quaternion(q.x, q.y, q.z, q.w)
                });

                var scale = new float3(UnityEngine.Random.Range(5, 15),
                                       UnityEngine.Random.Range(5, 10),
                                       UnityEngine.Random.Range(5, 15));
                scale *= UnityEngine.Random.Range(1, 10);

                manager.AddComponent(instance, ComponentType.ReadWrite <NonUniformScale>());
                manager.SetComponentData(instance, new NonUniformScale {
                    Value = scale
                });
            }

            blobAsset.Dispose();
        }
Example #23
0
 private void OnDestroy()
 {
     blobAssetStore.Dispose();
 }
 private void OnDestroy()
 {
     store.Dispose();
 }
 private void OnDestroy()
 {
     prefabAssetStore.Dispose();
     prefabAssetStore = null;
 }
Example #26
0
 void OnDestroy()
 {
     assetStore.Dispose();
 }
 public void Dispose()
 {
     objectsToEntity.Clear();
     store.Dispose();
 }
Example #28
0
 private void OnApplicationQuit()
 {
     blob.Dispose();
 }
Example #29
0
 private void OnDestroy()
 {
     bas.Dispose();
 }
 /// Disposes of asset on application end
 private void OnDisable()
 {
     asset.Dispose();
 }