Example #1
0
        protected override void ManageSuddenChanges(BaseCreation config, bool isForward)
        {
            if (isForward)
            {
                if (_createdGO == null)
                {
                    _parent = config.ParentRef.HasValue
                                                ? References.Instance.GetGameObject(config.FullParentRef)
                                                : config.DefaultParentGO;

                    if (config.GameObject == null)
                    {
                        _createdGO = new GameObject(config.Ref.ToString());
                        _createdGO.transform.parent = _parent.transform;
                    }
                    else
                    {
                        _createdGO      = GameObject.Instantiate(config.GameObject, _parent.transform);
                        _createdGO.name = config.Ref.ToString();
                    }

                    References.Instance.AddGameObject(config.Ref.ToString(), _createdGO);

                    Helper.KeepAnimatorControllerStateOnDisable(_createdGO);
                    Helper.AddParticleSystemManager(_createdGO);
                    Helper.AddSliderParts(_createdGO);
                }
                else
                {
                    DestroyOccurrence.Restore(_createdGO, _parent.transform, config.Ref.ToString(), true);
                }

                Helper.SetAnimatorsTimeScale(_createdGO);
                Helper.SetAudioSourcesTimeScale(_createdGO);
            }
            else
            {
                DestroyOccurrence.Destroy(_createdGO, _newConfig.Ref.ToString(), true);
            }
        }
        protected override void ManageSuddenChanges(ClearScene config, bool isForward)
        {
            if (isForward)
            {
                if (_firstTime)
                {
                    _refs = References.Instance.GetRefs();
                    _referencesGameObjects = References.Instance.GetGameObjects();
                }
                References.Instance.ResetMaps();

                foreach (Transform transform in Helper.RootGameObject.transform)
                {
                    var go = transform.gameObject;
                    DestroyOccurrence.Destroy(go, null, false);
                    if (_firstTime)
                    {
                        _deletedGameObjects.Add(go);
                    }
                }

                if (_firstTime)
                {
                    _firstTime = false;
                }
            }
            else
            {
                foreach (var go in _deletedGameObjects)
                {
                    DestroyOccurrence.Restore(go, Helper.RootGameObject.transform, null, false);
                }

                for (int i = 0; i < _refs.Length; i++)
                {
                    References.Instance.AddGameObject(_refs[i], _referencesGameObjects[i]);
                }
            }
        }