Exemplo n.º 1
0
        static SVGImporterLaunchEditor()
        {
            if (launched)
            {
                return;
            }
            else
            {
                launched = true;
            }

            initCall = new DelayedCall(DelayedInit);

            if (EditorPrefs.HasKey(SVG_IMPORTER_WINDOW_PREF_KEY))
            {
                _active = EditorPrefs.GetBool(SVG_IMPORTER_WINDOW_PREF_KEY);
            }
            else
            {
                _active = true;
            }

            //HideGizmos();
            SVGPostprocessor.Init();
            UpdateDelegates();

            //Analytics.TrackEvent("Start App, Version: "+SVGImporterSettings.version, "app/start");
            EditorCoroutine.StartCoroutine(initCall.Delay(0.5f), initCall);
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.LabelField("Rendering", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(format, SVGAssetEditor.FORMAT_LABEL);
            EditorGUILayout.PropertyField(useGradients, SVGAssetEditor.USE_GRADIENTS_LABEL);
            EditorGUILayout.PropertyField(antialiasing, SVGAssetEditor.ANTIALIASING_LABEL);
            EditorGUILayout.PropertyField(antialiasingWidth, SVGAssetEditor.ANTIALIASING_WIDTH_LABEL);
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Meshes", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(meshCompression, SVGAssetEditor.MESH_COMPRESSION_LABEL);
            EditorGUILayout.PropertyField(optimizeMesh, SVGAssetEditor.OPTIMIZE_MESH_LABEL);
            EditorGUILayout.PropertyField(scale, SVGAssetEditor.SCALE_LABEL);
            EditorGUILayout.PropertyField(vpm, SVGAssetEditor.QUALITY_LABEL);

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

            EditorGUILayout.PropertyField(customPivotPoint, SVGAssetEditor.CUSTOM_PIVOT_LABEL);
            if (customPivotPoint.boolValue)
            {
                EditorGUILayout.PropertyField(pivotPoint, SVGAssetEditor.PIVOT_LABEL);
            }
            else
            {
                Vector2 pivotPointVector = pivotPoint.vector2Value;
                int     selectedIndex    = Mathf.RoundToInt(pivotPointVector.x * 2 + Mathf.Clamp(pivotPointVector.y * 6, 0, 8));

                selectedIndex = EditorGUILayout.Popup("Pivot", selectedIndex, SVGAssetEditor.anchorPosition);

                int x = selectedIndex % 3;
                int y = Mathf.FloorToInt(selectedIndex / 3);

                pivotPointVector.x = x / 2f;
                pivotPointVector.y = y / 2f;

                pivotPoint.vector2Value = pivotPointVector;
            }
            EditorGUILayout.PropertyField(generateCollider, SVGAssetEditor.GENERATE_COLLIDER_LABEL);
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Normals & Tangents", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(generateNormals, SVGAssetEditor.GENERATE_NORMALS_LABEL);
            if (!generateNormals.boolValue)
            {
                EditorGUI.BeginDisabledGroup(true);
            }
            EditorGUILayout.PropertyField(generateTangents, SVGAssetEditor.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, SVGAssetEditor.KEEP_SVG_FILE_LABEL);
            EditorGUILayout.PropertyField(useLayers, SVGAssetEditor.USE_LAYERS_LABEL);
            EditorGUILayout.PropertyField(ignoreSVGCanvas, SVGAssetEditor.IGNORE_SVG_CANVAS_LABEL);

            GUILayout.Space(10f);

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            EditorGUILayout.BeginHorizontal();
            if (SVGPostprocessor.active)
            {
                EditorGUILayout.LabelField("Asset Postprocessor: On");
                if (GUILayout.Button("Stop"))
                {
                    SVGPostprocessor.Stop();
                }
            }
            else
            {
                EditorGUILayout.LabelField("Asset Postprocessor: Off");
                if (GUILayout.Button("Start"))
                {
                    SVGPostprocessor.Start();
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            if (SVGImporterLaunchEditor.active)
            {
                EditorGUILayout.LabelField("Support Service: On");

                /*
                 * if(GUILayout.Button("Stop"))
                 * {
                 *  SVGImporterLaunchEditor.Stop();
                 * }
                 */
            }
            else
            {
                EditorGUILayout.LabelField("Support Service: Off");
                if (GUILayout.Button("Start"))
                {
                    SVGImporterLaunchEditor.Stop();
                }
            }
            EditorGUILayout.EndHorizontal();
        }