// Draws a custom UI for the cloud reco behaviour inspector public override void OnInspectorGUI() { TextRecoBehaviour crb = (TextRecoBehaviour)target; IEditorTextRecoBehaviour etrb = (IEditorTextRecoBehaviour)target; EditorGUILayout.HelpBox("The list of words the TextTracker can detect and track.\n" + "The word list is loaded from a binary file and can be extended by a list of custom words.", MessageType.Info); //select word list from all lst-files. if none is found, show link to AR-page var textConfig = ConfigDataManager.Instance.GetTextConfigData(); if (textConfig.NumDictionaries > 1) { var wordListNames = new string[textConfig.NumDictionaries]; var wordListFiles = new string[textConfig.NumDictionaries]; textConfig.CopyDictionaryNamesAndFiles(wordListNames, wordListFiles, 0); var currentIdx = QCARUtilities.GetIndexFromString(etrb.WordListFile, wordListFiles); if (currentIdx < 0) { currentIdx = 0; } var idx = EditorGUILayout.Popup("Word List", currentIdx, wordListNames); etrb.WordListFile = wordListFiles[idx]; if (idx == 0) { GUI.enabled = false; } } else { if (GUILayout.Button("No word list available. \nPlease copy it from the TextRecognition sample app. \n" + "Press here to go to the download page for sample apps!")) { SceneManager.Instance.GoToSampleAppPage(); } GUI.enabled = false; } var numTxtFiles = textConfig.NumWordLists; var txtFileNames = new string[numTxtFiles]; var txtFiles = new string[numTxtFiles]; textConfig.CopyWordListNamesAndFiles(txtFileNames, txtFiles, 0); //select custom word list file from one of the found text-files var customWordListIndex = QCARUtilities.GetIndexFromString(etrb.CustomWordListFile, txtFiles); if (customWordListIndex < 0) { customWordListIndex = 0; } var newCustomWordListIndex = EditorGUILayout.Popup("Additional Word File", customWordListIndex, txtFileNames); if (newCustomWordListIndex != customWordListIndex) { //test if file is valid when other than default word list is selected //for better convenience let the developer select an invalid file, but show an error if (newCustomWordListIndex != 0) { TestValidityOfWordListFile(txtFiles[newCustomWordListIndex]); } etrb.CustomWordListFile = txtFiles[newCustomWordListIndex]; } //define additional custom words EditorGUILayout.LabelField("Additional Words:"); EditorGUILayout.HelpBox("Write one word per line. Open compound words can be specified using whitespaces.", MessageType.None); etrb.AdditionalCustomWords = EditorGUILayout.TextArea(etrb.AdditionalCustomWords); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.HelpBox("The filter list allows to specify subset of words that will be detected and tracked.", MessageType.Info); //Edit filter mode by selecting one of the enum-values var filterModeNames = new [] { "NONE", "BLACK_LIST", "WHITE_LIST" }; var filterModeValues = new List <WordFilterMode> { WordFilterMode.NONE, WordFilterMode.BLACK_LIST, WordFilterMode.WHITE_LIST }; var filterModeIndex = filterModeValues.IndexOf(etrb.FilterMode); filterModeIndex = EditorGUILayout.Popup("Filter Mode", filterModeIndex, filterModeNames); etrb.FilterMode = filterModeValues[filterModeIndex]; //do not show editor for filter words when FilterMode is set to NONE if (etrb.FilterMode != WordFilterMode.NONE) { //Select filter list file from one of the detected text-files var filterListIndex = QCARUtilities.GetIndexFromString(etrb.FilterListFile, txtFiles); if (filterListIndex < 0) { filterListIndex = 0; } var newFilterListIndex = EditorGUILayout.Popup("Filter List File", filterListIndex, txtFileNames); if (newFilterListIndex != filterListIndex) { //test if file is valid when other than default word list is selected //for better convenience let the developer select an invalid file, but show an error if (newFilterListIndex != 0) { TestValidityOfWordListFile(txtFiles[newFilterListIndex]); } etrb.FilterListFile = txtFiles[newFilterListIndex]; } //Define additional filter words EditorGUILayout.LabelField("Additional Filter Words:"); EditorGUILayout.HelpBox("Write one word per line. Open compound words can be specified using whitespaces.", MessageType.None); etrb.AdditionalFilterWords = EditorGUILayout.TextArea(etrb.AdditionalFilterWords); } EditorGUILayout.HelpBox("It is possible to use Word Prefabs to define augmentations for detected words. " + "Each Word Prefab can be instantiated up to a maximum number.", MessageType.Info); //Define how word prefabs are used at runtime var duplicatePrefabs = EditorGUILayout.Toggle("Use Word Prefabs", etrb.WordPrefabCreationMode == WordPrefabCreationMode.DUPLICATE); if (duplicatePrefabs) { etrb.WordPrefabCreationMode = WordPrefabCreationMode.DUPLICATE; etrb.MaximumWordInstances = EditorGUILayout.IntField("Max Simultaneous Words", etrb.MaximumWordInstances); } else { etrb.WordPrefabCreationMode = WordPrefabCreationMode.NONE; } GUI.enabled = true; if (GUI.changed) { EditorUtility.SetDirty(crb); } }
public override void OnInspectorGUI() { TextRecoAbstractBehaviour target = (TextRecoAbstractBehaviour)base.target; IEditorTextRecoBehaviour behaviour2 = (IEditorTextRecoBehaviour)base.target; EditorGUILayout.HelpBox("The list of words the TextTracker can detect and track.\nThe word list is loaded from a binary file and can be extended by a list of custom words.", MessageType.Info); TextConfigData textConfigData = ConfigDataManager.Instance.GetTextConfigData(); if (textConfigData.NumDictionaries > 1) { string[] strArray = new string[textConfigData.NumDictionaries]; string[] strArray2 = new string[textConfigData.NumDictionaries]; textConfigData.CopyDictionaryNamesAndFiles(strArray, strArray2, 0); int num = QCARUtilities.GetIndexFromString(behaviour2.WordListFile, strArray2); if (num < 0) { num = 0; } int num2 = EditorGUILayout.Popup("Word List", num, strArray, new GUILayoutOption[0]); behaviour2.WordListFile = strArray2[num2]; if (num2 == 0) { GUI.enabled = false; } } else { if (GUILayout.Button("No word list available. \nPlease copy it from the TextRecognition sample app. \nPress here to go to the download page for sample apps!", new GUILayoutOption[0])) { SceneManager.Instance.GoToSampleAppPage(); } GUI.enabled = false; } int numWordLists = textConfigData.NumWordLists; string[] namesArray = new string[numWordLists]; string[] filesArray = new string[numWordLists]; textConfigData.CopyWordListNamesAndFiles(namesArray, filesArray, 0); int indexFromString = QCARUtilities.GetIndexFromString(behaviour2.CustomWordListFile, filesArray); if (indexFromString < 0) { indexFromString = 0; } int index = EditorGUILayout.Popup("Additional Word File", indexFromString, namesArray, new GUILayoutOption[0]); if (index != indexFromString) { if (index != 0) { TestValidityOfWordListFile(filesArray[index]); } behaviour2.CustomWordListFile = filesArray[index]; } EditorGUILayout.LabelField("Additional Words:", new GUILayoutOption[0]); EditorGUILayout.HelpBox("Write one word per line. Open compound words can be specified using whitespaces.", MessageType.None); behaviour2.AdditionalCustomWords = EditorGUILayout.TextArea(behaviour2.AdditionalCustomWords, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.HelpBox("The filter list allows to specify subset of words that will be detected and tracked.", MessageType.Info); string[] displayedOptions = new string[] { "NONE", "BLACK_LIST", "WHITE_LIST" }; List <WordFilterMode> list = new List <WordFilterMode> { WordFilterMode.NONE, WordFilterMode.BLACK_LIST, WordFilterMode.WHITE_LIST }; int selectedIndex = list.IndexOf(behaviour2.FilterMode); selectedIndex = EditorGUILayout.Popup("Filter Mode", selectedIndex, displayedOptions, new GUILayoutOption[0]); behaviour2.FilterMode = list[selectedIndex]; if (behaviour2.FilterMode != WordFilterMode.NONE) { int num7 = QCARUtilities.GetIndexFromString(behaviour2.FilterListFile, filesArray); if (num7 < 0) { num7 = 0; } int num8 = EditorGUILayout.Popup("Filter List File", num7, namesArray, new GUILayoutOption[0]); if (num8 != num7) { if (num8 != 0) { TestValidityOfWordListFile(filesArray[num8]); } behaviour2.FilterListFile = filesArray[num8]; } EditorGUILayout.LabelField("Additional Filter Words:", new GUILayoutOption[0]); EditorGUILayout.HelpBox("Write one word per line. Open compound words can be specified using whitespaces.", MessageType.None); behaviour2.AdditionalFilterWords = EditorGUILayout.TextArea(behaviour2.AdditionalFilterWords, new GUILayoutOption[0]); } EditorGUILayout.HelpBox("It is possible to use Word Prefabs to define augmentations for detected words. Each Word Prefab can be instantiated up to a maximum number.", MessageType.Info); if (EditorGUILayout.Toggle("Use Word Prefabs", behaviour2.WordPrefabCreationMode == WordPrefabCreationMode.DUPLICATE, new GUILayoutOption[0])) { behaviour2.WordPrefabCreationMode = WordPrefabCreationMode.DUPLICATE; behaviour2.MaximumWordInstances = EditorGUILayout.IntField("Max Simultaneous Words", behaviour2.MaximumWordInstances, new GUILayoutOption[0]); } else { behaviour2.WordPrefabCreationMode = WordPrefabCreationMode.NONE; } GUI.enabled = true; if (GUI.changed) { EditorUtility.SetDirty(target); } }