コード例 #1
0
 private void UpdateSVGEditorWindow()
 {
     SVGEditorWindow svgEditorWindow = SVGEditorWindow.s_Instance;
     if(svgEditorWindow != null)
     {
         svgEditorWindow.ManualUpdate();
     }
 }
コード例 #2
0
 private void RepaintSVGEditorWindow()
 {
     SVGEditorWindow svgEditorWindow = SVGEditorWindow.s_Instance;
     if(svgEditorWindow != null)
     {
         svgEditorWindow.Repaint();
     }
 }
コード例 #3
0
 void OnEnable()
 {
     GetSVGAsset();
     UpdateOriginalPivotPoint();
     base.minSize = new Vector2(360f, 200f);
     s_Instance   = this;
     //Undo.undoRedoPerformed = (Undo.UndoRedoCallback)Delegate.Combine(Undo.undoRedoPerformed, new Undo.UndoRedoCallback(this.UndoRedoPerformed));
     CreateCamera();
     CreateSVGRenderer();
 }
コード例 #4
0
		void OnEnable()
		{
            GetSVGAsset();
            UpdateOriginalPivotPoint();
			base.minSize = new Vector2(360f, 200f);
			s_Instance = this;
			//Undo.undoRedoPerformed = (Undo.UndoRedoCallback)Delegate.Combine(Undo.undoRedoPerformed, new Undo.UndoRedoCallback(this.UndoRedoPerformed));
            CreateCamera();
            CreateSVGRenderer();
		}
コード例 #5
0
 public static void GetWindow()
 {
     s_Instance = EditorWindow.GetWindow <SVGEditorWindow>(false, "SVG Asset Editor", true);
 }
コード例 #6
0
        void OnFilesValid()
        {
            bool valueChanged = false;

            serializedObject.Update();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.LabelField("Rendering", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(format, FORMAT_LABEL);
            EditorGUILayout.PropertyField(useGradients, USE_GRADIENTS_LABEL);
            EditorGUILayout.PropertyField(antialiasing, ANTIALIASING_LABEL);
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Meshes", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(meshCompression, MESH_COMPRESSION_LABEL);
            if(((SVGMeshCompression)meshCompression.enumValueIndex) != SVGMeshCompression.Off)
            {
                EditorGUILayout.HelpBox(MESH_COMPRESSION_HELPBOX_LABEL, MessageType.Warning);
            }
            EditorGUILayout.PropertyField(optimizeMesh, OPTIMIZE_MESH_LABEL);
            EditorGUILayout.PropertyField(scale, SCALE_LABEL);
            EditorGUILayout.PropertyField(vpm, QUALITY_LABEL);

            if(format.enumValueIndex == (int)SVGAssetFormat.Opaque)
            {
                EditorGUILayout.PropertyField(depthOffset, DEPTH_OFFSET_LABEL);
                EditorGUILayout.PropertyField(compressDepth, COMPRESS_DEPTH_LABEL);
            }

            EditorGUILayout.PropertyField(customPivotPoint, CUSTOM_PIVOT_LABEL);
            EditorGUILayout.BeginHorizontal();
            if(customPivotPoint.boolValue)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(pivotPoint, PIVOT_LABEL);
                EditorGUILayout.EndHorizontal();
            } else {
                Vector2 pivotPointVector = pivotPoint.vector2Value;
                int selectedIndex = GetPivotPointIndex(pivotPointVector);
                selectedIndex = EditorGUILayout.Popup(PIVOT_LABEL, selectedIndex, anchorPositionContent);
                pivotPoint.vector2Value = GetPivotPoint(selectedIndex);
            }

            if(!serializedObject.isEditingMultipleObjects)
            {
                if(GUILayout.Button("SVG Editor", EditorStyles.miniButton, GUILayout.Width(70f)))
                {
                    SVGEditorWindow.GetWindow();
                }
            }

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.PropertyField(generateCollider, GENERATE_COLLIDER_LABEL);
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Normals & Tangents", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(generateNormals, GENERATE_NORMALS_LABEL);
            if(!generateNormals.boolValue)  EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.PropertyField(generateTangents, GENERATE_TANGENTS_LABEL);
            if(!generateNormals.boolValue && generateTangents.boolValue)
            {
                generateTangents.boolValue = false;
            }
            if(!generateNormals.boolValue)  EditorGUI.EndDisabledGroup();

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("SVG Document", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(keepSVGFile, KEEP_SVG_FILE_LABEL);
            EditorGUILayout.PropertyField(useLayers, USE_LAYERS_LABEL);
            EditorGUILayout.PropertyField(ignoreSVGCanvas, IGNORE_SVG_CANVAS_LABEL);
            EditorGUILayout.Space();

            if(EditorGUI.EndChangeCheck())
            {
                valueChanged = true;
            }

            GUILayout.BeginHorizontal();
            if(GUILayout.Button(new GUIContent("Recover SVG File", "Save the original SVG Document to a specified directory.")))
            {
                if(serializedObject.isEditingMultipleObjects)
                {
                    for(int i = 0; i < assets.Length; i++)
                    {
                        RecoverSVGFile(assets[i]);
                    }
                } else {
                    RecoverSVGFile(asset);
                }
            }

            if(GUILayout.Button(new GUIContent("Save Mesh File", "Save the mesh asset to a specified directory.")))
            {
                if(serializedObject.isEditingMultipleObjects)
                {
                    for(int i = 0; i < assets.Length; i++)
                    {
                        SaveMeshFile(assets[i]);
                    }
                } else {
                    SaveMeshFile(asset);
                }
            }

            if(valueChanged)
            {
                unappliedChanges = true;
                serializedObject.ApplyModifiedProperties();
                RepaintSVGEditorWindow();
            }
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUI.enabled = unappliedChanges && !UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode;

            if(GUILayout.Button(new GUIContent("Revert", "Revert all changes.")))
            {
                RevertChanges();
            }

            if (GUILayout.Button(new GUIContent("Apply", "Apply all changes.")))
            {
                serializedObject.ApplyModifiedProperties();
                ApplyChanges();
            }
            GUI.enabled = true;
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();

            SVGError[] errors = GetEditorErrors(asset);
            if(errors != null && errors.Length > 0)
            {
                for(int i = 0; i < errors.Length; i++)
                {
                    switch(errors[i])
                    {
                        case SVGError.CorruptedFile:
                            EditorGUILayout.HelpBox("SVG file is corrupted", MessageType.Error);
                            break;
                        case SVGError.Syntax:
                            EditorGUILayout.HelpBox("SVG syntax is invalid", MessageType.Error);
                            break;
                        case SVGError.ClipPath:
                            EditorGUILayout.HelpBox("Clip paths are experimental", MessageType.Warning);
                            break;
                        case SVGError.Mask:
                            EditorGUILayout.HelpBox("Masks are not supported", MessageType.Warning);
                            break;
                        case SVGError.Symbol:
                            EditorGUILayout.HelpBox("Re-import for working symbols", MessageType.Warning);
                            break;
                        case SVGError.Image:
                            EditorGUILayout.HelpBox("Images are not supported", MessageType.Warning);
                            break;
                        case SVGError.Unknown:
                            EditorGUILayout.HelpBox("Unknow error occurred", MessageType.Error);
                            break;
                    }
                }
            }

            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(new GUIContent("Report Import!")))
            {
                SVGReportBugWindow.titleField = "Wrong SVG file import!";
                SVGReportBugWindow.descriptionField = "My file was incorrectly imported. I believe that the file is not corrupted.";
                SVGReportBugWindow.problemOccurrence = SVGReportBugWindow.PROBLEM_OCCURRENCE.Always;
                SVGReportBugWindow.problemType = SVGReportBugWindow.PROBLEM_TYPE.FileImport;
                SVGReportBugWindow.AddSVGAttachment(asset.name, asset.svgFile);
                SVGReportBugWindow.ShowReportBugWindow();
            }
            GUILayout.EndHorizontal();
        }
コード例 #7
0
 void DoRenderPreview()
 {
     SVGEditorWindow.DoRenderPreview(target as SVGAsset, m_PreviewUtility);
 }
コード例 #8
0
		public static void GetWindow()
		{
			s_Instance = EditorWindow.GetWindow<SVGEditorWindow>(false, "SVG Asset Editor", true);
		}