Esempio n. 1
0
    public void UpdateMenuPosition()
    {
        UIScale uiScale  = GameObject.Find("UI Camera").GetComponent <UIScale>();
        Vector3 uiCenter = uiScale.gameObject.transform.position;

        transform.Find("Menu Container").transform.position = uiCenter + new Vector3((Left - .5f) * uiScale.xScale, (Top - .5f) * -uiScale.yScale, 10 - Z);
    }
Esempio n. 2
0
 public EditorConfig()
 {
     RecycleBinMax = 30;
     Scale         = UIScale.Normal;
     Supported     = new List <ItemTypeSupport>();
     SavePath      = "Assets/Localiza/Saves/";
     this.TryLoadConfigFromFile();
 }
        private IEnumerator WaitForAnimate(float seconds, UIScale rewardUiScale, bool isPicked)
        {
            yield return(new WaitForSeconds(seconds));

            if (isPicked)
            {
                SoundManager.PlayStatic("UI Coin");
            }
            rewardUiScale.ScaleIn();
        }
Esempio n. 4
0
    public override void OnInspectorGUI()
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("UIScale");
        EditorGUILayout.ObjectField(target, typeof(Component), true);

        EditorGUILayout.EndHorizontal();

        for (int i = 0; i < targets.Length; ++i)
        {
            UIScale scalescript = targets[i] as UIScale;
            Vector2 value       = scalescript.uiscale;

            GUILayout.BeginHorizontal();
            GUILayout.Label("x scale", GUILayout.Width(60));
            float x = GUILayout.HorizontalSlider(value.x, -1000, 1000);

            x = EditorGUILayout.FloatField(x, GUILayout.Width(50));

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("y scale", GUILayout.Width(60));
            float y = GUILayout.HorizontalSlider(value.y, -1000, 1000);

            y = EditorGUILayout.FloatField(y, GUILayout.Width(50));

            GUILayout.EndHorizontal();

            value = new Vector2(x, y);
            scalescript.uiscale = value;
            if (GUILayout.Button("confirm"))
            {
                scalescript.SetScale(value);
            }
        }
    }
Esempio n. 5
0
        private async Task <UIScale> GetUIScaleOutAsync(int width, int hight)
        {
            UIScale ret = new UIScale();
            double  screengridActualWidth = await parent.GetSwapChainPanelActualWidthAsync();

            double screengridActualHeight = await parent.GetSwapChainPanelActualHeightAsync();

            Windows.Foundation.Point TopPoint = new Windows.Foundation.Point(0, 0);



            double LiveActualWidth  = 0;
            double LiveActualHeight = 0;
            double PicWidth         = width;
            double PicHeight        = hight;

            if ((screengridActualWidth / screengridActualHeight) > (PicWidth / PicHeight))
            {
                LiveActualHeight = screengridActualHeight;
                LiveActualWidth  = screengridActualHeight * PicWidth / PicHeight;
                TopPoint.X       = (screengridActualWidth - LiveActualWidth) / 2.0;
                TopPoint.Y       = 0;
            }
            else
            {
                LiveActualWidth  = screengridActualWidth;
                LiveActualHeight = screengridActualWidth * PicHeight / PicWidth;
                TopPoint.Y       = (screengridActualHeight - LiveActualHeight) / 2.0;
                TopPoint.X       = 0;
            }

            ret.topPoint = TopPoint;
            ret.scaleW   = LiveActualWidth;
            ret.scaleH   = LiveActualHeight;
            return(ret);
        }
        private void CalculateScale()
        {
            double yScale = ActualHeight / 900f;
            double xScale = ActualWidth / 1200f;
            double value  = Math.Min(xScale, yScale);

            if (value > 1)
            {
                value = 1;
            }

            ScaleValue = Math.Round((double)OnCoerceScaleValue(dbMainWindow, value), 2);

            if (ScaleValue < 0.82 && scale != UIScale.Small)
            {
                scale = UIScale.Small;

                var dictionary = Application.Current.Resources.MergedDictionaries
                                 .Where(d => d.Source.OriginalString == "Styles/ThemeFonts.Medium.xaml" || d.Source.OriginalString == "Styles/ThemeFonts.Regular.xaml")
                                 .FirstOrDefault();

                if (dictionary != null)
                {
                    Application.Current.Resources.MergedDictionaries.Remove(dictionary);

                    Application.Current.Resources.MergedDictionaries.Add(
                        new ResourceDictionary
                    {
                        Source = new Uri("Styles/ThemeFonts.Small.xaml", UriKind.Relative)
                    }
                        );
                }
            }
            else if (ScaleValue >= 0.82 && ScaleValue < 0.9 && scale != UIScale.Medium)
            {
                scale = UIScale.Medium;

                var dictionary = Application.Current.Resources.MergedDictionaries
                                 .Where(d => d.Source.OriginalString == "Styles/ThemeFonts.Small.xaml" || d.Source.OriginalString == "Styles/ThemeFonts.Regular.xaml")
                                 .FirstOrDefault();

                if (dictionary != null)
                {
                    Application.Current.Resources.MergedDictionaries.Remove(dictionary);

                    Application.Current.Resources.MergedDictionaries.Add(
                        new ResourceDictionary
                    {
                        Source = new Uri("Styles/ThemeFonts.Medium.xaml", UriKind.Relative)
                    }
                        );
                }
            }

            else if (ScaleValue >= 0.9 && scale != UIScale.Regular)
            {
                scale = UIScale.Regular;

                var dictionary = Application.Current.Resources.MergedDictionaries
                                 .Where(d => d.Source.OriginalString == "Styles/ThemeFonts.Small.xaml" || d.Source.OriginalString == "Styles/ThemeFonts.Medium.xaml")
                                 .FirstOrDefault();

                if (dictionary != null)
                {
                    Application.Current.Resources.MergedDictionaries.Remove(dictionary);

                    Application.Current.Resources.MergedDictionaries.Add(
                        new ResourceDictionary
                    {
                        Source = new Uri("Styles/ThemeFonts.Regular.xaml", UriKind.Relative)
                    }
                        );
                }
            }
        }
Esempio n. 7
0
 public static Rect Anchor(Rect bounds, Vector2 size, UIScale.Function scaleFn, Vector2 anchor, Vector2 itemAnchor)
 {
     // Apply any scaling required
     if (scaleFn != null) size = scaleFn(new Vector2(bounds.width, bounds.height), size);
     // Anchor scale to the bounding rectangle
     var rect = new Rect(bounds.x, bounds.y, size.x, size.y);
     rect.x += (bounds.width * anchor.x - rect.width * itemAnchor.x);
     rect.y += (bounds.height * anchor.y - rect.height * itemAnchor.y);
     return rect;
 }
Esempio n. 8
0
 public static Rect Anchor(Rect bounds, Vector2 size, UIScale.Function scaleFn, Vector2 anchor)
 {
     return Anchor(bounds, size, scaleFn, anchor, anchor);
 }