public void OnEnable()
    {
        TextRecoAbstractBehaviour target = (TextRecoAbstractBehaviour)base.target;

        if ((QCARUtilities.GetPrefabType(target) != PrefabType.Prefab) && !SceneManager.Instance.SceneInitialized)
        {
            SceneManager.Instance.InitScene();
        }
    }
    public void OnSceneGUI()
    {
        TextRecoAbstractBehaviour target = (TextRecoAbstractBehaviour)base.target;
        GUIStyle style2 = new GUIStyle {
            alignment = TextAnchor.LowerRight,
            fontSize  = 0x12
        };

        style2.normal.textColor = Color.white;
        GUIStyle style = style2;

        Handles.Label(target.transform.position, "Text\nRecognition", style);
    }
Пример #3
0
 public static void EditorConfigureTarget(TextRecoAbstractBehaviour trb)
 {
     if (trb == null)
     {
         Debug.LogError("TextRecoAbstractBehaviour parameter is null !");
         return;
     }
     if (VuforiaUtilities.GetPrefabType(trb) == PrefabType.Prefab)
     {
         return;
     }
     if (!SceneManager.Instance.SceneInitialized)
     {
         SceneManager.Instance.InitScene();
     }
 }
    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);
        }
    }
Пример #5
0
 private void OnLevelWasLoaded()
 {
     if (this.mKeepARCameraAlive)
     {
         List <TrackableBehaviour> list;
         StateManagerImpl          stateManager = (StateManagerImpl)TrackerManager.Instance.GetStateManager();
         if (this.mKeepTrackableBehavioursAlive)
         {
             list = stateManager.GetTrackableBehaviours().ToList <TrackableBehaviour>();
             foreach (WordAbstractBehaviour behaviour in stateManager.GetWordManager().GetTrackableBehaviours())
             {
                 list.Add(behaviour);
             }
         }
         else
         {
             list = new List <TrackableBehaviour>();
         }
         foreach (ILoadLevelEventHandler handler in this.mHandlers)
         {
             handler.OnLevelLoaded(list);
         }
         TrackableBehaviour[] behaviourArray = (TrackableBehaviour[])UnityEngine.Object.FindObjectsOfType(typeof(TrackableBehaviour));
         stateManager.RemoveDestroyedTrackables();
         stateManager.AssociateMarkerBehaviours();
         ImageTracker tracker = TrackerManager.Instance.GetTracker <ImageTracker>();
         if (tracker != null)
         {
             IEnumerable <DataSet> dataSets = tracker.GetDataSets();
             List <DataSet>        list2    = tracker.GetActiveDataSets().ToList <DataSet>();
             foreach (DataSet set in dataSets)
             {
                 if (list2.Contains(set))
                 {
                     tracker.DeactivateDataSet(set);
                 }
                 stateManager.AssociateTrackableBehavioursForDataSet(set);
                 if (list2.Contains(set))
                 {
                     tracker.ActivateDataSet(set);
                 }
             }
         }
         bool flag = false;
         TextRecoAbstractBehaviour behaviour2 = (TextRecoAbstractBehaviour)UnityEngine.Object.FindObjectOfType(typeof(TextRecoAbstractBehaviour));
         if (behaviour2 != null)
         {
             if (!behaviour2.IsInitialized)
             {
                 flag = true;
             }
             else
             {
                 WordManagerImpl wordManager = (WordManagerImpl)stateManager.GetWordManager();
                 wordManager.RemoveDestroyedTrackables();
                 wordManager.InitializeWordBehaviourTemplates();
             }
         }
         List <TrackableBehaviour>           disabledTrackables  = new List <TrackableBehaviour>();
         IEnumerable <TrackableBehaviour>    trackableBehaviours = stateManager.GetTrackableBehaviours();
         IEnumerable <WordAbstractBehaviour> source = stateManager.GetWordManager().GetTrackableBehaviours();
         foreach (TrackableBehaviour behaviour3 in behaviourArray)
         {
             if (behaviour3 is WordAbstractBehaviour)
             {
                 if (!flag && !source.Contains <WordAbstractBehaviour>((behaviour3 as WordAbstractBehaviour)))
                 {
                     behaviour3.gameObject.SetActive(false);
                     disabledTrackables.Add(behaviour3);
                 }
             }
             else if ((!(behaviour3 is ImageTargetAbstractBehaviour) || (((IEditorImageTargetBehaviour)behaviour3).ImageTargetType == ImageTargetType.PREDEFINED)) && !trackableBehaviours.Contains <TrackableBehaviour>(behaviour3))
             {
                 behaviour3.gameObject.SetActive(false);
                 disabledTrackables.Add(behaviour3);
             }
         }
         foreach (ILoadLevelEventHandler handler2 in this.mHandlers)
         {
             handler2.OnDuplicateTrackablesDisabled(disabledTrackables);
         }
     }
 }