示例#1
0
        private void OnGUI()
        {
            EditorGUI.BeginChangeCheck();
            originTexture = (Texture2D)EditorGUILayout.ObjectField("psd", originTexture, typeof(Texture2D), false);

            if (originTexture == null)
            {
                originPsd = null;
                return;
            }

            if (EditorGUI.EndChangeCheck() || (originTexture != null && originPsd == null))
            {
                UpdateOriginTexture();
            }

            fontData = (Font)EditorGUILayout.ObjectField("font", fontData, typeof(Font), false);
            EditorGUILayout.Space();

            if (saveEditor != null)
            {
                saveEditor.Draw(position.position);
            }

            if (GUILayout.Button("Convert"))
            {
                GameObject canvasObj = GameObject.Find("Canvas");
                if (canvasObj == null)
                {
                    canvasObj = new GameObject("Canvas");
                    var canvas = canvasObj.AddComponent <Canvas>();
                    canvas.renderMode = RenderMode.ScreenSpaceOverlay;

                    var scalor = canvasObj.AddComponent <CanvasScaler>();
                    scalor.uiScaleMode         = CanvasScaler.ScaleMode.ScaleWithScreenSize;
                    scalor.referenceResolution = originSize;
                }

                Convert();
                UpdateOriginTexture();
            }
        }
示例#2
0
        private void OnGUI()
        {
            EditorGUI.BeginChangeCheck();
            originTexture = (Texture2D)EditorGUILayout.ObjectField("psd", originTexture, typeof(Texture2D), false);
            if (EditorGUI.EndChangeCheck() || (originTexture != null && originPsd == null))
            {
                UpdateOriginTexture();
            }

            fontData = (Font)EditorGUILayout.ObjectField("font", fontData, typeof(Font), false);
            EditorGUILayout.Space();

            if (saveEditor != null)
            {
                saveEditor.Draw();
            }

            if (GUILayout.Button("Convert"))
            {
                Convert();
                UpdateOriginTexture();
            }
        }