private void OnGUI()
        {
            // TODO: ComputeShaderがAndroidBuildだと使えないから警告文を出す
            if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
            {
                DrawNotSupportBuildTarget();
                return;
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                GatoGUILayout.ObjectField(
                    localizedText.Data.rendererLabelText,
                    model.renderer,
                    renderer => model.OnChangeRenderer(canvasView, renderer)
                    );

                EditorGUILayout.Space();

                GatoGUILayout.EnumPopup(
                    localizedText.SelectedLanguage,
                    language => OnLanguagePopupChanged(language),
                    GUILayout.Width(50)
                    );
            }

            GUILayout.Space(20);

            using (new EditorGUILayout.HorizontalScope())
            {
                using (new EditorGUILayout.VerticalScope())
                {
                    canvasView.Render(model.HasTexture(), CANVAS_SIZE_RAITO);

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        GatoGUILayout.Slider(
                            localizedText.Data.scaleLabelText,
                            canvasView.ZoomScale,
                            0.1f,
                            1.0f,
                            scale => canvasView.ZoomScale = scale
                            );

                        GatoGUILayout.Button(
                            localizedText.Data.resetButtonText,
                            () => canvasView.ResetScrollOffsetAndZoomScale()
                            );
                    }
                }

                toolView.Render(model, localizedText, canvasView, 1 - CANVAS_SIZE_RAITO);
            }

            if (InputKeyDown(KeyCode.Z))
            {
                canvasView.UndoPreviewTexture();
            }
        }
Exemplo n.º 2
0
        public void Render(MeshDeleterWithTextureModel model, LocalizedText localizedText, CanvasView canvasView, float toolSizeRaito)
        {
            var width       = EditorGUIUtility.currentViewWidth * toolSizeRaito - PADDING_SIZE;
            var widthOption = GUILayout.Width(width);

            using (new EditorGUILayout.VerticalScope())
            {
                using (new EditorGUILayout.HorizontalScope(widthOption))
                {
                    GatoGUILayout.DisabledButton(
                        localizedText.Data.importDeleteMaskButtonText,
                        () => canvasView.deleteMask.ImportDeleteMaskTexture(),
                        !model.HasTexture()
                        );

                    GatoGUILayout.DisabledButton(
                        localizedText.Data.exportDeleteMaskButtonText,
                        () => {
                        canvasView.deleteMask.ExportDeleteMaskTexture();
                        model.SetPreviewTextureToMaterial(ref canvasView.previewTexture);

                        canvasView.uvMap.SetUVMapTexture(model.renderer, model.currentMaterialInfo);
                    },
                        !model.HasTexture()
                        );
                }

                GatoGUILayout.DragAndDropableArea(
                    localizedText.Data.dragAndDropDeleteMaskTextureAreaText,
                    deleteMaskTextureExtensions,
                    path => canvasView.deleteMask.ApplyDeleteMaskTextureToBuffer(path),
                    widthOption,
                    GUILayout.Height(EditorGUIUtility.singleLineHeight * 2)
                    );

                GUILayout.Space(10f);

                using (new EditorGUILayout.HorizontalScope(widthOption))
                {
                    GatoGUILayout.ColorField(
                        localizedText.Data.uvMapLineColorLabelText,
                        canvasView.uvMap.uvMapLineColor,
                        uvMapLineColor => canvasView.uvMap.SetUVMapLineColor(uvMapLineColor)
                        );

                    GatoGUILayout.Button(
                        localizedText.Data.exportUvMapButtonText,
                        () => canvasView.uvMap.ExportUVMapTexture()
                        );
                }

                GUILayout.Space(10);

                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    if (model.HasMaterials())
                    {
                        model.materialInfoIndex = EditorGUILayout.Popup(localizedText.Data.textureLabelText, model.materialInfoIndex, model.textureNames, widthOption);
                    }

                    if (check.changed)
                    {
                        model.OnChangeMaterial(canvasView);
                    }
                }

                EditorGUILayout.Space();

                using (new GatoGUILayout.TitleScope(localizedText.Data.toolsTitleText, widthOption))
                {
                    EditorGUILayout.LabelField(localizedText.Data.drawTypeLabelText, widthOption);

                    GatoGUILayout.Toolbar(
                        canvasView.DrawType,
                        drawTypeTexts,
                        drawType => { canvasView.DrawType = drawType; },
                        widthOption
                        );

                    EditorGUILayout.Space();

                    using (new EditorGUI.DisabledGroupScope(!model.HasTexture()))
                    {
                        PenColorChangeGUI(localizedText, canvasView, widthOption);
                    }

                    EditorGUILayout.Space();

                    GatoGUILayout.IntSlider(
                        localizedText.Data.penEraserSizeLabelText,
                        canvasView.PenSize,
                        1,
                        !model.HasTexture() ? 100 : model.Texture.width / 20,
                        penSize => canvasView.PenSize = penSize,
                        widthOption
                        );

                    EditorGUILayout.Space();

                    if (canvasView.DrawType == DrawType.SELECT)
                    {
                        using (new GatoGUILayout.RightAlignedScope(widthOption))
                        {
                            GatoGUILayout.Button(
                                localizedText.Data.inverseSelectAreaButtonText,
                                () => canvasView.selectArea.InverseSelectArea()
                                );

                            GatoGUILayout.Button(
                                localizedText.Data.applySelectAreaButtonText,
                                () => canvasView.ApplySelectArea()
                                );
                        }

                        EditorGUILayout.Space();
                    }

                    using (new GatoGUILayout.RightAlignedScope(widthOption))
                    {
                        GatoGUILayout.Button(
                            localizedText.Data.inverseFillAreaButtonText,
                            () =>
                        {
                            canvasView.RegisterUndoTexture();
                            canvasView.InverseFillArea();
                        }
                            );

                        GatoGUILayout.Button(
                            localizedText.Data.clearAllDrawingButtonText,
                            () =>
                        {
                            canvasView.RegisterUndoTexture();

                            canvasView.ClearAllDrawing();

                            model.SetPreviewTextureToMaterial(ref canvasView.previewTexture);
                        }
                            );

                        GUILayout.FlexibleSpace();

                        GatoGUILayout.DisabledButton(
                            localizedText.Data.undoDrawingButtonText,
                            () => canvasView.UndoPreviewTexture(),
                            !canvasView.undo.canUndo()
                            );
                    }
                }

                GUILayout.Space(20);

                using (new GatoGUILayout.TitleScope(localizedText.Data.modelInformationTitleText, widthOption))
                    using (new EditorGUI.IndentLevelScope())
                    {
                        EditorGUILayout.LabelField(localizedText.Data.triangleCountLabelText, model.triangleCount.ToString(), widthOption);
                    }

                GUILayout.Space(20);

                OutputMeshGUI(model, localizedText, widthOption);

                GUILayout.Space(50);

                using (new GatoGUILayout.RightAlignedScope(widthOption))
                {
                    GatoGUILayout.DisabledButton(
                        localizedText.Data.revertMeshToPrefabButtonText,
                        () => model.RevertMeshToPrefab(canvasView),
                        model.renderer == null || !PrefabUtility.IsPartOfAnyPrefab(model.renderer)
                        );

                    GatoGUILayout.DisabledButton(
                        localizedText.Data.revertMeshToPreviouslyButtonText,
                        () => model.RevertMeshToPreviously(canvasView),
                        !model.HasPreviousMesh()
                        );
                }

                EditorGUILayout.Space();

                GatoGUILayout.Button(
                    localizedText.Data.deleteMeshButtonText,
                    () =>
                {
                    try
                    {
                        model.OnDeleteMeshButtonClicked(canvasView);
                    }
                    catch (NotFoundVerticesException e)
                    {
                        EditorUtility.DisplayDialog(
                            localizedText.Data.errorDialogTitleText,
                            localizedText.Data.notFoundVerticesExceptionDialogMessageText,
                            localizedText.Data.errorDialogOkText
                            );
                        Debug.LogError(e.Message);
                    }
                    GUIUtility.ExitGUI();
                },
                    widthOption
                    );
            }
        }