public virtual void NavigateBackToLastUniquePage(bool keepCache = false)
        {
            UIPage lastPage = null;

            do
            {
                lastPage = NavigationHistory.Pop();
            }while((NavigationHistory.Any() && lastPage == null) ||
                   (lastPage != null && lastPage == CurrentPage));

            if (lastPage != null)
            {
                lastPage.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);
        }