Beispiel #1
0
        /// <summary>
        /// Draw the part of fields in <see cref="AdaptationBase">.
        /// </summary>
        //public static void Draw(SerializedObject serializedObject)
        public override void OnInspectorGUI()
        {
            AdaptationBase adaptation    = (AdaptationBase)target;
            var            supportedProp = serializedObject.FindProperty("supportedOrientations");
            var            portraitProp  = serializedObject.FindProperty("portraitOrDefaultAdaptation");
            var            landscapeProp = serializedObject.FindProperty("landscapeAdaptation");

            (bool landscapeCompatible, bool portraitCompatible) = NotchSolutionUtilityEditor.GetOrientationCompatibility();

            if (portraitCompatible && landscapeCompatible)
            {
                EditorGUILayout.PropertyField(supportedProp);
                EditorGUILayout.Separator();
            }

            bool dual = supportedProp.enumValueIndex == (int)SupportedOrientations.Dual;

            if (dual)
            {
                EditorGUILayout.LabelField("Portrait Orientation", EditorStyles.boldLabel);
            }

            portraitProp.Next(enterChildren: true);

            if (portraitCompatible && landscapeCompatible)
            {
                EditorGUI.indentLevel++;
            }

            DrawGenButton(adaptation, forPortrait: true);

            for (int i = 0; i < 3; i++)
            {
                EditorGUILayout.PropertyField(portraitProp);
                portraitProp.Next(enterChildren: false);
            }

            if (portraitCompatible && landscapeCompatible)
            {
                EditorGUI.indentLevel--;
            }

            if (dual)
            {
                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("Landscape Orientation", EditorStyles.boldLabel);
                landscapeProp.Next(enterChildren: true);
                EditorGUI.indentLevel++;
                DrawGenButton(adaptation, forPortrait: false);
                for (int i = 0; i < 3; i++)
                {
                    EditorGUILayout.PropertyField(landscapeProp);
                    landscapeProp.Next(enterChildren: false);
                }
                EditorGUI.indentLevel--;
            }

            serializedObject.ApplyModifiedProperties();
        }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            var orientationType = serializedObject.FindProperty("orientationType");

            var portrait    = serializedObject.FindProperty("portraitOrDefaultPaddings");
            var landscape   = serializedObject.FindProperty("landscapePaddings");
            var influence   = serializedObject.FindProperty("influence");
            var flipPadding = serializedObject.FindProperty("flipPadding");

            (bool landscapeCompatible, bool portraitCompatible) = NotchSolutionUtilityEditor.GetOrientationCompatibility();

            if (portraitCompatible && landscapeCompatible)
            {
                EditorGUILayout.PropertyField(orientationType);
                EditorGUILayout.Separator();
            }

            bool dual = orientationType.enumValueIndex == (int)SupportedOrientations.Dual;

            if (dual)
            {
                EditorGUILayout.LabelField("Portrait Orientation", EditorStyles.boldLabel);
            }

            if (portraitCompatible && landscapeCompatible)
            {
                EditorGUI.indentLevel++;
            }

            for (int i = 0; i < 4; i++)
            {
                portrait.Next(enterChildren: true);
                EditorGUILayout.PropertyField(portrait);
            }

            if (portraitCompatible && landscapeCompatible)
            {
                EditorGUI.indentLevel--;
            }

            if (dual)
            {
                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("Landscape Orientation", EditorStyles.boldLabel);
                EditorGUI.indentLevel++;
                for (int i = 0; i < 4; i++)
                {
                    landscape.Next(enterChildren: true);
                    EditorGUILayout.PropertyField(landscape);
                }
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(influence);
            EditorGUILayout.PropertyField(flipPadding);

            serializedObject.ApplyModifiedProperties();
        }
Beispiel #3
0
        /// <summary>
        /// It is currently active only when Notch Simulator tab is present.
        /// </summary>
        void OnGUI()
        {
            win = this;

            //Sometimes even with flag I can see it in hierarchy until I move a mouse over it??
            EditorApplication.RepaintHierarchyWindow();

            EditorGUI.BeginChangeCheck();

            var settings = Settings.Instance;

            string switchConfigShortcut = ShortcutManager.instance.GetShortcutBinding(NotchSolutionShortcuts.switchConfigurationShortcut).ToString();

            if (string.IsNullOrEmpty(switchConfigShortcut))
            {
                switchConfigShortcut = "None";
            }
            string simulateShortcut = ShortcutManager.instance.GetShortcutBinding(NotchSolutionShortcuts.toggleSimulationShortcut).ToString();

            if (string.IsNullOrEmpty(simulateShortcut))
            {
                simulateShortcut = "None";
            }

            settings.EnableSimulation = EditorGUILayout.BeginToggleGroup($"Simulate ({simulateShortcut})", settings.EnableSimulation);

            int previousIndex = settings.ActiveConfiguration.DeviceIndex;
            int currentIndex  = Mathf.Clamp(settings.ActiveConfiguration.DeviceIndex, 0, SimulationDatabase.KeyList.Length - 1);

            int selectedIndex = EditorGUILayout.Popup(currentIndex, SimulationDatabase.KeyList);

            if (GUILayout.Button($"{settings.ActiveConfiguration.ConfigurationName} ({switchConfigShortcut})", EditorStyles.helpBox))
            {
                NotchSolutionShortcuts.SwitchConfiguration();
            }
            EditorGUILayout.EndToggleGroup();

            settings.ActiveConfiguration.DeviceIndex = selectedIndex;

            var simulationDevice = SimulationDatabase.Get(SimulationDatabase.KeyList[selectedIndex]);

            //Draw warning about wrong aspect ratio
            if (settings.EnableSimulation && simulationDevice != null)
            {
                ScreenOrientation gameViewOrientation = NotchSimulatorUtility.GetGameViewOrientation();

                Vector2 gameViewSize = NotchSimulatorUtility.GetMainGameViewSize();
                if (gameViewOrientation == ScreenOrientation.Landscape)
                {
                    var flip = gameViewSize.x;
                    gameViewSize.x = gameViewSize.y;
                    gameViewSize.y = flip;
                }

                var screen         = simulationDevice.Screens.FirstOrDefault();
                var simAspect      = NotchSolutionUtilityEditor.ScreenRatio(new Vector2(screen.width, screen.height));
                var gameViewAspect = NotchSolutionUtilityEditor.ScreenRatio(gameViewSize);
                var aspectDiff     = Math.Abs((simAspect.x / simAspect.y) - (gameViewAspect.x / gameViewAspect.y));
                if (aspectDiff > 0.01f)
                {
                    EditorGUILayout.HelpBox($"The selected simulation device has an aspect ratio of {simAspect.y}:{simAspect.x} ({screen.height}x{screen.width}) but your game view is currently in aspect {gameViewAspect.y}:{gameViewAspect.x} ({gameViewSize.y}x{gameViewSize.x}). The overlay mockup won't be displayed correctly.", MessageType.Warning);
                }
            }

            bool changed = EditorGUI.EndChangeCheck();

            if (changed)
            {
                UpdateAllMockups();
                settings.Save();
            }

            UpdateSimulatorTargets();
        }