public void CustomOnPreviewGUI(Rect preview, Rect editorWindow, float padding, GUIStyle background) { if (createButtonStyle == null) { SetStylesAndImages(); } if (PreviewSceneInstance.PreviewObjectInstance != null) { EditorGUILayout.BeginVertical(GUILayout.MaxHeight(editorWindow.height - preview.height - padding * 2)); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, false, false); DrawRenderSettings(); DrawCameraSettings(preview); DrawLightsSettings(); DrawBackgroungSettings(); EditorGUILayout.EndScrollView(); MouseHandler(preview); EditorGUILayout.EndVertical(); PreviewSceneInstance.PreviewUtility.BeginPreview(preview, background); HandlerCameraRender.ChangeTexture(PreviewSceneInstance.PreviewUtility.camera, 256, backgroundTexture); PreviewSceneInstance.PreviewUtility.camera.backgroundColor = backgroundColor; PreviewSceneInstance.PreviewUtility.Render(); PreviewSceneInstance.PreviewUtility.EndAndDrawPreview(preview); } else { EditorGUILayout.HelpBox("Select an object from the project window that contains the MeshRenderer component.", MessageType.Info); } }
private void DrawRenderSettings() { EditorGUILayout.Space(); EditorGUILayout.BeginVertical("box"); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Size image"); sizeImagePreview = EditorGUILayout.Slider(sizeImagePreview, 64, 1024); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(" Create Icon", createButtonStyle, GUILayout.Height(24), GUILayout.Width(120))) { CheckDefaultFolderPathf(); PreviewSceneInstance.Light1.enabled = true; PreviewSceneInstance.Light2.enabled = true; if (clearFlags == ClearFlags.Image) { HandlerCameraRender.MakePreview(PreviewSceneInstance.PreviewCamera, folderPathf, PreviewSceneInstance.PreviewObjectInstance.name, (int)sizeImagePreview, backgroundTexture); } else { HandlerCameraRender.MakePreview(PreviewSceneInstance.PreviewCamera, folderPathf, PreviewSceneInstance.PreviewObjectInstance.name, (int)sizeImagePreview); } AssetDatabase.Refresh(); } if (GUILayout.Button(iconFolder, GUILayout.Height(24), GUILayout.Width(32))) { CheckDefaultFolderPathf(); string newFolderPathf = EditorUtility.SaveFolderPanel("Export folder", folderPathf, ""); if (newFolderPathf.Length > 0) { folderPathf = newFolderPathf + "/"; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); }
public Texture2D MakeImage(string folderPathf, string name, int size, Texture texBG) { Light1.enabled = true; Light2.enabled = true; if (folderPathf == "default") { folderPathf = "Assets/Easy Icon Maker/"; } if (name == "default" && PreviewObjectInstance != null) { name = PreviewObjectInstance.name; } Texture2D image = HandlerCameraRender.MakePreview(PreviewCamera, folderPathf, name, size, texBG); AssetDatabase.Refresh(); return(image); }