internal static void GameViewSizePopup(Rect buttonRect, GameViewSizeGroupType groupType, int selectedIndex, System.Action<int, object> itemClickedCallback, GUIStyle guiStyle)
 {
   GameViewSizeGroup group = ScriptableSingleton<GameViewSizes>.instance.GetGroup(groupType);
   string t = selectedIndex < 0 || selectedIndex >= group.GetTotalCount() ? string.Empty : group.GetGameViewSize(selectedIndex).displayText;
   if (!EditorGUI.ButtonMouseDown(buttonRect, GUIContent.Temp(t), FocusType.Passive, guiStyle))
     return;
   FlexibleMenu flexibleMenu = new FlexibleMenu((IFlexibleMenuItemProvider) new GameViewSizesMenuItemProvider(groupType), selectedIndex, (FlexibleMenuModifyItemUI) new GameViewSizesMenuModifyItemUI(), itemClickedCallback);
   PopupWindow.Show(buttonRect, (PopupWindowContent) flexibleMenu);
 }
 public static void AddCustomSize(GameViewSizeType viewSizeType, GameViewSizeGroupType sizeGroupType, int width, int height, string text)
 {
     var group = GetGroup(sizeGroupType);
     var addCustomSize = _getGroup.ReturnType.GetMethod("AddCustomSize");
     var gameViewSizeType = typeof (Editor).Assembly.GetType("UnityEditor.GameViewSize");
     var ctor = gameViewSizeType.GetConstructor(new Type[] {typeof (int), typeof (int), typeof (int), typeof (string)});
     var newSize = ctor.Invoke(new object[] {(int) viewSizeType, width, height, text});
     addCustomSize.Invoke(group, new object[] {newSize});
 }
 public static int FindSizeIndex(GameViewSizeGroupType sizeGroupType, string text)
 {
     var group = GetGroup(sizeGroupType);
     var getDisplayTexts = group.GetType().GetMethod("GetDisplayTexts");
     var displayTexts = getDisplayTexts.Invoke(group, null) as string[];
     for (var i = 0; i < displayTexts.Length; i++)
     {
         var display = displayTexts[i];
         // the text we get is "Name (W:H)" if the size has a name, or just "W:H" e.g. 16:9
         // so if we're querying a custom size text we substring to only get the name
         // You could see the outputs by just logging
         // Debug.Log(display);
         var pren = display.IndexOf('(');
         // -1 to remove the space that's before the prens. This is very implementation-depdenent
         if (pren != -1) display = display.Substring(0, pren - 1);
         if (display == text)
             return i;
     }
     return -1;
 }
Beispiel #4
0
 static object GetGroup(GameViewSizeGroupType type)
 {
     return(getGroupMethodInfo.Invoke(gameViewSizesInstance, new object[] { (int)type }));
 }
Beispiel #5
0
 public static bool Contains(GameViewSizeGroupType groupType, GameViewSize gameViewSize)
 {
     _gameViewSize = gameViewSize;
     return(Contains(GetGroup(groupType, instance)));
 }
 public bool IsRemoteScreenSize(GameViewSizeGroupType gameViewSizeGroupType, int index) =>
 (this.GetGroup(gameViewSizeGroupType).IndexOf(this.m_Remote) == index);
        public static Vector2 GetRenderTargetSize(Rect startRect, GameViewSizeGroupType groupType, int gameViewSizeIndex, out bool clamped)
        {
            Vector2      size;
            float        num2;
            GameViewSize gameViewSize = ScriptableSingleton <GameViewSizes> .instance.GetGroup(groupType).GetGameViewSize(gameViewSizeIndex);

            RefreshDerivedGameViewSize(groupType, gameViewSizeIndex, gameViewSize);
            clamped = false;
            if (gameViewSize.isFreeAspectRatio)
            {
                size = startRect.size;
            }
            else
            {
                GameViewSizeType sizeType = gameViewSize.sizeType;
                if (sizeType != GameViewSizeType.AspectRatio)
                {
                    if (sizeType != GameViewSizeType.FixedResolution)
                    {
                        throw new ArgumentException("Unrecognized size type");
                    }
                }
                else
                {
                    if ((startRect.height == 0f) || (gameViewSize.aspectRatio == 0f))
                    {
                        size = Vector2.zero;
                    }
                    else
                    {
                        float num = startRect.width / startRect.height;
                        if (num < gameViewSize.aspectRatio)
                        {
                            size = new Vector2(startRect.width, startRect.width / gameViewSize.aspectRatio);
                        }
                        else
                        {
                            size = new Vector2(startRect.height * gameViewSize.aspectRatio, startRect.height);
                        }
                    }
                    goto Label_010B;
                }
                size = new Vector2((float)gameViewSize.width, (float)gameViewSize.height);
            }
Label_010B:
            num2 = (((SystemInfo.graphicsMemorySize * 0.2f) / 12f) * 1024f) * 1024f;
            float num3 = size.x * size.y;

            if (num3 > num2)
            {
                size    = (Vector2)(size * (num2 / num3));
                clamped = true;
            }
            float b    = 8192f;
            float num5 = Mathf.Min((float)SystemInfo.maxRenderTextureSize, b);

            if ((size.x > num5) || (size.y > num5))
            {
                if (size.x > size.y)
                {
                    size = (Vector2)(size * (num5 / size.x));
                }
                else
                {
                    size = (Vector2)(size * (num5 / size.y));
                }
                clamped = true;
            }
            return(size);
        }
        public static Vector2 GetRenderTargetSize(Rect startRect, GameViewSizeGroupType groupType, int gameViewSizeIndex, out bool clamped)
        {
            GameViewSize gameViewSize = GameViewSizes.instance.GetGroup(groupType).GetGameViewSize(gameViewSizeIndex);

            RefreshDerivedGameViewSize(groupType, gameViewSizeIndex, gameViewSize);
            Vector2 targetSize;

            clamped = false;

            // Free aspect takes up all available pixels by default
            if (gameViewSize.isFreeAspectRatio)
            {
                targetSize = startRect.size;
            }
            else
            {
                switch (gameViewSize.sizeType)
                {
                // Aspect ratio is enforced, but fills up as much game view as it can
                case GameViewSizeType.AspectRatio:
                {
                    if (startRect.height == 0f || gameViewSize.aspectRatio == 0f)
                    {
                        targetSize = Vector2.zero;
                        break;
                    }
                    var startRatio = startRect.width / startRect.height;
                    if (startRatio < gameViewSize.aspectRatio)
                    {
                        targetSize = new Vector2(startRect.width, Mathf.Round(startRect.width / gameViewSize.aspectRatio));
                    }
                    else
                    {
                        targetSize = new Vector2(Mathf.Round(startRect.height * gameViewSize.aspectRatio), startRect.height);
                    }
                }
                break;

                // Fixed resolution is fixed, but scaled down to fit, or scaled up to largest possible integer
                case GameViewSizeType.FixedResolution:
                {
                    targetSize = new Vector2(gameViewSize.width, gameViewSize.height);
                }
                break;

                default:
                    throw new ArgumentException("Unrecognized size type");
                }
            }

            // Prevent ludicrous render target sizes. Heuristics based on:
            // - GPU supported max. texture size
            // - "should be enough for anyone" (i.e. more than 8K resolution)
            // - Available VRAM
            //
            // The reason is that while GPUs support large textures (e.g. 16k x 16k), trying to
            // actually create one will just make you run out of memory. VRAM size estimate that we
            // have is also only very approximate.
            // Let's assume we can use 20% of VRAM for game view render target;
            // and that we need 12 bytes/pixel (4 for color, double buffered, 4 for depth).
            // Figure out what's the max texture area that fits there.
            var maxVRAMArea = SystemInfo.graphicsMemorySize * 0.20f / 12f * 1024f * 1024f;

            var targetArea = targetSize.x * targetSize.y;

            if (targetArea > maxVRAMArea)
            {
                var aspect = targetSize.y / targetSize.x;
                targetSize.x = Mathf.Sqrt(maxVRAMArea * aspect);
                targetSize.y = aspect * targetSize.x;
                clamped      = true;
            }

            // Over 8K resolution (7680x4320) should be enough for anyone (tm)
            var maxResolutionSize = 8192f;
            var maxSize           = Mathf.Min(SystemInfo.maxRenderTextureSize, maxResolutionSize);

            if (targetSize.x > maxSize || targetSize.y > maxSize)
            {
                if (targetSize.x > targetSize.y)
                {
                    targetSize *= maxSize / targetSize.x;
                }
                else
                {
                    targetSize *= maxSize / targetSize.y;
                }
                clamped = true;
            }

            return(targetSize);
        }
 public bool IsRemoteScreenSize(GameViewSizeGroupType gameViewSizeGroupType, int index)
 {
     return(GetGroup(gameViewSizeGroupType).IndexOf(m_Remote) == index);
 }
		public GameViewSizesMenuItemProvider(GameViewSizeGroupType gameViewSizeGroupType)
		{
			this.m_GameViewSizeGroup = ScriptableSingleton<GameViewSizes>.instance.GetGroup(gameViewSizeGroupType);
		}
 static object GetGroup(GameViewSizeGroupType groupType, object instance_gameViewSizes)
 {
     Type[]   returnTypes = new Type[] { groupType.GetType() };
     object[] parameters  = new object[] { groupType };
     return(instance_gameViewSizes.GetType().GetMethod("GetGroup", bindingFlags, null, returnTypes, null).Invoke(instance_gameViewSizes, parameters));
 }
 public static int FindSizeIndex(GameViewSizeGroupType sizeGroupType, int width, int height)
 {
     var group = GetGroup(sizeGroupType);
     var groupType = group.GetType();
     var getBuiltinCount = groupType.GetMethod("GetBuiltinCount");
     var getCustomCount = groupType.GetMethod("GetCustomCount");
     var sizesCount = (int)getBuiltinCount.Invoke(group, null) + (int)getCustomCount.Invoke(group, null);
     var getGameViewSize = groupType.GetMethod("GetGameViewSize");
     var gvsType = getGameViewSize.ReturnType;
     var widthProp = gvsType.GetProperty("width");
     var heightProp = gvsType.GetProperty("height");
     var indexValue = new object[1];
     for (var i = 0; i < sizesCount; i++)
     {
         indexValue[0] = i;
         var size = getGameViewSize.Invoke(group, indexValue);
         var sizeWidth = (int)widthProp.GetValue(size, null);
         var sizeHeight = (int)heightProp.GetValue(size, null);
         if (sizeWidth == width && sizeHeight == height)
             return i;
     }
     return -1;
 }
 public static void RemoveCustomSize(GameViewSizeGroupType sizeGroupType, int index)
 {
     var group = GetGroup(sizeGroupType);
     var addCustomSize = _getGroup.ReturnType.GetMethod("RemoveCustomSize");
     addCustomSize.Invoke(group, new object[] { index });
 }
 public static bool IsSizeExist(GameViewSizeGroupType sizeGroupType, int width, int height)
 {
     return FindSizeIndex(sizeGroupType, width, height) != -1;
 }
 public static bool SizeExists(GameViewSizeGroupType sizeGroupType, string text)
 {
     return(FindSize(sizeGroupType, text) != -1);
 }
Beispiel #16
0
 public static bool RemoveCustomSize(GameViewSizeGroupType groupType, GameViewSize gameViewSize)
 {
     _gameViewSize = gameViewSize;
     return(Remove(GetGroup(groupType, instance)));
 }
Beispiel #17
0
 internal static void GameViewSizePopup(GameViewSizeGroupType groupType, int selectedIndex, IGameViewSizeMenuUser gameView, GUIStyle style, params GUILayoutOption[] options)
 {
     s_LastRect = GetControlRect(false, EditorGUI.kSingleLineHeight, style, options);
     EditorGUI.GameViewSizePopup(s_LastRect, groupType, selectedIndex, gameView, style);
 }
 public static bool IsSizeExist(GameViewSizeGroupType sizeGroupType, string text)
 {
     return FindSizeIndex(sizeGroupType, text) != -1;
 }
Beispiel #19
0
 public bool IsDefaultWebPlayerScreenSize(GameViewSizeGroupType gameViewSizeGroupType, int index)
 {
     return(gameViewSizeGroupType == GameViewSizeGroupType.WebPlayer && this.GetDefaultWebPlayerIndex() == index);
 }
        public static Rect GetConstrainedRect(Rect startRect, GameViewSizeGroupType groupType, int gameViewSizeIndex, out bool fitsInsideRect)
        {
            fitsInsideRect = true;
            Rect         constrainedRect = startRect;
            GameViewSize gameViewSize    = GameViewSizes.instance.GetGroup(groupType).GetGameViewSize(gameViewSizeIndex);

            RefreshDerivedGameViewSize(groupType, gameViewSizeIndex, gameViewSize);

            if (gameViewSize.isFreeAspectRatio)
            {
                return(startRect);
            }

            float newRatio = 0;
            bool  useRatio;

            switch (gameViewSize.sizeType)
            {
            case GameViewSizeType.AspectRatio:
            {
                newRatio = gameViewSize.aspectRatio;
                useRatio = true;
            }
            break;

            case GameViewSizeType.FixedResolution:
            {
                if (gameViewSize.height > startRect.height || gameViewSize.width > startRect.width)
                {
                    newRatio       = gameViewSize.aspectRatio;
                    useRatio       = true;
                    fitsInsideRect = false;
                }
                else
                {
                    constrainedRect.height = gameViewSize.height;
                    constrainedRect.width  = gameViewSize.width;
                    useRatio = false;
                }
            }
            break;

            default:
                throw new ArgumentException("Unrecognized size type");
            }

            if (useRatio)
            {
                constrainedRect.height = (constrainedRect.width / newRatio) > startRect.height
                    ? (startRect.height)
                    : (constrainedRect.width / newRatio);
                constrainedRect.width = (constrainedRect.height * newRatio);
            }

            // clamp
            constrainedRect.height = Mathf.Clamp(constrainedRect.height, 0f, startRect.height);
            constrainedRect.width  = Mathf.Clamp(constrainedRect.width, 0f, startRect.width);

            // center
            constrainedRect.y = (startRect.height * 0.5f - constrainedRect.height * 0.5f) + startRect.y;
            constrainedRect.x = (startRect.width * 0.5f - constrainedRect.width * 0.5f) + startRect.x;

            // Round to whole pixels - actually is important for correct rendering of game view!
            constrainedRect.width  = Mathf.Floor(constrainedRect.width + 0.5f);
            constrainedRect.height = Mathf.Floor(constrainedRect.height + 0.5f);
            constrainedRect.x      = Mathf.Floor(constrainedRect.x + 0.5f);
            constrainedRect.y      = Mathf.Floor(constrainedRect.y + 0.5f);

            return(constrainedRect);
        }
Beispiel #21
0
        private static void RefreshGameViewSizeGroupType()
        {
            BuildTargetGroup buildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);

            GameViewSizes.s_GameViewSizeGroupType = GameViewSizes.BuildTargetGroupToGameViewSizeGroup(buildTargetGroup);
        }
        static void RefreshGameViewSizeGroupType(BuildTarget oldTarget, BuildTarget newTarget)
        {
            BuildTargetGroup buildTargetGroup = BuildPipeline.GetBuildTargetGroup(newTarget);

            s_GameViewSizeGroupType = BuildTargetGroupToGameViewSizeGroup(buildTargetGroup);
        }
Beispiel #23
0
        public static Vector2 GetRenderTargetSize(Rect startRect, GameViewSizeGroupType groupType, int gameViewSizeIndex, out bool clamped)
        {
            GameViewSize gameViewSize = ScriptableSingleton <GameViewSizes> .instance.GetGroup(groupType).GetGameViewSize(gameViewSizeIndex);

            GameViewSizes.RefreshDerivedGameViewSize(groupType, gameViewSizeIndex, gameViewSize);
            clamped = false;
            Vector2 vector;

            if (gameViewSize.isFreeAspectRatio)
            {
                vector = startRect.size;
            }
            else
            {
                GameViewSizeType sizeType = gameViewSize.sizeType;
                if (sizeType != GameViewSizeType.AspectRatio)
                {
                    if (sizeType != GameViewSizeType.FixedResolution)
                    {
                        throw new ArgumentException("Unrecognized size type");
                    }
                    vector = new Vector2((float)gameViewSize.width, (float)gameViewSize.height);
                }
                else if (startRect.height == 0f || gameViewSize.aspectRatio == 0f)
                {
                    vector = Vector2.zero;
                }
                else
                {
                    float num = startRect.width / startRect.height;
                    if (num < gameViewSize.aspectRatio)
                    {
                        vector = new Vector2(startRect.width, startRect.width / gameViewSize.aspectRatio);
                    }
                    else
                    {
                        vector = new Vector2(startRect.height * gameViewSize.aspectRatio, startRect.height);
                    }
                }
            }
            float num2 = (float)SystemInfo.graphicsMemorySize * 0.2f / 12f * 1024f * 1024f;
            float num3 = vector.x * vector.y;

            if (num3 > num2)
            {
                float num4 = vector.x / vector.y;
                vector.x = Mathf.Sqrt(num2 * num4);
                vector.y = num4 * vector.x;
                clamped  = true;
            }
            float b    = 8192f;
            float num5 = Mathf.Min((float)SystemInfo.maxRenderTextureSize, b);

            if (vector.x > num5 || vector.y > num5)
            {
                if (vector.x > vector.y)
                {
                    vector *= num5 / vector.x;
                }
                else
                {
                    vector *= num5 / vector.y;
                }
                clamped = true;
            }
            return(vector);
        }
 public bool IsDefaultStandaloneScreenSize(GameViewSizeGroupType gameViewSizeGroupType, int index) =>
 ((gameViewSizeGroupType == GameViewSizeGroupType.Standalone) && (this.GetDefaultStandaloneIndex() == index));
 public GameViewSizesMenuItemProvider(GameViewSizeGroupType gameViewSizeGroupType)
 {
     m_GameViewSizeGroup = GameViewSizes.instance.GetGroup(gameViewSizeGroupType);
 }
Beispiel #26
0
 public static bool IsSizeExist(GameViewSizeGroupType sizeGroupType, string text)
 {
     return(FindSizeIndex(sizeGroupType, text) != -1);
 }
 internal static void GameViewSizePopup(GameViewSizeGroupType groupType, int selectedIndex, IGameViewSizeMenuUser gameView, GUIStyle style, params GUILayoutOption[] options)
 {
     s_LastRect = GetControlRect(false, 16f, style, options);
     EditorGUI.GameViewSizePopup(s_LastRect, groupType, selectedIndex, gameView, style);
 }
 public static bool SizeExists(GameViewSizeGroupType sizeGroupType, int width, int height)
 {
     return(FindSize(sizeGroupType, width, height) != -1);
 }
Beispiel #29
0
        void OnGUI()
        {
            var removeTargets = new List <GameViewSizeHelper.GameViewSize>();
            var addTargets    = new List <GameViewSizeHelper.GameViewSize>();

            selectedTab = (GameViewSizeGroupType)GUILayout.Toolbar((int)selectedTab, tabNames);
            var presets     = GameViewSizePreset.GetPresets(selectedTab);
            var customSizes = gameViewSizeMap[selectedTab];

            using (var scroll = new EditorGUILayout.ScrollViewScope(scrollPosition))
            {
                scrollPosition = scroll.scrollPosition;
                EditorGUILayout.Space();
                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.LabelField("■■■PRESET■■■■■■■■■■■■■■■■■■■■■■■■", EditorStyles.boldLabel);
                    if (GUILayout.Button("Add all preset", GUILayout.Width(140)))
                    {
                        addTargets.AddRange(presets);
                    }
                    if (GUILayout.Button("Remove all preset", GUILayout.Width(140)))
                    {
                        removeTargets.AddRange(presets);
                    }
                }
                EditorGUILayout.Space();
                if (presets.Length == 0)
                {
                    EditorGUILayout.LabelField("Nothing preset GameViewSize. Please request https://github.com/Syy12345-Unity/GameViewSizeController");
                }
                foreach (var gameViewSize in presets)
                {
                    bool contains = customSizes.Any(data => GameViewSizeEqual(data, gameViewSize));
                    using (new EditorGUILayout.VerticalScope("ShurikenModuleTitle"))
                    {
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            if (contains)
                            {
                                if (GUILayout.Button("", EditorStyles.label, GUILayout.Width(55)))
                                {
                                }
                            }
                            else
                            {
                                if (GUILayout.Button("Add", EditorStyles.miniButton, GUILayout.Width(55)))
                                {
                                    addTargets.Add(gameViewSize);
                                }
                            }
                            EditorGUILayout.LabelField(gameViewSize.baseText, GUILayout.Width(300));
                            EditorGUILayout.LabelField(string.Format("{0} × {1}", gameViewSize.width, gameViewSize.height));
                        }
                    }
                }

                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■", EditorStyles.boldLabel);
                EditorGUILayout.LabelField("■■■REGISTERED■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■", EditorStyles.boldLabel);
                EditorGUILayout.LabelField("■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■", EditorStyles.boldLabel);
                EditorGUILayout.LabelField("Quick change GameViewSize by click title", EditorStyles.boldLabel);
                EditorGUILayout.Space();
                if (customSizes.Length == 0)
                {
                    EditorGUILayout.LabelField("Nothing registered custom GameViewSize");
                }
                foreach (var gameViewSize in customSizes)
                {
                    using (new EditorGUILayout.VerticalScope("ShurikenModuleTitle"))
                    {
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            if (GUILayout.Button("Remove", EditorStyles.miniButton, GUILayout.Width(55)))
                            {
                                removeTargets.Add(gameViewSize);
                            }
                            if (GUILayout.Button(gameViewSize.baseText, EditorStyles.label, GUILayout.Width(300)))
                            {
                                GameViewSizeHelper.ChangeGameViewSize(selectedTab, gameViewSize);
                            }
                            // EditorGUILayout.LabelField(gameViewSize.baseText);
                            EditorGUILayout.LabelField(string.Format("{0} × {1}", gameViewSize.width, gameViewSize.height));
                        }
                    }
                }

                if (removeTargets.Count != 0)
                {
                    var list = customSizes.ToList();
                    foreach (var target in removeTargets)
                    {
                        GameViewSizeHelper.RemoveCustomSize(selectedTab, target);
                        var findObj = list.FirstOrDefault(data => GameViewSizeEqual(data, target));
                        if (findObj != null)
                        {
                            list.Remove(findObj);
                        }
                    }
                    gameViewSizeMap[selectedTab] = list.ToArray();
                }

                if (addTargets.Count != 0)
                {
                    var list = customSizes.ToList();
                    foreach (var target in addTargets)
                    {
                        var findObj = list.FirstOrDefault(data => GameViewSizeEqual(data, target));
                        if (findObj == null)
                        {
                            GameViewSizeHelper.AddCustomSize(selectedTab, target);
                            list.Add(target);
                        }
                    }
                    gameViewSizeMap[selectedTab] = list.ToArray();
                }
                EditorGUILayout.Space();
            }
            EditorGUILayout.Space();
        }
 static object GetGroup(GameViewSizeGroupType type)
 {
     return(s_GetGroup.Invoke(s_GameViewSizesInstance, new object[] { (int)type }));
 }
Beispiel #31
0
        public static List <ViewSize> GetViewSizes(GameViewSizeGroupType sizeGroupType)
        {
            var viewSizes = new List <ViewSize>();

            var group           = GetGroup(sizeGroupType);
            var groupType       = group.GetType();
            var getBuiltinCount = groupType.GetMethod("GetBuiltinCount");
            var getCustomCount  = groupType.GetMethod("GetCustomCount");
            int sizesCount      = (int)getBuiltinCount.Invoke(group, null) + (int)getCustomCount.Invoke(group, null);
            var getGameViewSize = groupType.GetMethod("GetGameViewSize");
            var gvsType         = getGameViewSize.ReturnType;
            var widthProp       = gvsType.GetProperty("width");
            var heightProp      = gvsType.GetProperty("height");
            var indexValue      = new object[1];

            var getDisplayTexts = group.GetType().GetMethod("GetDisplayTexts");
            var displayTexts    = getDisplayTexts.Invoke(group, null) as string[];

            var iterations = (sizesCount > displayTexts.Length) ? sizesCount : displayTexts.Length;

            for (var i = 0; i < iterations; i++)
            {
                indexValue[0] = i;

                var size       = getGameViewSize.Invoke(group, indexValue);
                int sizeWidth  = (int)widthProp.GetValue(size, null);
                int sizeHeight = (int)heightProp.GetValue(size, null);

                if (AndroidViewType == AndroidViewType.Landscape && sizeWidth > sizeHeight && sizeWidth > 280)
                {
                    viewSizes.Add(new ViewSize
                    {
                        Name   = displayTexts[i],
                        Width  = sizeWidth,
                        Height = sizeHeight
                    });
                }
                else if (AndroidViewType == AndroidViewType.Portrait && sizeWidth < sizeHeight)
                {
                    viewSizes.Add(new ViewSize
                    {
                        Name   = displayTexts[i],
                        Width  = sizeWidth,
                        Height = sizeHeight
                    });
                }
                else if (AndroidViewType == AndroidViewType.All)
                {
                    viewSizes.Add(new ViewSize
                    {
                        Name   = displayTexts[i],
                        Width  = sizeWidth,
                        Height = sizeHeight
                    });
                }
            }

            viewSizes = viewSizes.OrderBy(x => x.Width).ToList();

            return(viewSizes);
        }
Beispiel #32
0
 public static void AddCustomSize(GameViewSizeGroupType groupType, GameViewSizeType type, int width, int height, string baseText)
 {
     AddCustomSize(groupType, new GameViewSize {
         type = type, width = width, height = height, baseText = baseText
     });
 }
 public GameViewSizesMenuItemProvider(GameViewSizeGroupType gameViewSizeGroupType)
 {
     this.m_GameViewSizeGroup = ScriptableSingleton <GameViewSizes> .instance.GetGroup(gameViewSizeGroupType);
 }
		internal static void GameViewSizePopup(GameViewSizeGroupType groupType, int selectedIndex, Action<int, object> itemClickedCallback, GUIStyle style, params GUILayoutOption[] options)
		{
			EditorGUILayout.s_LastRect = EditorGUILayout.GetControlRect(false, 16f, style, options);
			EditorGUI.GameViewSizePopup(EditorGUILayout.s_LastRect, groupType, selectedIndex, itemClickedCallback, style);
		}
Beispiel #35
0
		internal static void GameViewSizePopup(Rect buttonRect, GameViewSizeGroupType groupType, int selectedIndex, Action<int, object> itemClickedCallback, GUIStyle guiStyle)
		{
			GameViewSizeGroup group = ScriptableSingleton<GameViewSizes>.instance.GetGroup(groupType);
			string t;
			if (selectedIndex >= 0 && selectedIndex < group.GetTotalCount())
			{
				t = group.GetGameViewSize(selectedIndex).displayText;
			}
			else
			{
				t = string.Empty;
			}
			if (EditorGUI.ButtonMouseDown(buttonRect, GUIContent.Temp(t), FocusType.Passive, guiStyle))
			{
				IFlexibleMenuItemProvider itemProvider = new GameViewSizesMenuItemProvider(groupType);
				FlexibleMenu windowContent = new FlexibleMenu(itemProvider, selectedIndex, new GameViewSizesMenuModifyItemUI(), itemClickedCallback);
				PopupWindow.Show(buttonRect, windowContent);
			}
		}
 public bool IsDefaultStandaloneScreenSize(GameViewSizeGroupType gameViewSizeGroupType, int index)
 {
     return(gameViewSizeGroupType == GameViewSizeGroupType.Standalone && GetDefaultStandaloneIndex() == index);
 }
 public static object GetGroup(GameViewSizeGroupType type)
 {
     return _getGroup.Invoke(_gameViewSizesInstance, new object[] {(int) type});
 }