Esempio n. 1
0
        private void ShiftX(SceneFragment fragment, float offsetX)
        {
            var offset = new Vector3(offsetX, 0.0f);

            fragment.transform.Translate(offset);

            if (fragment.Roots != null)
            {
                for (int i = 0; i < fragment.Roots.Length; i++)
                {
                    fragment.Roots[i].Translate(offset);
                }
            }
        }
Esempio n. 2
0
        private bool RemoveFirstInvisibleFragment()
        {
            if (SceneStream == null)
            {
                return(false);
            }

            if (_activeFragments.Count <= 0)
            {
                return(false);
            }

            Debug.AssertFormat(
                _activeFragmentScenes.Count == _activeFragments.Count,
                "ActiveScenes.Count = {0}, ActiveFragments.Count = {1}",
                _activeFragmentScenes.Count,
                _activeFragments.Count);

            SceneFragment fragment     = _activeFragments.Peek();
            Rect          fragmentRect = fragment.Rect;
            Rect          viewRect     = SceneStream.View;

            //Debug.LogFormat("Peeking {0}", fragment.gameObject.scene.name);

            if (!viewRect.Overlaps(fragmentRect))
            {
                string fragmentScene = _activeFragmentScenes.Dequeue();
                _activeFragments.Dequeue();

                SceneManager.UnloadSceneAsync(fragmentScene);

                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        internal void AddActive(SceneFragment fragment)
        {
            float         maxX             = float.MinValue;
            SceneFragment?fragmentWithMaxX = null;

            foreach (SceneFragment existingFragment in _activeFragments)
            {
                float x = existingFragment.transform.position.x;

                if (x > maxX)
                {
                    maxX             = x;
                    fragmentWithMaxX = existingFragment;
                }
            }

            if (fragmentWithMaxX != null)
            {
                float offsetX = fragmentWithMaxX.Size.x / 2.0f + fragment.Size.x / 2.0f + maxX;
                ShiftX(fragment, offsetX);
            }

            _activeFragments.Enqueue(fragment);
        }