void ReleaseAssetReference(AssetReference reference, NotifyOnDestroy notification)
 {
     reference.ReleaseInstance(notification.gameObject);
     if (_asyncHandles[reference].IsValid())
     {
         Addressables.Release(_asyncHandles[reference]);
     }
     _asyncHandles.Remove(reference);
 }
Beispiel #2
0
        private static void Remove(AssetReference reference, NotifyOnDestroy obj)
        {
            Addressables.ReleaseInstance(obj.gameObject);
            AssetSprites[reference].Remove(obj.gameObject);
            if (AssetSprites[reference].Count == 0)
            {
                if (OperationHandles[reference].IsValid())
                {
                    Addressables.Release(OperationHandles[reference]);
                }

                OperationHandles.Remove(reference);
            }
        }
Beispiel #3
0
        public static void SpawnObject(AssetReference reference)
        {
            reference.InstantiateAsync().Completed += (operation) => {
                if (!AssetSprites.ContainsKey(reference))
                {
                    AssetSprites.Add(reference, new List <GameObject>());
                }

                AssetSprites[reference].Add(operation.Result);
                NotifyOnDestroy notify = operation.Result.AddComponent <NotifyOnDestroy>();
                notify.Destroyed     += Remove;
                notify.AssetReference = reference;
            };
        }
Beispiel #4
0
    private void Remove(AssetReference assetReference, NotifyOnDestroy obj)
    {
        Addressables.ReleaseInstance(obj.gameObject);

        _spawnedParticleSystems[assetReference].Remove(obj.gameObject);
        if (_spawnedParticleSystems[assetReference].Count == 0)
        {
            Debug.Log($"Removed all {assetReference.RuntimeKey.ToString()}");

            if (_asyncOperationHandles[assetReference].IsValid())
            {
                Addressables.Release(_asyncOperationHandles[assetReference]);
            }

            _asyncOperationHandles.Remove(assetReference);
        }
    }
Beispiel #5
0
    public GameObject SpawnEnemy()
    {
        if (!SpawningEnabled)
        {
            return(null);
        }

        GameObject g = Instantiate(enemyPrefab, transform.position, Quaternion.identity) as GameObject;

        g.name = enemyPrefab.name;

        Transform t = g.transform;

        t.SetParent(WorldInfo.Instance.IsOverworld ? _enemiesContainer : transform.parent);
        t.forward = transform.up;

        Enemy enemy = g.GetComponent <Enemy>();

        if (enemy != null)
        {
            enemy.SpawnPoint = this;

            AssignBoundaryToSpawnedEnemy(enemy);
            AssignSpecialDropItemToSpawnedEnemy(enemy);
        }

        NotifyOnDestroy n = g.AddComponent <NotifyOnDestroy>();

        n.receiver   = gameObject;
        n.methodName = "OnSpawnedEnemyDestroyed";

        _spawnedEnemy = g;

        SendMessage("OnEnemySpawned", enemy, SendMessageOptions.DontRequireReceiver);

        return(g);
    }
Beispiel #6
0
 private void Remove(AssetReference assetReference, NotifyOnDestroy obj)
 {
     Addressables.ReleaseInstance(obj.gameObject);
     //Debug.Log("RELEASING");
 }
Beispiel #7
0
 private void Remove(AssetReference assetReference, NotifyOnDestroy obj)
 {
     Addressables.ReleaseInstance(obj.gameObject);
 }