private void AspectGUI() { EZ_Style.Header("Aspect", false, false); if (useBackground) { backgroundAspect = (EzSS_AspectHelper.Aspects)EditorGUILayout.EnumPopup("Background Aspect:", backgroundAspect); } if (useMockup) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Mockup Aspect:", GUILayout.Width(148)); EZ_Style.BeginHorizontalRectBox(); EditorGUILayout.LabelField(currentAspectName); EZ_Style.EndHorizontalRectBox(); EditorGUILayout.EndHorizontal(); VerifyAspect(mockupAspect); } else { screenshotAspect = (EzSS_AspectHelper.Aspects)EditorGUILayout.EnumPopup("Screenshot Aspect:", screenshotAspect); VerifyAspect(screenshotAspect); } EZ_Style.Footer(); }
private void VerifyAspect(EzSS_AspectHelper.Aspects aspect) { string _newAspectName = ""; aspectVector = EzSS_AspectHelper.AspectsVectors[aspect]; // Set the name of the new aspect if (Vector2.Equals(aspectVector, Vector2.zero)) { _newAspectName = ""; } else { _newAspectName = aspectVector.x + ":" + aspectVector.y; } // If the current name and the new one are different, change the aspect of the game view if (!string.Equals(currentAspectName, _newAspectName)) { EzSS_GameView.SetAspectRatio(EzSS_GameView.GameViewSizeType.AspectRatio, (int)aspectVector.x, (int)aspectVector.y, _newAspectName); // Reset all the cameras to update the aspect Camera[] _tempCameras = GameObject.FindObjectsOfType(typeof(Camera)) as Camera[]; for (int i = 0; i < _tempCameras.Length; i++) { _tempCameras[i].enabled = false; _tempCameras[i].enabled = true; } } }
private Vector2 SizeConstructor(EzSS_AspectHelper.Aspects aspect, int width, int height) { int _width = width; int _height = height; if (aspect == EzSS_AspectHelper.Aspects.aspect_2_3 || aspect == EzSS_AspectHelper.Aspects.aspect_3_4 || aspect == EzSS_AspectHelper.Aspects.aspect_3_5 || aspect == EzSS_AspectHelper.Aspects.aspect_4_5 || aspect == EzSS_AspectHelper.Aspects.aspect_9_16 || aspect == EzSS_AspectHelper.Aspects.aspect_10_16) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Width:", GUILayout.Width(45)); rect = EditorGUILayout.BeginHorizontal(); GUI.Box(rect, GUIContent.none); EditorGUILayout.LabelField(_width.ToString()); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Height:", GUILayout.Width(45)); _height = EditorGUILayout.IntSlider(_height, minSize, maxSize); EditorGUILayout.EndHorizontal(); if (useMockup && mockupImage != null) { _width = Mathf.RoundToInt(_height / (mockupFixedSize.y / mockupFixedSize.x)); } else { _width = Mathf.RoundToInt((float)_height * EzSS_AspectHelper.AspectsResults[aspect]); } } else if (aspect == EzSS_AspectHelper.Aspects.aspect_3_2 || aspect == EzSS_AspectHelper.Aspects.aspect_4_3 || aspect == EzSS_AspectHelper.Aspects.aspect_5_3 || aspect == EzSS_AspectHelper.Aspects.aspect_5_4 || aspect == EzSS_AspectHelper.Aspects.aspect_16_9 || aspect == EzSS_AspectHelper.Aspects.aspect_16_10) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Width:", GUILayout.Width(45)); _width = EditorGUILayout.IntSlider(_width, minSize, maxSize); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Height:", GUILayout.Width(45)); rect = EditorGUILayout.BeginHorizontal(); GUI.Box(rect, GUIContent.none); EditorGUILayout.LabelField(_height.ToString()); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); if (useMockup && mockupImage != null) { if (mockupCategory == MockupCategories.computer) { _height = Mathf.RoundToInt(_width / (mockupFixedSize.x / mockupFixedSize.y)); } else { _height = Mathf.RoundToInt(_width / (mockupFixedSize.y / mockupFixedSize.x)); } } else { _height = Mathf.RoundToInt(_width / EzSS_AspectHelper.AspectsResults[aspect]); } } else { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Width:", GUILayout.Width(45)); _width = EditorGUILayout.IntSlider(_width, minSize, maxSize); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Height:", GUILayout.Width(45)); _height = EditorGUILayout.IntSlider(_height, minSize, maxSize); EditorGUILayout.EndHorizontal(); } return(new Vector2(_width, _height)); }
private void MockupGUI() { if (useMockup = EZ_Style.Header("Mockup", true, useMockup)) { if (appleManager == null) { appleManager = new EzSS_AppleManager(); } if (encodeType == EncodeType.JPG) { encodeType = EncodeType.PNG; EditorUtility.DisplayDialog(EzSS_Messages.TITLE_00, EzSS_Messages.WARNING_02, EzSS_Messages.BUTTON_00); } // Select the brand mockupBrand = (MockupBrands)EditorGUILayout.EnumPopup("Brand:", mockupBrand); // Select the category mockupCategory = (MockupCategories)EditorGUILayout.EnumPopup("Category:", mockupCategory); // Select the device if (mockupCategory == MockupCategories.smartphone) { if (mockupBrand == MockupBrands.apple) { setMockupOrientation = true; // Mockup configurations selectedMockup = appleManager.SmartphoneSelector(); selectedColor = appleManager.SmartphoneColorSelector(); mockupFixedSize = appleManager.devicesFixedSizes[appleManager.smartphonesApple.ToString()]; mockupAspect = appleManager.devicesAspects[appleManager.smartphonesApple.ToString()]; screenPercentage = appleManager.devicesScreenPercentage[appleManager.smartphonesApple.ToString()]; deviceOffset = appleManager.devicesOffsets[appleManager.smartphonesApple.ToString()]; } } else if (mockupCategory == MockupCategories.tablet) { if (mockupBrand == MockupBrands.apple) { setMockupOrientation = true; // Mockup configurations selectedMockup = appleManager.TabletSelector(); selectedColor = appleManager.TabletColorSelector(); mockupFixedSize = appleManager.devicesFixedSizes[appleManager.tablet.ToString()]; mockupAspect = appleManager.devicesAspects[appleManager.tablet.ToString()]; screenPercentage = appleManager.devicesScreenPercentage[appleManager.tablet.ToString()]; deviceOffset = appleManager.devicesOffsets[appleManager.tablet.ToString()]; } } else if (mockupCategory == MockupCategories.computer) { if (mockupBrand == MockupBrands.apple) { // Computers has wide aspect ratio, but the orientation is portrait because landcape will invert x and y width and height setMockupOrientation = false; mockupOrientation = MockupOrientation.portrait; // Mockup configurations selectedMockup = appleManager.ComputerSelector(); selectedColor = appleManager.ComputerColorSelector(); mockupFixedSize = appleManager.devicesFixedSizes[appleManager.computer.ToString()]; mockupAspect = appleManager.devicesAspects[appleManager.computer.ToString()]; screenPercentage = appleManager.devicesScreenPercentage[appleManager.computer.ToString()]; deviceOffset = appleManager.devicesOffsets[appleManager.computer.ToString()]; } } else { if (mockupBrand == MockupBrands.apple) { // Watches has just one orientation setMockupOrientation = false; mockupOrientation = MockupOrientation.portrait; // Mockup configurations selectedMockup = appleManager.WatchSelector(); selectedColor = appleManager.WatchColorSelector(); mockupFixedSize = appleManager.devicesFixedSizes[appleManager.watch.ToString()]; mockupAspect = appleManager.devicesAspects[appleManager.watch.ToString()]; screenPercentage = appleManager.devicesScreenPercentage[appleManager.watch.ToString()]; deviceOffset = appleManager.devicesOffsets[appleManager.watch.ToString()]; } } if (setMockupOrientation) { mockupOrientation = (MockupOrientation)EditorGUILayout.EnumPopup("Orientation:", mockupOrientation); selectedOrientation = mockupOrientation.ToString(); if (EzSS_AspectHelper.AspectsResults[mockupAspect] < 1 && (mockupOrientation == MockupOrientation.landscapeLeft || mockupOrientation == MockupOrientation.landscapeRight)) { mockupAspect = EzSS_AspectHelper.AspectsInverted[appleManager.devicesAspects[selectedMockup]]; } } else { selectedOrientation = ""; } // Mockup image path selectedBrand = mockupBrand.ToString(); selectedCategory = mockupCategory.ToString(); if (!string.IsNullOrEmpty(selectedColor)) { selectedColor = "-" + selectedColor; } if (!string.IsNullOrEmpty(selectedOrientation)) { selectedOrientation = "-" + selectedOrientation; } string _finalPath = mockupsPath + selectedBrand + "/" + selectedCategory + "/" + selectedMockup + selectedColor + selectedOrientation + ".png"; // Load the image mockupImage = (Texture2D)AssetDatabase.LoadAssetAtPath(_finalPath, typeof(Texture2D)); // Display the image float _offsetX = mockupPreviewPreviewOffset[mockupCategory].x; float _offsetY = mockupPreviewPreviewOffset[mockupCategory].y; EditorGUILayout.LabelField("Mockup Preview:"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (mockupOrientation == MockupOrientation.portrait) { GUILayout.Label(mockupImage, GUILayout.Width(_offsetX), GUILayout.Height(_offsetY)); } else { GUILayout.Label(mockupImage, GUILayout.Width(_offsetY), GUILayout.Height(_offsetX)); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } EZ_Style.Footer(); }