Exemple #1
0
        public ScreenTypeConditions(string displayName,
                                    bool optimizedScreenInfo = false,
                                    bool orientation         = false,
                                    bool bigger     = false,
                                    bool smaller    = false,
                                    bool touch      = false,
                                    bool vr         = false,
                                    bool deviceType = false)
        {
            this.name = displayName;
            this.optimizedScreenInfo = new ScreenInfo(new Vector2(1920, 1080), 96);

            this.checkOrientation = new IsCertainScreenOrientation(IsCertainScreenOrientation.Orientation.Landscape)
            {
                IsActive = orientation
            };

            this.checkScreenSize = new IsScreenOfCertainSize()
            {
                IsActive = bigger
            };

            this.checkAspectRatio = new IsCertainAspectRatio()
            {
                IsActive = bigger
            };

            this.checkDeviceType = new IsScreenOfCertainDeviceInfo()
            {
                IsActive = deviceType
            };
        }
Exemple #2
0
        public static bool IsOptimizedResolution(int width, int height)
        {
            if ((int)OptimizedResolutionFallback.x == width && (int)OptimizedResolutionFallback.y == height)
            {
                return(true);
            }

            foreach (var config in Instance.optimizedScreens)
            {
                ScreenInfo si = config.OptimizedScreenInfo;
                if (si != null && (int)si.Resolution.x == width && (int)si.Resolution.y == height)
                {
                    return(true);
                }
            }

            return(false);
        }
        public float CalculateFactor(string screenConfig)
        {
            ScreenInfo info         = ResolutionMonitor.GetOpimizedScreenInfo(screenConfig);
            Vector2    optimizedRes = info.Resolution;
            float      optimizedDpi = info.Dpi;

            Vector2 actualRes = ResolutionMonitor.CurrentResolution;
            float   actualDpi = ResolutionMonitor.CurrentDpi;

            float factor = 0;

            float max   = (SizeModifiers.Count > 0) ? SizeModifiers.Max((o) => o.Impact) : 1;
            float scale = 0;

            foreach (var entry in SizeModifiers)
            {
                factor += entry.GetFactor(optimizedRes, actualRes, optimizedDpi, actualDpi);
                scale  += entry.Impact / max;
            }

            if (factor == 0) // nothing in list
            {
                factor = 1;
            }
            else
            {
                factor /= scale;
                factor  = 1 - factor;
            }

            if (ExponentialScale != 1)
            {
                factor = Mathf.Pow(factor, ExponentialScale);
            }

            return(factor);
        }