ArabicSupportTool.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using ArabicSupport;
  2. using UnityEditor;
  3. using UnityEngine;
  4. public class ArabicSupportTool : EditorWindow
  5. {
  6. string rawText;
  7. string fixedText;
  8. bool showTashkeel = true;
  9. bool useHinduNumbers = true;
  10. // Add menu item named "Arabic Support Tool" to the Tools menu
  11. [MenuItem("Tools/Arabic Support Tool")]
  12. public static void ShowWindow()
  13. {
  14. //Show existing window instance. If one doesn't exist, make one.
  15. EditorWindow.GetWindow(typeof(ArabicSupportTool));
  16. }
  17. void OnGUI()
  18. {
  19. if (string.IsNullOrEmpty(rawText))
  20. {
  21. fixedText = "";
  22. }
  23. else
  24. {
  25. fixedText = ArabicFixer.Fix(rawText, showTashkeel, useHinduNumbers);
  26. }
  27. GUILayout.Label("Options:", EditorStyles.boldLabel);
  28. showTashkeel = EditorGUILayout.Toggle("Use Tashkeel", showTashkeel);
  29. useHinduNumbers = EditorGUILayout.Toggle("Use Hindu Numbers", useHinduNumbers);
  30. GUILayout.Label("Input (Not Fixed)", EditorStyles.boldLabel);
  31. rawText = EditorGUILayout.TextArea(rawText);
  32. GUILayout.Label("Output (Fixed)", EditorStyles.boldLabel);
  33. fixedText = EditorGUILayout.TextArea(fixedText);
  34. if (GUILayout.Button("Copy")) {
  35. var tempTextEditor = new TextEditor();
  36. tempTextEditor.text = fixedText;
  37. tempTextEditor.SelectAll();
  38. tempTextEditor.Copy();
  39. }
  40. }
  41. }