public virtual void NavigateBack(bool keepCache = false)
 {
     if (NavigatedFromPage != null)
     {
         //NavigatedFromPage.NavigateTo();
         NavigationHistory.Pop().NavigateTo(keepCache);
     }
 }
Пример #2
0
        public T SpawnAndGetGameObject(T gameObjectToSpawn, bool useSpawnerTransformValues = true)
        {
            if (SpawnLimit > 0 && SpawnedGameObjects.Count >= SpawnLimit)
            {
                return(null);
            }

            T spawnedGameObject;

            if (PoolSize > 0 && _pooledGameObjects.Any())
            {
                spawnedGameObject = _pooledGameObjects.Pop();
                spawnedGameObject.gameObject.SetActive(true);
            }
            else
            {
                spawnedGameObject = Instantiate(gameObjectToSpawn);
            }

            ValidateSpawnParent();
            spawnedGameObject.transform.SetParent(SpawnParent);

            if (useSpawnerTransformValues)
            {
                gameObject.transform.CopyValuesTo(spawnedGameObject.transform, false);
            }
            else
            {
                gameObjectToSpawn.transform.CopyValuesTo(spawnedGameObject.transform, false);
                // spawnedGameObject.transform.ResetScaleAndRotation();
                spawnedGameObject.transform.localPosition = Vector3.zero; //transform.localPosition;
            }

            _spawnedGameObjects.Add(spawnedGameObject);
            OnSpawnEvent.Invoke(spawnedGameObject);
            return(spawnedGameObject);
        }