Esempio n. 1
0
    public static void SetTextMeshProIntegration()
    {
        if (IsDefined(TEXDRAW_TMP))
        {
            if (EditorUtility.DisplayDialog("Removing TEXDRAW_TMP",
                                            "This will remove TMP integration for all platform. (Files will be keep). Please Rebuild TEXDraw font data after recompilation.",
                                            "Proceed", "Cancel"))
            {
                TEXPreference.main.defaultMaterial.shader = Shader.Find("TEXDraw/Default/Full");
                EditorPrefs.SetBool("TEXDraw_WillProceedTMP", true);
                SetDefined(TEXDRAW_TMP, false, true);
            }
        }
        else
        {
            var respond = EditorUtility.DisplayDialogComplex("Prequirements", "Do you already have imported TextMeshPro in your project?\n"
                                                             + "(NOTE: TMP Essentials should already be imported if you have installed TMP via Package Manager)",
                                                             "Yes", "Visit Asset Store", "Cancel");
            if (respond == 1)
            {
                Help.BrowseURL("https://www.assetstore.unity3d.com/en/#!/content/84126");
            }
            if (respond != 0)
            {
                return;
            }

            respond = EditorUtility.DisplayDialogComplex("Add TEXDRAW_TMP integration for all platform",
                                                         "This process will take a moment.\n" +
                                                         "For your safety, we can automate the whole process. What do you prefer?\n",
                                                         "Automatic (Recommended)", "Manual", "Abort");
            if (respond == 2)
            {
                return;
            }
            if (respond == 1)
            {
                if (EditorUtility.DisplayDialog("TEXDRAW_TMP manual integration",
                                                "Manual integration can be done in four steps:\n" +
                                                "1. Add TEXDRAW_TMP script definition to all platform (see PlayerSettings)\n" +
                                                "2. Importing additional shader pack (see GuideAndExtras) to this project\n" +
                                                "3. Render fonts into SDF assets (see TEXPreference)\n" +
                                                "4. Change TEXDraw materials to TEXDRAW-TMP shader each\n" +
                                                "We can do the first step by clicking OK. See the manual for more detail.", "OK", "Close"))
                {
                    SetDefined(TEXDRAW_TMP, true, true);
                }
                return;
            }
            TEXPreference.Initialize();
            AssetDatabase.importPackageCompleted += delegate(string name)
            {
                EditorPrefs.SetBool("TEXDraw_WillProceedTMP", true);
                SetDefined(TEXDRAW_TMP, true, true);
                Debug.Log("Wait a minute. Importing process will began shortly. Look at TEXPreference for the progress.");
                TEXPreference.main.defaultMaterial.shader = Shader.Find("TEXDraw/TextMeshPro/Distance Field");
            };
            AssetDatabase.ImportPackage(TEXPreference.main.MainFolderPath + "/GuideAndExtras/TEXDraw-TMP Shader Extensions.unitypackage", false);
        }
    }
Esempio n. 2
0
    protected override void OnEnable()
    {
        base.OnEnable();
        m_TextDirty = true;
        #if UNITY_EDITOR
        if (!pref)
        {
            pref = TEXPreference.main;
            if (!pref)
            {
                Debug.LogWarning("A TEXDraw Component hasn't the preference yet");
            }
        }
        #else
        if (!TEXPreference.main)
        {
            TEXPreference.main = pref; //Assign the Preference to main stack
        }
        else if (!pref)
        {
            pref = TEXPreference.main; //This component may added runtimely
        }
        #endif

        UpdateSupplements();
        Font.textureRebuilt += TextureRebuilted;

        #if UNITY_5_6_OR_NEWER
        if (canvas)
        {
            canvas.additionalShaderChannels |= AdditionalCanvasShaderChannels.Tangent | AdditionalCanvasShaderChannels.TexCoord1;
        }
        #endif
    }
Esempio n. 3
0
    public static void SetDefaultTemplate()
    {
        TEXPreference.Initialize();

        var obj     = Selection.activeGameObject;
        var tex     = GetTexDraw(obj);
        var name    = (tex.GetType().Name);
        var respond = EditorUtility.DisplayDialogComplex("Confirm set as Template",
                                                         string.Format("Do you want to set selected {0} as a template every time you create a new {0} object?" +
                                                                       "\n(This includes its components and values expect the text itself)\n(This template will only affect project-wide environment)", name)
                                                         , "Yes", "Yes, but keep the text", "Cancel");

        if (respond == 2)
        {
            return;
        }
        var path = TEXPreference.main.MainFolderPath + "/Template-" + name + ".prefab";

        obj = GameObject.Instantiate(obj);
        if (respond == 0)
        {
            GetTexDraw(obj).text = "TEXDraw";
        }
        PrefabUtility.CreatePrefab(path, obj, ReplacePrefabOptions.Default);
        GameObject.DestroyImmediate(obj, false);
    }
Esempio n. 4
0
    public static bool ValidateTemplateExist()
    {
        TEXPreference.Initialize();
        var files = AssetDatabase.FindAssets("Template-", new string[] { TEXPreference.main.MainFolderPath });

        return(files.Length > 0);
    }
Esempio n. 5
0
 void OnEnable()
 {
     TEXPreference.Initialize();
     Undo.undoRedoPerformed += RecordRedrawCallback;
     matProp      = serializedObject.FindProperty("watchedMaterial");
     configEditor = CreateEditor(TEXConfiguration.main);
     if (willFocusOnImport)
     {
         FocusOnImporter();
         willFocusOnImport = false;
     }
 }
Esempio n. 6
0
    int SubDrawThumbnail(int hash, string confirmTxt, GUIStyle style)
    {
        if (EditorGUILayout.ToggleLeft(confirmTxt, hash != -1))
        {
            EditorGUI.BeginChangeCheck();
            EditorGUI.indentLevel++;

            if (hash < 0)
            {
                hash = selectedChar.ToHash() + 1;
            }
            int font = hash >> 8, ch = hash % 128;
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical();
            font = Mathf.Clamp(EditorGUILayout.IntField(font), 0, targetPreference.fonts.Length);
            ch   = Mathf.Clamp(EditorGUILayout.IntField(ch), 0, 127);
            var targetFont = targetPreference.fonts[font];
            EditorGUILayout.EndVertical();
            EditorGUI.indentLevel--;
            if (targetFont.type == TexAssetType.Font)
            {
                //r.height = targetFont.Font_Asset.lineHeight * 1.7f;
                style.font = ((TexFont)targetFont).asset;
                EditorGUILayout.LabelField(Styles.GetCharMapContent(targetFont.chars[ch].characterIndex), style);
            }
            else
            {
                //r.height = targetFont.font_lineHeight * r.width;
                EditorGUILayout.LabelField(GUIContent.none);
                var r  = EditorGUILayout.GetControlRect(GUILayout.Height(35));
                var st = ((TexSprite)targetFont).assets[ch];
                if (st)
                {
                    GUI.DrawTextureWithTexCoords(r, st.texture, st.textureRect);
                }
            }
            EditorGUILayout.EndHorizontal();
            //EditorGUILayout.GetControlRect(GUILayout.Height(Mathf.Max(r.height - 18, 36)));
            if (EditorGUI.EndChangeCheck())
            {
                return(TEXPreference.CharToHash(font, ch));
            }
            else
            {
                return(hash);
            }
        }
        else
        {
            return(-1);
        }
    }
Esempio n. 7
0
    protected override void OnEnable()
    {
        if (!preference)
        {
            TEXPreference.Initialize();
        }

        FixCanvas(canvas);
        base.OnEnable();
        m_TextDirty = true;
        UpdateSupplements();
        Font.textureRebuilt += TextureRebuilted;
    }
Esempio n. 8
0
    static void CreateCustomGameObject(MenuCommand menuCommand)
    {
        TEXPreference.Initialize();
        // Create a custom game object
        GameObject go = new GameObject("TEXDraw 3D");

        go.AddComponent <TEXDraw3D>();
        // Ensure it gets reparented if this was a context click (otherwise does nothing)
        GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
        // Register the creation in the undo system
        Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
        Selection.activeObject = go;
    }
Esempio n. 9
0
    void OnEnable()
    {
        if (!preference)
        {
            TEXPreference.Initialize();
        }

        Font.textureRebuilt += OnFontRebuild;
        if (!mesh)
        {
            mesh      = new Mesh();
            mesh.name = assetID;
        }
        Redraw();
        Repaint();
    }
Esempio n. 10
0
    public static void ClearDefaultTemplates()
    {
        TEXPreference.Initialize();

        if (!EditorUtility.DisplayDialog("Confirm clear Template",
                                         "This action will clear every TEXDraw template you made in this project.\n(You actually can do this manually via the root of TEXDraw folder)\n(Can't be undone)", "OK", "Cancel"))
        {
            return;
        }
        var files = AssetDatabase.FindAssets("Template-", new string[] { TEXPreference.main.MainFolderPath });

        foreach (var guid in files)
        {
            AssetDatabase.DeleteAsset(AssetDatabase.GUIDToAssetPath(guid));
        }
    }
Esempio n. 11
0
    protected virtual void FillMesh(Mesh m)
    {
        if (pref == null)
        {
            pref = TEXPreference.main;
        }

        #if UNITY_EDITOR
        if (pref.editorReloading)
        {
            return;
        }
        #endif

        CheckTextDirty();
        drawingContext.Render(m, cacheParam);
    }
Esempio n. 12
0
    static void CreateTEXDraw(MenuCommand menuCommand)
    {
        TEXPreference.Initialize();
        var        prefab = AssetDatabase.LoadAssetAtPath <GameObject>(TEXPreference.main.MainFolderPath + "/Template-TEXDraw.prefab");
        GameObject go;

        if (!prefab)
        {
            go = new GameObject("TEXDraw");
            go.AddComponent <TEXDraw>();
        }
        else
        {
            go      = GameObject.Instantiate(prefab);
            go.name = "TEXDraw";
        }
        PlaceUIElementRoot(go, menuCommand);
    }
Esempio n. 13
0
    // -----------------------------------------------------------------------------------------------------

    static TEXEditorMenus()
    {
        TEXSupplementEditor.isHelpShown = EditorPrefs.GetBool("TEXDraw_ShowTipOnSupplement", true);
        if (EditorPrefs.GetBool("TEXDraw_WillProceedTMP", false))
        {
            EditorApplication.delayCall += delegate()
            {
                TEXPreferenceEditor.willFocusOnImport = true;
                TEXPreference.Initialize();
                Selection.activeObject = TEXPreference.main;
#if TEXDRAW_TMP
                TexTMPImporter.onRenderingBatch = 2;
                TexTMPImporter.DoBatchRendering();
#endif
                EditorPrefs.DeleteKey("TEXDraw_WillProceedTMP");
            };
        }
    }
Esempio n. 14
0
 void OnEnable()
 {
     if (!TEXPreference.main)
     {
         TEXPreference.main = pref;             //Assign the Preference to main stack
     }
     else if (!pref)
     {
         pref = TEXPreference.main;             //This component may added runtimely
     }
     Font.textureRebuilt += OnFontRebuild;
     if (!mesh)
     {
         mesh      = new Mesh();
         mesh.name = assetID;
     }
     Redraw();
     Repaint();
 }
Esempio n. 15
0
    void OnEnable()
    {
        if (!pref)
        {
            pref = TEXPreference.main;
            if (!pref)
            {
                Debug.LogWarning("A TEXDraw 3D Component hasn't the preference yet");
            }
        }

        Font.textureRebuilt += OnFontRebuild;
        if (!mesh)
        {
            mesh      = new Mesh();
            mesh.name = assetID;
        }
        Redraw();
        Repaint();
    }
Esempio n. 16
0
 public static void SelectDefaultMaterial()
 {
     TEXPreference.Initialize();
     Selection.activeObject = TEXPreference.main.defaultMaterial;
 }
Esempio n. 17
0
 protected override void Reset()
 {
     pref = TEXPreference.main;
 }
Esempio n. 18
0
 public static void RepaintTEXDraws()
 {
     TEXPreference.Initialize();
     TEXPreference.main.CallRedraw();
 }
Esempio n. 19
0
 public static void ImportMaterial()
 {
     TEXPreference.Initialize();
     TEXPreference.main.RebuildMaterial();
 }
Esempio n. 20
0
 public static void ImportPreference()
 {
     TEXPreference.Initialize();
     TEXPreference.main.Reload();
 }
Esempio n. 21
0
 public void PickPreferenceAsset()
 {
     pref = TEXPreference.main;
 }
Esempio n. 22
0
    // Root of all GUI instruction begin here.
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        if (!targetPreference)
        {
            targetPreference = TEXPreference.main;
            if (selectedFont != null)
            {
                SetPreviewFont(selectedFont.asset);
            }
        }
        RecordUndo();
        DrawHeaderOption();
        if (headerActive == 0)
        {
            Rect v = EditorGUILayout.GetControlRect(GUILayout.Height(5));
            EditorGUILayout.BeginHorizontal(GUILayout.ExpandHeight(true));
            {
                EditorGUILayout.BeginVertical(GUILayout.Width(EditorGUIUtility.labelWidth));

                EditorGUILayout.BeginHorizontal();
                for (int i = 0; i < 3; i++)
                {
                    if (GUILayout.Toggle(i == managerState, Styles.ManagerHeaderContent[i], Styles.ManagerHeader[i]))
                    {
                        managerState = i;
                    }
                }
                EditorGUILayout.EndHorizontal();
                EditorGUIUtility.labelWidth /= 2;
                if (managerState == 0)
                {
                    DrawManager();
                }
                else if (managerState == 1)
                {
                    DrawImporter();
                }
                else if (managerState == 2)
                {
                    DrawSetter();
                }
                EditorGUIUtility.labelWidth *= 2;
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUI.indentLevel = 0;
            EditorGUILayout.Separator();
            if (selectedAsset != null)
            {
                v.xMin  += EditorGUIUtility.labelWidth + 4;
                v.height = Screen.height - ViewerHeight;
                CheckEvent(false);
                switch (selectedAsset.type)
                {
                case TexAssetType.Font:
                    DrawViewerFont(v);
                    break;

                case TexAssetType.Sprite:
                    DrawViewerSprite(v);
                    break;

                case TexAssetType.FontSigned:
                    DrawViewerSigned(v);
                    break;
                }
            }
        }
        else if (headerActive == 1)
        {
            DrawConfiguration();
        }
        else if (headerActive == 2)
        {
            DrawMaterial();
        }
        else if (headerActive == 3)
        {
            DrawGlue();
        }

        serializedObject.ApplyModifiedProperties();
    }
Esempio n. 23
0
 public static void OpenPreference()
 {
     TEXPreference.Initialize();
     Selection.activeObject = TEXPreference.main;
 }
Esempio n. 24
0
 void Reset()
 {
     pref = TEXPreference.main;
     GetComponent <MeshRenderer>().material = pref.defaultMaterial;
 }