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();
     }
 }
Esempio n. 2
0
 public override void OnInspectorGUI()
 {
     base.DrawDefaultInspector();
     VuforiaUtilities.DisableGuiForPrefab(base.target);
     using (this.mSerializedObject.Edit())
     {
         EditorGUILayout.HelpBox("This is a prop template that will be duplicated at runtime for newly found smart terrain props. The DefaultSmartTerrainEventHandler will use the same template for every prop at runtime. You can implement a custom ISmartTerrainEventHandler to create a different behavior.", MessageType.Info);
         EditorGUILayout.HelpBox("The mesh filter, mesh collider and/or box collider selected below will be automatically updated with new revisions of the smart terrain prop. Set them to None to ignore updates.", MessageType.None);
         EditorGUILayout.PropertyField(this.mSerializedObject.MeshFilterToUpdateProperty, new GUIContent("MeshFilter to update"), new GUILayoutOption[0]);
         EditorGUILayout.PropertyField(this.mSerializedObject.MeshColliderToUpdateProperty, new GUIContent("MeshCollider to update"), new GUILayoutOption[0]);
         EditorGUILayout.PropertyField(this.mSerializedObject.BoxColliderToUpdateProperty, new GUIContent("BoxCollider to update"), new GUILayoutOption[0]);
     }
     if (GUI.changed)
     {
         SceneManager.Instance.SceneUpdated();
     }
 }
Esempio n. 3
0
        private List <ConfigData.MultiTargetPartData> CreateDefaultParts()
        {
            List <ConfigData.MultiTargetPartData> arg_6C_0 = new List <ConfigData.MultiTargetPartData>(6);
            float num = VuforiaUtilities.CreateDefaultImageTarget().size.x * 0.5f;

            arg_6C_0.Add(new ConfigData.MultiTargetPartData
            {
                translation = new Vector3(0f, num, 0f),
                rotation    = Quaternion.AngleAxis(0f, new Vector3(1f, 0f, 0f)),
                name        = "--- EMPTY ---"
            });
            arg_6C_0.Add(new ConfigData.MultiTargetPartData
            {
                translation = new Vector3(0f, -num, 0f),
                rotation    = Quaternion.AngleAxis(180f, new Vector3(1f, 0f, 0f)),
                name        = "--- EMPTY ---"
            });
            arg_6C_0.Add(new ConfigData.MultiTargetPartData
            {
                translation = new Vector3(-num, 0f, 0f),
                rotation    = Quaternion.AngleAxis(90f, new Vector3(0f, 0f, 1f)),
                name        = "--- EMPTY ---"
            });
            arg_6C_0.Add(new ConfigData.MultiTargetPartData
            {
                translation = new Vector3(num, 0f, 0f),
                rotation    = Quaternion.AngleAxis(-90f, new Vector3(0f, 0f, 1f)),
                name        = "--- EMPTY ---"
            });
            arg_6C_0.Add(new ConfigData.MultiTargetPartData
            {
                translation = new Vector3(0f, 0f, num),
                rotation    = Quaternion.AngleAxis(90f, new Vector3(1f, 0f, 0f)),
                name        = "--- EMPTY ---"
            });
            arg_6C_0.Add(new ConfigData.MultiTargetPartData
            {
                translation = new Vector3(0f, 0f, -num),
                rotation    = Quaternion.AngleAxis(-90f, new Vector3(1f, 0f, 0f)),
                name        = "--- EMPTY ---"
            });
            return(arg_6C_0);
        }
Esempio n. 4
0
        private static void UpdateRectangleMaterial(GameObject gameObject)
        {
            MeshRenderer meshRenderer = gameObject.GetComponent <MeshRenderer>();

            if (!meshRenderer)
            {
                meshRenderer = gameObject.AddComponent <MeshRenderer>();
            }
            Material material  = VuforiaUtilities.LoadReferenceMaterial();
            Material material2 = meshRenderer.sharedMaterial;

            if (material2 == null || material2 == material)
            {
                material2 = new Material(material);
            }
            material2.name   = "Text";
            material2.shader = Shader.Find("Unlit/Texture");
            material2.SetColor("_Color", Color.white);
            meshRenderer.sharedMaterial = material2;
        }
        private void DrawCloudRecoTargetInspectorUI(bool typeChanged)
        {
            if (typeChanged)
            {
                ConfigData.ImageTargetData imageTargetData = VuforiaUtilities.CreateDefaultImageTarget();
                this.mSerializedObject.TrackableName = string.Empty;
                ImageTargetEditor.UpdateAspectRatio(this.mSerializedObject, imageTargetData.size);
                this.mSerializedObject.SetMaterial(ImageTargetEditor.UpdateMaterial("", "", ImageTargetType.CLOUD_RECO, this.mSerializedObject.GetMaterial()));
            }
            EditorGUILayout.PropertyField(this.mSerializedObject.PreserveChildSizeProperty, new GUIContent("Preserve child size"), new GUILayoutOption[0]);
            bool expr_7B = SceneManager.Instance.SmartTerrainInitializationEnabled();

            if (expr_7B)
            {
                EditorGUILayout.HelpBox("Extended Tracking cannot be enabled at the same time as Smart Terrain.", MessageType.Info);
            }
            GUI.enabled = !expr_7B;
            EditorGUILayout.PropertyField(this.mSerializedObject.ExtendedTrackingProperty, new GUIContent("Enable Extended Tracking"), new GUILayoutOption[0]);
            GUI.enabled = true;
            SmartTerrainInitializationTargetEditorExtension.DrawInspectorForInitializationTarget(this.mSerializedObject, true);
        }
Esempio n. 6
0
        private void ReadVuMarkShape(XmlReader configReader, ref Vector4 boundingBox2D, ref Vector2 origin)
        {
            string attribute = configReader.GetAttribute("bbox2D");

            if (attribute == null || !VuforiaUtilities.RectangleFromStringArray(out boundingBox2D, attribute.Split(new char[]
            {
                ' '
            })))
            {
                Debug.LogWarning("Info parser: can't read bounding box of VuMark");
            }
            string attribute2 = configReader.GetAttribute("origin");

            if (attribute2 == null || !VuforiaUtilities.SizeFromStringArray(out origin, attribute2.Split(new char[]
            {
                ' '
            })))
            {
                Debug.LogWarning("Info parser: can't read origin of VuMark");
            }
        }
 public override void OnInspectorGUI()
 {
     base.DrawDefaultInspector();
     VuforiaUtilities.DisableGuiForPrefab(base.target);
     using (this.mSerializedObject.Edit())
     {
         ImageTargetType imageTargetType = this.mSerializedObject.ImageTargetType;
         string[]        array           = new string[]
         {
             "Predefined",
             "User Defined",
             "Cloud Reco"
         };
         ImageTargetType[] array2 = new ImageTargetType[]
         {
             ImageTargetType.PREDEFINED,
             ImageTargetType.USER_DEFINED,
             ImageTargetType.CLOUD_RECO
         };
         this.mSerializedObject.ImageTargetType = array2[EditorGUILayout.Popup("Type", array2.ToList <ImageTargetType>().IndexOf(this.mSerializedObject.ImageTargetType), array, new GUILayoutOption[0])];
         bool flag = this.mSerializedObject.ImageTargetType != imageTargetType;
         if (flag)
         {
             this.mSerializedObject.AutoSetOccluderFromTargetSize = false;
         }
         if (this.mSerializedObject.ImageTargetType == ImageTargetType.PREDEFINED)
         {
             this.DrawPredefinedTargetInspectorUI(flag);
         }
         else if (this.mSerializedObject.ImageTargetType == ImageTargetType.USER_DEFINED)
         {
             this.DrawUserDefinedTargetInspectorUI(flag);
         }
         else
         {
             this.DrawCloudRecoTargetInspectorUI(flag);
         }
     }
 }
Esempio n. 8
0
 public override void ApplyDataSetAppearance()
 {
     if (VuforiaUtilities.GetPrefabType(this.mTarget) == PrefabType.Prefab)
     {
         return;
     }
     using (this.mSerializedObject.Edit())
     {
         ConfigData.CylinderTargetData ctConfig;
         if (this.TrackableInDataSet(this.mSerializedObject.TrackableName, this.mSerializedObject.GetDataSetName()))
         {
             ConfigDataManager.Instance.GetConfigData(this.mSerializedObject.GetDataSetName()).GetCylinderTarget(this.mSerializedObject.TrackableName, out ctConfig);
         }
         else
         {
             ConfigDataManager.Instance.GetConfigData("--- EMPTY ---").GetCylinderTarget("--- EMPTY ---", out ctConfig);
             this.mSerializedObject.DataSetPath   = "--- EMPTY ---";
             this.mSerializedObject.TrackableName = "--- EMPTY ---";
         }
         CylinderTargetEditor.UpdateAspectRatio(this.mSerializedObject, ctConfig);
     }
 }
 public override void OnInspectorGUI()
 {
     base.DrawDefaultInspector();
     VuforiaUtilities.DisableGuiForPrefab(base.target);
     if (ConfigDataManager.Instance.NumConfigDataObjects > 1)
     {
         using (this.mSerializedObject.Edit())
         {
             bool flag = VuforiaUtilities.DrawDatasetTrackableInspector(this.mSerializedObject, false, new Func <ConfigData, string[]>(ObjectTargetEditor.GetTrackableNames), "Object Target");
             this.mSerializedObject.LengthProperty.FixApproximatelyEqualFloatValues();
             EditorGUILayout.PropertyField(this.mSerializedObject.LengthProperty, new GUIContent("Length"), new GUILayoutOption[0]);
             this.mSerializedObject.WidthProperty.FixApproximatelyEqualFloatValues();
             EditorGUILayout.PropertyField(this.mSerializedObject.WidthProperty, new GUIContent("Width"), new GUILayoutOption[0]);
             this.mSerializedObject.HeightProperty.FixApproximatelyEqualFloatValues();
             EditorGUILayout.PropertyField(this.mSerializedObject.HeightProperty, new GUIContent("Height"), new GUILayoutOption[0]);
             EditorGUILayout.PropertyField(this.mSerializedObject.ShowBoundingBoxProperty, new GUIContent("Show Bounding Box"), new GUILayoutOption[0]);
             VuforiaUtilities.DrawTrackableOptions(this.mSerializedObject, true, true, true);
             if (flag)
             {
                 ConfigData.ObjectTargetData objectTargetData;
                 ConfigDataManager.Instance.GetConfigData(this.mSerializedObject.GetDataSetName()).GetObjectTarget(this.mSerializedObject.TrackableName, out objectTargetData);
                 ObjectTargetEditor.UpdateAspectRatio(this.mSerializedObject, objectTargetData.size);
                 ObjectTargetEditor.UpdateBoundingBox(this.mSerializedObject, objectTargetData.bboxMin, objectTargetData.bboxMax);
                 ObjectTargetEditor.UpdateScale(this.mSerializedObject, objectTargetData.size);
                 ObjectTargetEditor.UpdatePreviewImage(this.mSerializedObject, objectTargetData.targetID);
             }
             if (this.mSerializedObject.PreviewImage)
             {
                 GUILayout.Label(this.mSerializedObject.PreviewImage, new GUILayoutOption[]
                 {
                     GUILayout.Width(512f)
                 });
             }
             return;
         }
     }
     VuforiaUtilities.DrawMissingTargetsButton();
 }
Esempio n. 10
0
 public override void ApplyDataSetProperties()
 {
     if (VuforiaUtilities.GetPrefabType(this.mTarget) == PrefabType.Prefab)
     {
         return;
     }
     using (this.mSerializedObject.Edit())
     {
         ConfigData.ObjectTargetData objectTargetData;
         if (this.TrackableInDataSet(this.mSerializedObject.TrackableName, this.mSerializedObject.GetDataSetName()))
         {
             ConfigDataManager.Instance.GetConfigData(this.mSerializedObject.GetDataSetName()).GetObjectTarget(this.mSerializedObject.TrackableName, out objectTargetData);
         }
         else
         {
             ConfigDataManager.Instance.GetConfigData("--- EMPTY ---").GetObjectTarget("--- EMPTY ---", out objectTargetData);
             this.mSerializedObject.DataSetPath   = "--- EMPTY ---";
             this.mSerializedObject.TrackableName = "--- EMPTY ---";
         }
         ObjectTargetEditor.UpdateAspectRatio(this.mSerializedObject, objectTargetData.size);
         ObjectTargetEditor.UpdateScale(this.mSerializedObject, objectTargetData.size);
     }
 }
Esempio n. 11
0
 public override void ApplyDataSetAppearance()
 {
     if (VuforiaUtilities.GetPrefabType(this.mTarget) == PrefabType.Prefab)
     {
         return;
     }
     using (this.mSerializedObject.Edit())
     {
         ConfigData.ObjectTargetData objectTargetData;
         if (this.TrackableInDataSet(this.mSerializedObject.TrackableName, this.mSerializedObject.GetDataSetName()))
         {
             ConfigDataManager.Instance.GetConfigData(this.mSerializedObject.GetDataSetName()).GetObjectTarget(this.mSerializedObject.TrackableName, out objectTargetData);
         }
         else
         {
             ConfigDataManager.Instance.GetConfigData("--- EMPTY ---").GetObjectTarget("--- EMPTY ---", out objectTargetData);
             this.mSerializedObject.DataSetPath   = "--- EMPTY ---";
             this.mSerializedObject.TrackableName = "--- EMPTY ---";
         }
         ObjectTargetEditor.UpdateBoundingBox(this.mSerializedObject, objectTargetData.bboxMin, objectTargetData.bboxMax);
         ObjectTargetEditor.UpdatePreviewImage(this.mSerializedObject, objectTargetData.targetID);
     }
 }
Esempio n. 12
0
 public static void EditorConfigureTarget(PropAbstractBehaviour prop, SerializedProp serializedObject)
 {
     if (prop == null)
     {
         Debug.LogError("PropAbstractBehaviour parameter is null !");
         return;
     }
     if (VuforiaUtilities.GetPrefabType(prop) == PrefabType.Prefab)
     {
         return;
     }
     if (!SceneManager.Instance.SceneInitialized)
     {
         SceneManager.Instance.InitScene();
     }
     using (serializedObject.Edit())
     {
         if (!EditorApplication.isPlaying)
         {
             serializedObject.InitializedInEditor = true;
         }
     }
 }
Esempio n. 13
0
 public override void ApplyDataSetProperties()
 {
     if (VuforiaUtilities.GetPrefabType(this.mTarget) == PrefabType.Prefab)
     {
         return;
     }
     using (this.mSerializedObject.Edit())
     {
         ConfigData.MultiTargetData multiTargetData;
         if (this.TrackableInDataSet(this.mSerializedObject.TrackableName, this.mSerializedObject.GetDataSetName()))
         {
             ConfigDataManager.Instance.GetConfigData(this.mSerializedObject.GetDataSetName()).GetMultiTarget(this.mSerializedObject.TrackableName, out multiTargetData);
         }
         else
         {
             ConfigDataManager.Instance.GetConfigData("--- EMPTY ---").GetMultiTarget("--- EMPTY ---", out multiTargetData);
             this.mSerializedObject.DataSetPath   = "--- EMPTY ---";
             this.mSerializedObject.TrackableName = "--- EMPTY ---";
         }
         List <ConfigData.MultiTargetPartData> parts = multiTargetData.parts;
         MultiTargetEditor.UpdateParts(this.mSerializedObject, parts.ToArray());
     }
 }
Esempio n. 14
0
 public static void EditorConfigureTarget(SurfaceAbstractBehaviour surface, SerializedSmartTerrainTrackable serializedObject)
 {
     if (surface == null)
     {
         Debug.LogError("SurfaceAbstractBehaviour parameter is null !");
         return;
     }
     if (VuforiaUtilities.GetPrefabType(surface) == PrefabType.Prefab)
     {
         return;
     }
     if (!SceneManager.Instance.SceneInitialized)
     {
         SceneManager.Instance.InitScene();
     }
     using (serializedObject.Edit())
     {
         if (!EditorApplication.isPlaying)
         {
             serializedObject.InitializedInEditor = true;
         }
     }
 }
 public static void EditorConfigureTarget(ReconstructionAbstractBehaviour rb, SerializedObject serializedObject = null)
 {
     if (rb == null)
     {
         Debug.LogError("ReconstructionAbstractBehaviour parameter is null !");
         return;
     }
     if (VuforiaUtilities.GetPrefabType(rb) == PrefabType.Prefab)
     {
         return;
     }
     if (!SceneManager.Instance.SceneInitialized)
     {
         SceneManager.Instance.InitScene();
     }
     if (serializedObject == null)
     {
         serializedObject = new SerializedObject(rb);
     }
     if (!EditorApplication.isPlaying)
     {
         serializedObject.Update();
         SerializedProperty serializedProperty = serializedObject.FindProperty("mInitializedInEditor");
         if (!serializedProperty.boolValue)
         {
             Debug.Log("Reconstruction added to scene, enabling SmartTerrainTracker");
             VuforiaAbstractConfiguration expr_6F = VuforiaAbstractConfigurationEditor.LoadConfigurationObject();
             expr_6F.SmartTerrainTracker.AutoInitAndStartTracker = true;
             expr_6F.SmartTerrainTracker.AutoInitBuilder         = true;
             using (serializedObject.Edit())
             {
                 serializedObject.FindProperty("mMaximumExtentEnabled").boolValue = false;
                 serializedProperty.boolValue = true;
             }
         }
     }
 }
 public override void OnInspectorGUI()
 {
     base.DrawDefaultInspector();
     VuforiaUtilities.DisableGuiForPrefab(base.target);
     if (ConfigDataManager.Instance.NumConfigDataObjects > 1)
     {
         using (this.mSerializedObject.Edit())
         {
             if (VuforiaUtilities.DrawDatasetTrackableInspector(this.mSerializedObject, false, new Func <ConfigData, string[]>(CylinderTargetEditor.GetTrackableNames), "Cylinder Target"))
             {
                 ConfigData.CylinderTargetData cylinderTargetData;
                 ConfigDataManager.Instance.GetConfigData(this.mSerializedObject.GetDataSetName()).GetCylinderTarget(this.mSerializedObject.TrackableName, out cylinderTargetData);
                 CylinderTargetEditor.UpdateAspectRatio(this.mSerializedObject, cylinderTargetData);
                 CylinderTargetEditor.UpdateScale(this.mSerializedObject, cylinderTargetData.sideLength);
             }
             EditorGUILayout.PropertyField(this.mSerializedObject.SideLengthProperty, new GUIContent("Side length"), new GUILayoutOption[0]);
             EditorGUILayout.PropertyField(this.mSerializedObject.TopDiameterProperty, new GUIContent("Top diameter"), new GUILayoutOption[0]);
             EditorGUILayout.PropertyField(this.mSerializedObject.BottomDiameterProperty, new GUIContent("Bottom diameter"), new GUILayoutOption[0]);
             VuforiaUtilities.DrawTrackableOptions(this.mSerializedObject, true, true, true);
             return;
         }
     }
     VuforiaUtilities.DrawMissingTargetsButton();
 }
Esempio n. 17
0
        internal static void UpdateMaterial(SerializedVuMark serializedObject)
        {
            Material material      = serializedObject.GetMaterial();
            string   previewImage  = serializedObject.PreviewImage;
            string   trackableName = serializedObject.TrackableName;
            Material material2     = VuforiaUtilities.LoadReferenceMaterial();

            if (material2 == null)
            {
                return;
            }
            Material material3 = material;

            if (material3 == null || material3 == material2)
            {
                material3 = new Material(material2);
            }
            Texture2D mainTexture = AssetDatabase.LoadAssetAtPath <Texture2D>(previewImage);

            material3.mainTexture      = mainTexture;
            material3.mainTextureScale = new Vector2(1f, 1f);
            material3.name             = trackableName + "Material";
            serializedObject.SetMaterial(material3);
        }
Esempio n. 18
0
 public override void ApplyDataSetAppearance()
 {
     if (VuforiaUtilities.GetPrefabType(this.mTarget) == PrefabType.Prefab)
     {
         return;
     }
     using (this.mSerializedObject.Edit())
     {
         ConfigData.VuMarkData vuMarkData;
         if (this.TrackableInDataSet(this.mSerializedObject.TrackableName, this.mSerializedObject.GetDataSetName()))
         {
             ConfigDataManager.Instance.GetConfigData(this.mSerializedObject.GetDataSetName()).GetVuMarkTarget(this.mSerializedObject.TrackableName, out vuMarkData);
         }
         else
         {
             ConfigDataManager.Instance.GetConfigData("--- EMPTY ---").GetVuMarkTarget("--- EMPTY ---", out vuMarkData);
             this.mSerializedObject.DataSetPath   = "--- EMPTY ---";
             this.mSerializedObject.TrackableName = "--- EMPTY ---";
         }
         VuMarkEditor.UpdateDataSetInfo(this.mSerializedObject, vuMarkData);
         VuMarkEditor.UpdateAspectRatio(this.mSerializedObject, vuMarkData.size);
         VuMarkEditor.UpdateMaterial(this.mSerializedObject);
     }
 }
        private static Material[] UpdateMaterials(string dataSetName, string trackableName, bool hasBottomGeometry, bool hasTopGeometry, bool insideMaterial, Material[] oldMaterials)
        {
            Material material = VuforiaUtilities.LoadReferenceMaterial();

            if (material == null)
            {
                return(new Material[0]);
            }
            string str = "Assets/Editor/Vuforia/CylinderTargetTextures/" + dataSetName + "/" + trackableName;

            if (!File.Exists(str + ".Body_scaled.png") && !File.Exists(str + ".Body_scaled.jpg") && !File.Exists(str + ".Body_scaled.jpeg"))
            {
                str = "Assets/Editor/QCAR/CylinderTargetTextures/" + dataSetName + "/" + trackableName;
            }
            List <string> list = new List <string>
            {
                str + ".Body_scaled"
            };

            if (hasBottomGeometry)
            {
                list.Add(str + ".Bottom_scaled");
            }
            if (hasTopGeometry)
            {
                list.Add(str + ".Top_scaled");
            }
            int count = list.Count;

            Material[] array = new Material[insideMaterial ? (count * 2) : count];
            for (int i = 0; i < list.Count; i++)
            {
                string text;
                VuforiaUtilities.GetImagePathWithExtension(list[i], out text);
                Material material2 = null;
                if (i < oldMaterials.Length)
                {
                    material2 = oldMaterials[i];
                }
                if (material2 == null || material2 == material)
                {
                    material2 = new Material(material);
                }
                Texture2D mainTexture = AssetDatabase.LoadAssetAtPath <Texture2D>(text);
                string    fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text);
                material2.mainTexture      = mainTexture;
                material2.name             = fileNameWithoutExtension + "Material";
                material2.mainTextureScale = new Vector2(-1f, -1f);
                array[i] = material2;
                if (insideMaterial)
                {
                    int      num       = i + count;
                    Material material3 = null;
                    if (num < oldMaterials.Length)
                    {
                        material3 = oldMaterials[num];
                    }
                    if (material3 == null || material3 == material)
                    {
                        material3 = new Material(material2);
                    }
                    material3.CopyPropertiesFromMaterial(material2);
                    material3.name   = material2.name + "Bright";
                    material3.shader = Shader.Find("Custom/BrightTexture");
                    array[num]       = material3;
                }
            }
            return(array);
        }
 public override void OnInspectorGUI()
 {
     VuforiaUtilities.DisableGuiForPrefab(base.target);
     base.DrawDefaultInspector();
     using (base.serializedObject.Edit())
     {
         TextConfigData textConfigData = ConfigDataManager.Instance.GetTextConfigData();
         if (textConfigData.NumDictionaries > 1)
         {
             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);
             string[] array  = new string[textConfigData.NumDictionaries];
             string[] array2 = new string[textConfigData.NumDictionaries];
             textConfigData.CopyDictionaryNamesAndFiles(array, array2, 0);
             int num = VuforiaUtilities.GetIndexFromString(this.mWordListFile.stringValue, array2);
             if (num < 0)
             {
                 num = 0;
             }
             int num2 = EditorGUILayout.Popup("Word List", num, array, new GUILayoutOption[0]);
             this.mWordListFile.stringValue = array2[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      expr_D8 = textConfigData.NumWordLists;
         string[] array3  = new string[expr_D8];
         string[] array4  = new string[expr_D8];
         textConfigData.CopyWordListNamesAndFiles(array3, array4, 0);
         int num3 = VuforiaUtilities.GetIndexFromString(this.mCustomWordListFile.stringValue, array4);
         if (num3 < 0)
         {
             num3 = 0;
         }
         int num4 = EditorGUILayout.Popup("Additional Word File", num3, array3, new GUILayoutOption[0]);
         if (num4 != num3)
         {
             if (num4 != 0)
             {
                 TextRecoEditor.TestValidityOfWordListFile(array4[num4]);
             }
             this.mCustomWordListFile.stringValue = array4[num4];
         }
         EditorGUILayout.LabelField("Additional Words:", new GUILayoutOption[0]);
         EditorGUILayout.HelpBox("Write one word per line. Open compound words can be specified using whitespaces.", MessageType.None);
         this.mAdditionalCustomWords.stringValue = EditorGUILayout.TextArea(this.mAdditionalCustomWords.stringValue, 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);
         EditorGUILayout.PropertyField(this.mFilterMode, new GUIContent("Filter Mode"), new GUILayoutOption[0]);
         if (this.mFilterMode.enumValueIndex != 0)
         {
             int num5 = VuforiaUtilities.GetIndexFromString(this.mFilterListFile.stringValue, array4);
             if (num5 < 0)
             {
                 num5 = 0;
             }
             int num6 = EditorGUILayout.Popup("Filter List File", num5, array3, new GUILayoutOption[0]);
             if (num6 != num5)
             {
                 if (num6 != 0)
                 {
                     TextRecoEditor.TestValidityOfWordListFile(array4[num6]);
                 }
                 this.mFilterListFile.stringValue = array4[num6];
             }
             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);
             this.mAdditionalFilterWords.stringValue = EditorGUILayout.TextArea(this.mAdditionalFilterWords.stringValue, 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", this.mWordPrefabCreationMode.enumValueIndex == 1, new GUILayoutOption[0]))
         {
             this.mWordPrefabCreationMode.enumValueIndex = 1;
             EditorGUILayout.PropertyField(this.mMaximumWordInstances, new GUIContent("Max Simultaneous Words"), new GUILayoutOption[0]);
         }
         else
         {
             this.mWordPrefabCreationMode.enumValueIndex = 0;
         }
     }
     GUI.enabled = true;
 }
        public static bool DrawDatasetTrackableInspector(SerializedDataSetTrackable serializedObject, bool resetTrackable, Func <ConfigData, string[]> getTrackableNamesFunc, string trackableLabel)
        {
            bool result = false;

            string[] array = new string[ConfigDataManager.Instance.NumConfigDataObjects];
            ConfigDataManager.Instance.GetConfigDataNames(array);
            int num = -1;

            if (!serializedObject.DataSetPathProperty.hasMultipleDifferentValues)
            {
                num = VuforiaUtilities.GetIndexFromString(serializedObject.GetDataSetName(), array);
                if (num < 0)
                {
                    num = 0;
                }
            }
            EditorGUI.BeginChangeCheck();
            int  num2 = EditorGUILayout.Popup("Database", num, array, new GUILayoutOption[0]);
            bool flag = EditorGUI.EndChangeCheck();

            if (resetTrackable && num2 < 0)
            {
                num2 = 0;
                flag = true;
            }
            if (num2 >= 0)
            {
                string     dataSetName = array[num2];
                ConfigData configData  = ConfigDataManager.Instance.GetConfigData(dataSetName);
                string[]   array2      = getTrackableNamesFunc(configData);
                int        num3        = -1;
                if (!serializedObject.TrackableNameProperty.hasMultipleDifferentValues)
                {
                    num3 = VuforiaUtilities.GetIndexFromString(serializedObject.TrackableName, array2);
                    if (num3 < 0)
                    {
                        num3 = 0;
                    }
                }
                if (flag)
                {
                    num3 = 0;
                }
                EditorGUI.BeginChangeCheck();
                int  num4  = EditorGUILayout.Popup(trackableLabel, num3, array2, new GUILayoutOption[0]);
                bool flag2 = EditorGUI.EndChangeCheck();
                if (array2.Length != 0 && (flag | flag2 | resetTrackable))
                {
                    result = true;
                    serializedObject.DataSetPath = "";
                    serializedObject.DataSetPath = VuforiaRuntimeUtilities.StripStreamingAssetsFromPath(ConfigDataManager.Instance.GetConfigData(array[num2]).FullPath);
                    if (num4 >= 0)
                    {
                        string trackableName = array2[num4];
                        serializedObject.TrackableName = "";
                        serializedObject.TrackableName = trackableName;
                    }
                }
            }
            else
            {
                EditorGUILayout.Popup(trackableLabel, -1, new string[0], new GUILayoutOption[0]);
            }
            return(result);
        }
Esempio n. 22
0
        public bool fileToStruct(string configXMLPath, string authoringInfoXMLPath, ConfigData configData)
        {
            if (!File.Exists(configXMLPath))
            {
                return(false);
            }
            AuthoringInfo authoringInfo;

            if (File.Exists(authoringInfoXMLPath))
            {
                authoringInfo = new AuthoringInfo(authoringInfoXMLPath);
            }
            else
            {
                authoringInfo = new AuthoringInfo();
            }
            List <ConfigData.CylinderTargetData> list  = new List <ConfigData.CylinderTargetData>();
            List <ConfigData.ObjectTargetData>   list2 = new List <ConfigData.ObjectTargetData>();

            using (XmlTextReader xmlTextReader = new XmlTextReader(configXMLPath))
            {
                while (xmlTextReader.Read())
                {
                    if (xmlTextReader.NodeType == XmlNodeType.Element)
                    {
                        string name = xmlTextReader.Name;
                        uint   num  = ComputeStringHash(name);

                        if (num <= 2826972859u)
                        {
                            if (num != 1357157938u)
                            {
                                if (num != 1777789069u)
                                {
                                    if (num == 2826972859u)
                                    {
                                        if (name == "ObjectTarget")
                                        {
                                            string attribute = xmlTextReader.GetAttribute("name");
                                            xmlTextReader.MoveToElement();
                                            list2.Add(new ConfigData.ObjectTargetData
                                            {
                                                name = attribute
                                            });
                                        }
                                    }
                                }
                                else if (name == "VuMark")
                                {
                                    string  attribute2 = xmlTextReader.GetAttribute("name");
                                    Vector2 zero       = Vector2.zero;
                                    string  attribute3 = xmlTextReader.GetAttribute("size");
                                    if (attribute3 != null)
                                    {
                                        if (!VuforiaUtilities.SizeFromStringArray(out zero, attribute3.Split(new char[]
                                        {
                                            ' '
                                        })))
                                        {
                                            Debug.LogWarning("Found illegal size attribute for VuMark Target " + attribute2 + " in config.xml. VuMark Target will be ignored.");
                                        }
                                        else
                                        {
                                            xmlTextReader.MoveToElement();
                                            ConfigData.VuMarkData item;
                                            if (!authoringInfo.TryGetInfo(attribute2, out item))
                                            {
                                                Debug.LogWarning("Couldn't find VuMark " + attribute2 + " in authoring info");
                                                Debug.LogWarning("Use device database unitypackage as downloaded from Target Manager!\nTarget is not rendered correctly in editor.");
                                            }
                                            item.name = attribute2;
                                            item.size = zero;
                                            configData.SetVuMarkTarget(item, attribute2);
                                        }
                                    }
                                    else
                                    {
                                        Debug.LogWarning("VuMark Target " + attribute2 + " is missing a size attribut in config.xml. VuMark Target will be ignored.");
                                    }
                                }
                            }
                            else if (name == "CylinderTarget")
                            {
                                string attribute4 = xmlTextReader.GetAttribute("name");
                                if (attribute4 == null)
                                {
                                    Debug.LogWarning("Found Cylinder Target without name attribute in config.xml. Cylinder Target will be ignored.");
                                }
                                else
                                {
                                    string attribute5 = xmlTextReader.GetAttribute("sideLength");
                                    float  sideLength = -1f;
                                    if (attribute5 != null)
                                    {
                                        sideLength = float.Parse(attribute5, CultureInfo.InvariantCulture);
                                    }
                                    xmlTextReader.MoveToElement();
                                    list.Add(new ConfigData.CylinderTargetData
                                    {
                                        name       = attribute4,
                                        sideLength = sideLength
                                    });
                                }
                            }
                        }
                        else if (num <= 3803554136u)
                        {
                            if (num != 3027079795u)
                            {
                                if (num == 3803554136u)
                                {
                                    if (name == "VirtualButton")
                                    {
                                        string attribute6 = xmlTextReader.GetAttribute("name");
                                        if (attribute6 == null)
                                        {
                                            Debug.LogWarning("Found VirtualButton without name attribute in config.xml. Virtual Button will be ignored.");
                                        }
                                        else
                                        {
                                            Vector4  zero2 = Vector4.zero;
                                            string[] array = xmlTextReader.GetAttribute("rectangle").Split(new char[]
                                            {
                                                ' '
                                            });
                                            if (array != null)
                                            {
                                                if (!VuforiaUtilities.RectangleFromStringArray(out zero2, array))
                                                {
                                                    Debug.LogWarning("Found invalid rectangle attribute for Virtual Button " + attribute6 + " in config.xml. Virtual Button will be ignored.");
                                                }
                                                else
                                                {
                                                    bool   enabled    = true;
                                                    string attribute7 = xmlTextReader.GetAttribute("enabled");
                                                    if (attribute7 != null)
                                                    {
                                                        if (string.Compare(attribute7, "true", true) == 0)
                                                        {
                                                            enabled = true;
                                                        }
                                                        else if (string.Compare(attribute7, "false", true) == 0)
                                                        {
                                                            enabled = false;
                                                        }
                                                        else
                                                        {
                                                            Debug.LogWarning("Found invalid enabled attribute for Virtual Button " + attribute6 + " in config.xml. Default setting will be used.");
                                                        }
                                                    }
                                                    VirtualButton.Sensitivity sensitivity = VirtualButton.Sensitivity.LOW;
                                                    string attribute8 = xmlTextReader.GetAttribute("sensitivity");
                                                    if (attribute8 != null)
                                                    {
                                                        if (string.Compare(attribute8, "low", true) == 0)
                                                        {
                                                            sensitivity = VirtualButton.Sensitivity.LOW;
                                                        }
                                                        else if (string.Compare(attribute8, "medium", true) == 0)
                                                        {
                                                            sensitivity = VirtualButton.Sensitivity.MEDIUM;
                                                        }
                                                        else if (string.Compare(attribute8, "high", true) == 0)
                                                        {
                                                            sensitivity = VirtualButton.Sensitivity.HIGH;
                                                        }
                                                        else
                                                        {
                                                            Debug.LogWarning("Found illegal sensitivity attribute for Virtual Button " + attribute6 + " in config.xml. Default setting will be used.");
                                                        }
                                                    }
                                                    xmlTextReader.MoveToElement();
                                                    ConfigData.VirtualButtonData item2 = default(ConfigData.VirtualButtonData);
                                                    string latestITName = ConfigParser.GetLatestITName(configData);
                                                    item2.name        = attribute6;
                                                    item2.rectangle   = zero2;
                                                    item2.enabled     = enabled;
                                                    item2.sensitivity = sensitivity;
                                                    if (configData.ImageTargetExists(latestITName))
                                                    {
                                                        configData.AddVirtualButton(item2, latestITName);
                                                    }
                                                    else
                                                    {
                                                        Debug.LogWarning(string.Concat(new string[]
                                                        {
                                                            "Image Target with name ",
                                                            latestITName,
                                                            " could not be found. Virtual Button ",
                                                            attribute6,
                                                            "will not be added."
                                                        }));
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                Debug.LogWarning("Virtual Button " + attribute6 + " has no rectangle attribute in config.xml. Virtual Button will be ignored.");
                                            }
                                        }
                                    }
                                }
                            }
                            else if (name == "MultiTarget")
                            {
                                string attribute9 = xmlTextReader.GetAttribute("name");
                                if (attribute9 == null)
                                {
                                    Debug.LogWarning("Found Multi Target without name attribute in config.xml. Multi Target will be ignored.");
                                }
                                else
                                {
                                    xmlTextReader.MoveToElement();
                                    configData.SetMultiTarget(new ConfigData.MultiTargetData
                                    {
                                        parts = new List <ConfigData.MultiTargetPartData>()
                                    }, attribute9);
                                }
                            }
                        }
                        else if (num != 3814285364u)
                        {
                            if (num == 4124202875u)
                            {
                                if (name == "ImageTarget")
                                {
                                    string attribute10 = xmlTextReader.GetAttribute("name");
                                    if (attribute10 == null)
                                    {
                                        Debug.LogWarning("Found ImageTarget without name attribute in config.xml. Image Target will be ignored.");
                                    }
                                    else
                                    {
                                        Vector2  zero3  = Vector2.zero;
                                        string[] array2 = xmlTextReader.GetAttribute("size").Split(new char[]
                                        {
                                            ' '
                                        });
                                        if (array2 != null)
                                        {
                                            if (!VuforiaUtilities.SizeFromStringArray(out zero3, array2))
                                            {
                                                Debug.LogWarning("Found illegal itSize attribute for Image Target " + attribute10 + " in config.xml. Image Target will be ignored.");
                                            }
                                            else
                                            {
                                                xmlTextReader.MoveToElement();
                                                configData.SetImageTarget(new ConfigData.ImageTargetData
                                                {
                                                    size           = zero3,
                                                    virtualButtons = new List <ConfigData.VirtualButtonData>()
                                                }, attribute10);
                                            }
                                        }
                                        else
                                        {
                                            Debug.LogWarning("Image Target " + attribute10 + " is missing a itSize attribut in config.xml. Image Target will be ignored.");
                                        }
                                    }
                                }
                            }
                        }
                        else if (name == "Part")
                        {
                            string attribute11 = xmlTextReader.GetAttribute("name");
                            if (attribute11 == null)
                            {
                                Debug.LogWarning("Found Multi Target Part without name attribute in config.xml. Part will be ignored.");
                            }
                            else
                            {
                                Vector3  zero4  = Vector3.zero;
                                string[] array3 = xmlTextReader.GetAttribute("translation").Split(new char[]
                                {
                                    ' '
                                });
                                if (array3 != null)
                                {
                                    if (!VuforiaUtilities.TransformFromStringArray(out zero4, array3))
                                    {
                                        Debug.LogWarning("Found illegal transform attribute for Part " + attribute11 + " in config.xml. Part will be ignored.");
                                    }
                                    else
                                    {
                                        Quaternion quaternion  = Quaternion.identity;
                                        string     attribute12 = xmlTextReader.GetAttribute("rotation");
                                        if (attribute12 == null)
                                        {
                                            Debug.LogWarning("Multi Target Part " + attribute11 + " has no rotation attribute in config.xml. Part will be ignored.");
                                        }
                                        else
                                        {
                                            string[] array4 = attribute12.Split(new char[]
                                            {
                                                ';'
                                            });
                                            string str = "";
                                            if (array4.Length != 0)
                                            {
                                                str = array4[0].Split(new char[]
                                                {
                                                    ' '
                                                })[0];
                                            }
                                            for (int i = 0; i < array4.Length; i++)
                                            {
                                                string text = array4[i];
                                                if (i != 0)
                                                {
                                                    text = str + " " + text.Trim();
                                                }
                                                Quaternion quaternion2 = this.parseQuaternionFromAttrString(text);
                                                quaternion *= quaternion2;
                                            }
                                            xmlTextReader.MoveToElement();
                                            ConfigData.MultiTargetPartData item3 = default(ConfigData.MultiTargetPartData);
                                            string latestMTName = ConfigParser.GetLatestMTName(configData);
                                            item3.name        = attribute11;
                                            item3.rotation    = quaternion;
                                            item3.translation = zero4;
                                            if (configData.MultiTargetExists(latestMTName))
                                            {
                                                configData.AddMultiTargetPart(item3, latestMTName);
                                            }
                                            else
                                            {
                                                Debug.LogWarning(string.Concat(new string[]
                                                {
                                                    "Multi Target with name ",
                                                    latestMTName,
                                                    " could not be found. Multi Target Part ",
                                                    attribute11,
                                                    "will not be added."
                                                }));
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    Debug.LogWarning("Multi Target Part " + attribute11 + " has no translation attribute in config.xml. Part will be ignored.");
                                }
                            }
                        }
                    }
                }
            }
            if (list.Count > 0)
            {
                string arg_796_0 = configXMLPath.Substring(0, configXMLPath.Length - 3) + "dat";
                ConfigData.CylinderTargetData[] array5 = list.ToArray();
                CylinderDatasetReader.Read(arg_796_0, array5);
                ConfigData.CylinderTargetData[] array6 = array5;
                for (int j = 0; j < array6.Length; j++)
                {
                    ConfigData.CylinderTargetData cylinderTargetData = array6[j];
                    configData.SetCylinderTarget(cylinderTargetData, cylinderTargetData.name);
                }
            }
            if (list2.Count > 0)
            {
                ConfigData.ObjectTargetData[] array7 = list2.ToArray();
                string[] array8 = configXMLPath.Split(new char[]
                {
                    '/'
                });
                string text2 = array8[(array8.Length - 1 > 0) ? (array8.Length - 1) : 0];
                int    num2  = 4;
                if (text2.Contains("_OT"))
                {
                    num2 += 3;
                }
                string text3 = "Assets/Editor/Vuforia/TargetsetData/" + text2.Substring(0, text2.Length - num2) + "_info.xml";
                string text4 = "Assets/Editor/QCAR/TargetsetData/" + text2.Substring(0, text2.Length - num2) + "_info.xml";
                if (File.Exists(text3))
                {
                    ObjectEditorConfigurationReader.Read(text3, array7);
                }
                else if (File.Exists(text4))
                {
                    ObjectEditorConfigurationReader.Read(text4, array7);
                }
                else
                {
                    Debug.LogError("No editor configuration file available for " + text2 + " (Only use unity dataset package generated from the Vuforia developer portal)");
                    for (int k = 0; k < array7.Length; k++)
                    {
                        array7[k].targetID = "";
                        array7[k].bboxMin  = new Vector3(0f, 0f, 0f);
                        array7[k].bboxMax  = new Vector3(200f, 200f, 200f);
                        array7[k].size     = new Vector3(200f, 200f, 200f);
                    }
                }
                for (int l = 0; l < array7.Length; l++)
                {
                    configData.SetObjectTarget(array7[l], array7[l].name);
                }
            }
            return(true);
        }