Exemple #1
0
        private void EnsureSelectedSizeAreValid()
        {
            if (ScriptableSingleton <GameViewSizes> .instance.GetChangeID() != this.m_SizeChangeID)
            {
                this.m_SizeChangeID = ScriptableSingleton <GameViewSizes> .instance.GetChangeID();

                Array values = Enum.GetValues(typeof(GameViewSizeGroupType));
                if (this.m_SelectedSizes.Length != values.Length)
                {
                    Array.Resize <int>(ref this.m_SelectedSizes, values.Length);
                }
                IEnumerator enumerator = values.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        GameViewSizeGroupType gameViewSizeGroupType = (GameViewSizeGroupType)enumerator.Current;
                        GameViewSizeGroup     group = ScriptableSingleton <GameViewSizes> .instance.GetGroup(gameViewSizeGroupType);

                        int num = (int)gameViewSizeGroupType;
                        this.m_SelectedSizes[num] = Mathf.Clamp(this.m_SelectedSizes[num], 0, group.GetTotalCount() - 1);
                    }
                }
                finally
                {
                    IDisposable disposable;
                    if ((disposable = (enumerator as IDisposable)) != null)
                    {
                        disposable.Dispose();
                    }
                }
                int num2 = this.m_LowResolutionForAspectRatios.Length;
                if (this.m_LowResolutionForAspectRatios.Length != values.Length)
                {
                    Array.Resize <bool>(ref this.m_LowResolutionForAspectRatios, values.Length);
                }
                for (int i = num2; i < values.Length; i++)
                {
                    this.m_LowResolutionForAspectRatios[i] = GameViewSizes.DefaultLowResolutionSettingForSizeGroupType((GameViewSizeGroupType)values.GetValue(i));
                }
            }
        }
Exemple #2
0
        // Call when number of available aspects can have changed (after deserialization or gui change)
        private void EnsureSelectedSizeAreValid()
        {
            // Early out if no change was recorded
            if (GameViewSizes.instance.GetChangeID() == m_SizeChangeID)
            {
                return;
            }

            m_SizeChangeID = GameViewSizes.instance.GetChangeID();

            var sizeGroupTypes = System.Enum.GetValues(typeof(GameViewSizeGroupType));

            // Ensure deserialized array is resized if needed
            if (m_SelectedSizes.Length != sizeGroupTypes.Length)
            {
                System.Array.Resize(ref m_SelectedSizes, sizeGroupTypes.Length);
            }

            // Ensure deserialized selection index for each group is within valid range
            foreach (GameViewSizeGroupType groupType in sizeGroupTypes)
            {
                var gvsg  = GameViewSizes.instance.GetGroup(groupType);
                var index = (int)groupType;
                m_SelectedSizes[index] = Mathf.Clamp(m_SelectedSizes[index], 0, gvsg.GetTotalCount() - 1);
            }

            // Resize low resolution array as necessary, and fill in new indices with defaults
            var lowResolutionSettingsLength = m_LowResolutionForAspectRatios.Length;

            if (m_LowResolutionForAspectRatios.Length != sizeGroupTypes.Length)
            {
                System.Array.Resize(ref m_LowResolutionForAspectRatios, sizeGroupTypes.Length);
            }
            for (var groupIndex = lowResolutionSettingsLength; groupIndex < sizeGroupTypes.Length; ++groupIndex)
            {
                m_LowResolutionForAspectRatios[groupIndex] = GameViewSizes.DefaultLowResolutionSettingForSizeGroupType((GameViewSizeGroupType)sizeGroupTypes.GetValue(groupIndex));
            }
        }
 public void OnActiveBuildTargetChanged(BuildTarget oldTarget, BuildTarget newTarget)
 {
     GameViewSizes.RefreshGameViewSizeGroupType(oldTarget, newTarget);
 }
 internal static Rect GetConstrainedGameViewRenderRect(Rect renderRect, int sizeIndex, out bool fitsInsideRect)
 {
     return(GameViewSizes.GetConstrainedRect(renderRect, GameView.currentSizeGroupType, sizeIndex, out fitsInsideRect));
 }