protected void RestoreDevicePreview()
        {
            if (m_ConfigAsset.m_BackupPreviewToDisk == false)
            {
                return;
            }

            // Debug.Log("Restore");

            m_Loading     = true;
            m_NeedsBackup = false;
            m_ConfigAsset = ResolutionSettingsWindow.GetConfig();
            // Load screenshots from temporary folder
            foreach (ScreenshotResolution resolution in m_ConfigAsset.m_Config.GetActiveResolutions())
            {
                if (resolution.m_Texture != null)
                {
                    continue;
                }

                string filename = Application.persistentDataPath + "/" + m_TempFolder + "/" + resolution.m_ResolutionName + ".png";

                //				Debug.Log ("Loading tmp image " + filename);

                if (!System.IO.File.Exists(filename))
                {
                    continue;
                }

                resolution.m_Texture = TextureExporter.LoadFromFile(filename);
            }
            m_Loading = false;
        }
        public override void OnInspectorGUI()
        {
            EditorGUILayout.HelpBox("This asset contains the settings used by the Universal Device Preview.", MessageType.Info);

            if (GUILayout.Button("Open Settings"))
            {
                ResolutionSettingsWindow.Init();
            }
        }
 public static void RepaintWindows()
 {
     if (ResolutionGalleryWindow.IsOpen())
     {
         ResolutionGalleryWindow.m_Window.Repaint();
     }
     if (ResolutionPreviewWindow.IsOpen())
     {
         ResolutionPreviewWindow.m_Window.Repaint();
     }
     if (ResolutionSettingsWindow.IsOpen())
     {
         ResolutionSettingsWindow.m_Window.Repaint();
     }
 }
        void Reset()
        {
            //			Debug.Log ("Reset");

            m_ConfigAsset = ResolutionSettingsWindow.GetConfig();

            DestroyManager();

            if (m_Camera)
            {
                GameObject.DestroyImmediate(m_Camera.gameObject);
            }
            if (m_Canvas)
            {
                GameObject.DestroyImmediate(m_Canvas.gameObject);
            }

            m_IsUpdating = false;
        }
Esempio n. 5
0
        protected override void DrawToolBarGUI()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            // BUTTONS
            var col = GUI.color;

            GUI.color = new Color(0.6f, 1f, 0.6f, 1.0f);
            if (GUILayout.Button("  Update Previews ", EditorStyles.toolbarButton))
            {
                UpdateWindowResolutions();
            }
            GUI.color = col;

            if (GUILayout.Button("Export to file(s)", EditorStyles.toolbarButton))
            {
                Export();
            }

            // SPACE
            GUILayout.FlexibleSpace();

            // SAFE AREA
            if (m_ConfigAsset.m_DrawSafeArea)
            {
                if (GUILayout.Button("Safe Area (ON)  ", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_DrawSafeArea = false;
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }
            else
            {
                if (GUILayout.Button("Safe Area (OFF)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_DrawSafeArea = true;
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }

            // ORIENTATION
            if (m_ConfigAsset.m_Config.GetFirstActiveResolution().m_Orientation == ScreenshotResolution.Orientation.LANDSCAPE)
            {
                if (GUILayout.Button("LANDSCAPE", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_Config.SetAllPortait();
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }
            else
            {
                if (GUILayout.Button("PORTAIT", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_Config.SetAllLandscape();
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }


            // MODE
            EditorGUILayout.LabelField("Display mode", GUILayout.MaxWidth(85));
            EditorGUILayout.PropertyField(m_SerializedConfig.FindProperty("m_GalleryDisplayMode"), GUIContent.none, GUILayout.MaxWidth(70));

            // MODE
            EditorGUILayout.LabelField("Drawing mode", GUILayout.MaxWidth(85));
            var previousDrawing = m_ConfigAsset.m_DrawingMode;

            EditorGUILayout.PropertyField(m_SerializedConfig.FindProperty("m_DrawingMode"), GUIContent.none, GUILayout.MaxWidth(100));
            m_SerializedConfig.ApplyModifiedProperties();
            m_SerializedConfig.Update();
            if (previousDrawing != m_ConfigAsset.m_DrawingMode)
            {
                UpdateWindowResolutions();
            }



            if (GUILayout.Button("Settings", EditorStyles.toolbarButton))
            {
                ResolutionSettingsWindow.Init();
            }

            // ABOUT
            if (GUILayout.Button("About", EditorStyles.toolbarButton))
            {
                UniversalDevicePreview.About();
            }

            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);



            // AUTO REFRESH
            if (m_ConfigAsset.m_AutoRefresh)
            {
                if (GUILayout.Button("Auto refresh (ON)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_AutoRefresh = false;
                    EditorUtility.SetDirty(m_ConfigAsset);
                }
            }
            else
            {
                if (GUILayout.Button("Auto refresh (OFF)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_AutoRefresh = true;
                    EditorUtility.SetDirty(m_ConfigAsset);
                }
            }
            EditorGUILayout.LabelField("Refresh delay (s)", GUILayout.MaxWidth(110));
            float delay = EditorGUILayout.Slider(m_ConfigAsset.m_RefreshDelay, 0.01f, 10f, GUILayout.MaxWidth(200));

            if (delay != m_ConfigAsset.m_RefreshDelay)
            {
                m_ConfigAsset.m_RefreshDelay = delay;
                EditorUtility.SetDirty(m_ConfigAsset);
            }



            // SPACE
            GUILayout.FlexibleSpace();

            // ZOOM
            EditorGUILayout.LabelField("Zoom", GUILayout.MaxWidth(40));
            float zoom = EditorGUILayout.Slider(m_ConfigAsset.m_PreviewGalleryZoom, 0.05f, 4f, GUILayout.ExpandWidth(true));

            if (zoom != m_ConfigAsset.m_PreviewGalleryZoom)
            {
                m_ConfigAsset.m_PreviewGalleryZoom = zoom;
                EditorUtility.SetDirty(m_ConfigAsset);
            }

            if (GUILayout.Button("1:1", EditorStyles.toolbarButton))
            {
                m_ConfigAsset.m_PreviewGalleryZoom = 1f;
                EditorUtility.SetDirty(m_ConfigAsset);
            }

            EditorGUILayout.EndHorizontal();
        }
        protected override void DrawToolBarGUI()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);


            // Safe selection
            if (m_ConfigAsset.m_Selected >= m_ConfigAsset.m_Config.m_Resolutions.Count)
            {
                m_ConfigAsset.m_Selected = 0;
            }


            // BUTTONS
            var col = GUI.color;

            GUI.color = new Color(0.6f, 1f, 0.6f, 1.0f);
            if (GUILayout.Button("  Update Preview  ", EditorStyles.toolbarButton))
            {
                UpdateWindowResolutions();
            }
            GUI.color = col;

            if (GUILayout.Button("Export to file(s)", EditorStyles.toolbarButton))
            {
                Export();
            }

            // SPACE
            GUILayout.FlexibleSpace();



            // SAFE AREA
            if (m_ConfigAsset.m_DrawSafeArea)
            {
                if (GUILayout.Button("Safe Area (ON)  ", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_DrawSafeArea = false;
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }
            else
            {
                if (GUILayout.Button("Safe Area (OFF)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_DrawSafeArea = true;
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }

            // ORIENTATION
            var previousOrientation     = ScreenshotResolution.Orientation.LANDSCAPE;
            ScreenshotResolution device = null;

            if (m_ConfigAsset.m_Config.m_Resolutions.Count > m_ConfigAsset.m_Selected)
            {
                device = m_ConfigAsset.m_Config.m_Resolutions[m_ConfigAsset.m_Selected];
            }
            if (device != null)
            {
                previousOrientation = device.m_Orientation;
                var newOrientation = (ScreenshotResolution.Orientation)EditorGUILayout.EnumPopup("", m_ConfigAsset.m_Config.GetFirstActiveResolution().m_Orientation);
                if (newOrientation != previousOrientation)
                {
                    if (newOrientation == ScreenshotResolution.Orientation.LANDSCAPE)
                    {
                        m_ConfigAsset.m_Config.SetAllLandscape();
                    }
                    else if (newOrientation == ScreenshotResolution.Orientation.LANDSCAPE_RIGHT)
                    {
                        m_ConfigAsset.m_Config.SetAllLandscapeRight();
                    }
                    else
                    {
                        m_ConfigAsset.m_Config.SetAllPortait();
                    }
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }

            // MODE
            EditorGUILayout.LabelField("Display mode", GUILayout.MaxWidth(85));
            EditorGUILayout.PropertyField(m_SerializedConfig.FindProperty("m_PreviewDisplayMode"), GUIContent.none, GUILayout.MaxWidth(70));


            // MODE
            EditorGUILayout.LabelField("Drawing mode", GUILayout.MaxWidth(85));
            var previousDrawing = m_ConfigAsset.m_DrawingMode;

            EditorGUILayout.PropertyField(m_SerializedConfig.FindProperty("m_DrawingMode"), GUIContent.none, GUILayout.MaxWidth(100));
            m_SerializedConfig.ApplyModifiedProperties();
            if (previousDrawing != m_ConfigAsset.m_DrawingMode)
            {
                UpdateWindowResolutions();
            }



            if (GUILayout.Button("Settings", EditorStyles.toolbarButton))
            {
                ResolutionSettingsWindow.Init();
            }

            // ABOUT
            if (GUILayout.Button("About", EditorStyles.toolbarButton))
            {
                UniversalDevicePreview.About();
            }

            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);


            // AUTO REFRESH
            if (m_ConfigAsset.m_AutoRefresh)
            {
                if (GUILayout.Button("Auto refresh (ON)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_AutoRefresh = false;
                    EditorUtility.SetDirty(m_ConfigAsset);
                }
            }
            else
            {
                if (GUILayout.Button("Auto refresh (OFF)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_AutoRefresh = true;
                    EditorUtility.SetDirty(m_ConfigAsset);
                }
            }
            EditorGUILayout.LabelField("Refresh delay (s)", GUILayout.MaxWidth(110));
            float delay = EditorGUILayout.Slider(m_ConfigAsset.m_RefreshDelay, 0.01f, 10f, GUILayout.MaxWidth(200));

            if (delay != m_ConfigAsset.m_RefreshDelay)
            {
                m_ConfigAsset.m_RefreshDelay = delay;
                EditorUtility.SetDirty(m_ConfigAsset);
            }



            // SPACE
            GUILayout.FlexibleSpace();

            // ZOOM
            EditorGUILayout.LabelField("Zoom", GUILayout.MaxWidth(40));
            float zoom = EditorGUILayout.Slider(m_ConfigAsset.m_PreviewZoom, 0.05f, 4f);

            if (zoom != m_ConfigAsset.m_PreviewZoom)
            {
                m_ConfigAsset.m_PreviewZoom = zoom;
                EditorUtility.SetDirty(m_ConfigAsset);
            }

            if (GUILayout.Button("1:1", EditorStyles.toolbarButton))
            {
                m_ConfigAsset.m_PreviewZoom = 1f;
                EditorUtility.SetDirty(m_ConfigAsset);
            }

            EditorGUILayout.EndHorizontal();



            // DEVICES
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            GUILayout.FlexibleSpace();

            // SELECTION
            List <string> names    = m_ConfigAsset.m_Config.m_Resolutions.Select(x => x.ToString()).ToList();
            int           selected = EditorGUILayout.Popup(m_ConfigAsset.m_Selected, names.ToArray(), GUILayout.MinWidth(400));

            if (m_ConfigAsset.m_Config.m_Resolutions.Count > 0)
            {
                m_SelectedResolution = m_ConfigAsset.m_Config.m_Resolutions[selected];
            }
            else
            {
                m_SelectedResolution = null;
            }


            // Call update if selected changed
            if (selected != m_ConfigAsset.m_Selected)
            {
                m_ConfigAsset.m_Selected = selected;
                EditorUtility.SetDirty(m_ConfigAsset);
                if (m_ConfigAsset.m_AutoGenerateEmptyPreview)
                {
                    UpdateWindowResolutions();
                }
            }


            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
        protected override void DrawToolBarGUI()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);


            // Safe selection
            if (m_ConfigAsset.m_Selected >= m_ConfigAsset.m_Config.GetActiveResolutions().Count)
            {
                m_ConfigAsset.m_Selected = 0;
            }


            // BUTTONS
            if (GUILayout.Button("Update", EditorStyles.toolbarButton))
            {
                UpdateWindowResolutions();
            }

            if (GUILayout.Button("Export to file(s)", EditorStyles.toolbarButton))
            {
                Export();
            }

            // SPACE
            GUILayout.FlexibleSpace();



            // SAFE AREA
            if (m_ConfigAsset.m_DrawSafeArea)
            {
                if (GUILayout.Button("Safe Area (ON)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_DrawSafeArea = false;
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }
            else
            {
                if (GUILayout.Button("Safe Area (OFF)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_DrawSafeArea = true;
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }

            // ORIENTATION
            if (m_ConfigAsset.m_Config.GetActiveResolutions().Count > 0 && m_ConfigAsset.m_Config.GetActiveResolutions() [m_ConfigAsset.m_Selected].m_Orientation == ScreenshotResolution.Orientation.LANDSCAPE)
            {
                if (GUILayout.Button("LANDSCAPE", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_Config.SetAllPortait();
//					m_ConfigAsset.m_Config.GetActiveResolutions () [m_ConfigAsset.m_Selected].m_Orientation = ScreenshotResolution.Orientation.PORTRAIT;
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }
            else
            {
                if (GUILayout.Button("PORTAIT", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_Config.SetAllLandscape();
//					m_ConfigAsset.m_Config.GetActiveResolutions () [m_ConfigAsset.m_Selected].m_Orientation = ScreenshotResolution.Orientation.LANDSCAPE;
                    EditorUtility.SetDirty(m_ConfigAsset);
                    UpdateWindowResolutions();
                }
            }



            // MODE
            EditorGUILayout.LabelField("Display mode", GUILayout.MaxWidth(85));
            EditorGUILayout.PropertyField(m_SerializedConfig.FindProperty("m_PreviewDisplayMode"), GUIContent.none, GUILayout.MaxWidth(70));


            // MODE
            EditorGUILayout.LabelField("Drawing mode", GUILayout.MaxWidth(85));
            var previousDrawing = m_ConfigAsset.m_DrawingMode;

            EditorGUILayout.PropertyField(m_SerializedConfig.FindProperty("m_DrawingMode"), GUIContent.none, GUILayout.MaxWidth(100));
            m_SerializedConfig.ApplyModifiedProperties();
            if (previousDrawing != m_ConfigAsset.m_DrawingMode)
            {
                UpdateWindowResolutions();
            }



            if (GUILayout.Button("Settings", EditorStyles.toolbarButton))
            {
                ResolutionSettingsWindow.Init();
            }

            // ABOUT
            if (GUILayout.Button("About", EditorStyles.toolbarButton))
            {
                UniversalDevicePreview.About();
            }

            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);


            // AUTO REFRESH
            if (m_ConfigAsset.m_AutoRefresh)
            {
                if (GUILayout.Button("Auto refresh (ON)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_AutoRefresh = false;
                    EditorUtility.SetDirty(m_ConfigAsset);
                }
            }
            else
            {
                if (GUILayout.Button("Auto refresh (OFF)", EditorStyles.toolbarButton))
                {
                    m_ConfigAsset.m_AutoRefresh = true;
                    EditorUtility.SetDirty(m_ConfigAsset);
                }
            }
            EditorGUILayout.LabelField("Refresh delay (s)", GUILayout.MaxWidth(110));
            float delay = EditorGUILayout.Slider(m_ConfigAsset.m_RefreshDelay, 0.01f, 10f, GUILayout.MaxWidth(200));

            if (delay != m_ConfigAsset.m_RefreshDelay)
            {
                m_ConfigAsset.m_RefreshDelay = delay;
                EditorUtility.SetDirty(m_ConfigAsset);
            }



            // SPACE
            GUILayout.FlexibleSpace();

            // ZOOM
            EditorGUILayout.LabelField("Zoom", GUILayout.MaxWidth(40));
            float zoom = EditorGUILayout.Slider(m_ConfigAsset.m_PreviewZoom, 0.05f, 4f);

            if (zoom != m_ConfigAsset.m_PreviewZoom)
            {
                m_ConfigAsset.m_PreviewZoom = zoom;
                EditorUtility.SetDirty(m_ConfigAsset);
            }

            if (GUILayout.Button("1:1", EditorStyles.toolbarButton))
            {
                m_ConfigAsset.m_PreviewZoom = 1f;
                EditorUtility.SetDirty(m_ConfigAsset);
            }

            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);



            GUILayout.FlexibleSpace();

            // SELECTION
            List <string> names = new List <string> ();

            foreach (ScreenshotResolution resolution in m_ConfigAsset.m_Config.GetActiveResolutions())
            {
                names.Add(resolution.ToString());
            }
            int selected = EditorGUILayout.Popup(m_ConfigAsset.m_Selected, names.ToArray(), GUILayout.MinWidth(300));

            if (m_ConfigAsset.m_Config.GetActiveResolutions().Count > 0)
            {
                m_SelectedResolution = m_ConfigAsset.m_Config.GetActiveResolutions() [selected];
            }
            else
            {
                m_SelectedResolution = null;
            }


            // Call update if selected changed
            if (selected != m_ConfigAsset.m_Selected)
            {
                m_ConfigAsset.m_Selected = selected;
                EditorUtility.SetDirty(m_ConfigAsset);
                UpdateWindowResolutions();
            }



            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();
        }