void CreateResolutionReorderableList()
        {
            m_ResolutionReorderableList = new ReorderableList(serializedObject, m_Resolutions, true, true, true, true);

            if (m_IsDevice && m_Expanded)
            {
                m_ResolutionReorderableList.elementHeight = EditorGUIUtility.singleLineHeight * 8f;
            }
            else
            {
                m_ResolutionReorderableList.elementHeight = EditorGUIUtility.singleLineHeight * 1f;
            }



            m_ResolutionReorderableList.drawElementCallback = (Rect position, int index, bool active, bool focused) => {
                if (m_IsDevice)
                {
                    DrawResolution(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                    if (m_Expanded)
                    {
                        DrawResolutionName(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                        DrawResolutionRes(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                        DrawDeviceResolutionPPI(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                        DrawResolutionOrientation(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                        DrawDeviceCanvasResolution(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                    }
                }
                else
                {
                    SerializedProperty element = m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index);
                    EditorGUI.PropertyField(position, element);
                }
            };

            m_ResolutionReorderableList.onChangedCallback = (ReorderableList list) => {
                m_Config.UpdateRatios();
                EditorUtility.SetDirty(m_Obj);
            };

            m_ResolutionReorderableList.onSelectCallback = (ReorderableList list) => {
                m_Config.UpdateRatios();
                EditorUtility.SetDirty(m_Obj);
            };

            m_ResolutionReorderableList.drawHeaderCallback = (Rect position) => {
                if (m_IsDevice)
                {
                    EditorGUI.LabelField(position, "");
                }
                else
                {
                    EditorGUI.LabelField(position, "Active  Width     Height  Scale Ratio   Orientation        Name");
                }
            };



            m_ResolutionReorderableList.onAddDropdownCallback = (Rect position, ReorderableList list) => {
                var menu = new GenericMenu();

                ScreenshotResolutionPresets.Init();

                ConstructResolutionPresetsMenu(menu);

                menu.AddItem(new GUIContent("new"), false, OnResolutionSelectCallback, new ScreenshotResolution());

                menu.ShowAsContext();
            };
        }
Example #2
0
        void CreateResolutionReorderableList()
        {
            m_ResolutionReorderableList = new ReorderableList(serializedObject, m_Resolutions, true, true, true, true);

            if (m_ShowDetailedDevice && m_Expanded)
            {
                m_ResolutionReorderableList.elementHeight = EditorGUIUtility.singleLineHeight * 13f;
            }
            else
            {
                m_ResolutionReorderableList.elementHeight = EditorGUIUtility.singleLineHeight * 1f;
            }



            m_ResolutionReorderableList.drawElementCallback = (Rect position, int index, bool active, bool focused) =>
            {
                if (m_ShowDetailedDevice)
                {
                    DrawResolution(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                    if (m_Expanded)
                    {
                        DrawResolutionName(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                        DrawResolutionPlatform(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));

                        DrawResolutionRes(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                        DrawDeviceResolutionPPI(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                        DrawResolutionOrientation(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                        DrawDeviceCanvasResolution(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                        DrawDeviceSafeAreaPortrait(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                        DrawDeviceSafeArea(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                        // DrawDeviceSafeAreaRight(position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index));
                        //						DrawDeviceSafeAreaRight (position, m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex (index));
                    }
                }
                else
                {
                    SerializedProperty element = m_ResolutionReorderableList.serializedProperty.GetArrayElementAtIndex(index);
                    EditorGUI.PropertyField(position, element);
                }
            };

            m_ResolutionReorderableList.onChangedCallback = (ReorderableList list) =>
            {
                m_Config.UpdateRatios();
                EditorUtility.SetDirty(m_Obj);
            };

            m_ResolutionReorderableList.onSelectCallback = (ReorderableList list) =>
            {
                m_Config.UpdateRatios();
                EditorUtility.SetDirty(m_Obj);
            };

            m_ResolutionReorderableList.drawHeaderCallback = (Rect position) =>
            {
                if (m_ShowDetailedDevice)
                {
                    EditorGUI.LabelField(position, "");
                }
                else
                {
                    EditorGUI.LabelField(position, "Active  Width     Height  Scale Ratio   Orientation        Name");
                }
            };

            // Dirty fix
            m_ResolutionReorderableList.onReorderCallback = (ReorderableList list) =>
            {
                foreach (ScreenshotResolution r in m_Config.m_Resolutions)
                {
                    GameObject.DestroyImmediate(r.m_Texture);
                    r.m_Texture = null;
                }
            };


            m_ResolutionReorderableList.onAddDropdownCallback = (Rect position, ReorderableList list) =>
            {
                var res = new ScreenshotResolution();;
                res.m_ResolutionName = "";
                res.m_Category       = "";
                res.m_Width          = 800;
                res.m_Height         = 600;
                m_Config.m_Resolutions.Add(res);
                // DeviceSelectorWindow.Init();
                // DeviceS

                /*
                 * var menu = new GenericMenu();
                 *
                 * ScreenshotResolutionPresets.Init();
                 *
                 * ConstructResolutionPresetsMenu(menu);
                 *
                 * menu.AddItem(new GUIContent("new"), false, OnResolutionSelectCallback, new ScreenshotResolution());
                 *
                 * menu.ShowAsContext();
                 */
            };
        }