Esempio n. 1
0
        public void OnEnable()
        {
            MultiTargetAbstractBehaviour arg_22_0 = (MultiTargetAbstractBehaviour)base.target;

            this.mSerializedObject = new SerializedMultiTarget(base.serializedObject);
            MultiTargetEditor.EditorConfigureTarget(arg_22_0, this.mSerializedObject);
        }
Esempio n. 2
0
 public static void EditorConfigureTarget(MultiTargetAbstractBehaviour mtb, SerializedMultiTarget serializedObject)
 {
     if (mtb == null)
     {
         Debug.LogError("MultiTargetAbstractBehaviour parameter is null !");
         return;
     }
     if (VuforiaUtilities.GetPrefabType(mtb) == PrefabType.Prefab)
     {
         return;
     }
     if (!SceneManager.Instance.SceneInitialized)
     {
         SceneManager.Instance.InitScene();
     }
     using (serializedObject.Edit())
     {
         if (!serializedObject.InitializedInEditor && !EditorApplication.isPlaying)
         {
             ConfigData.MultiTargetData multiTargetData;
             ConfigDataManager.Instance.GetConfigData("--- EMPTY ---").GetMultiTarget("--- EMPTY ---", out multiTargetData);
             serializedObject.DataSetPath   = "--- EMPTY ---";
             serializedObject.TrackableName = "--- EMPTY ---";
             List <ConfigData.MultiTargetPartData> parts = multiTargetData.parts;
             MultiTargetEditor.UpdateParts(serializedObject, parts.ToArray());
             serializedObject.InitializedInEditor = true;
         }
         else if (!EditorApplication.isPlaying)
         {
             MultiTargetEditor.CheckMesh(mtb);
         }
     }
 }
Esempio n. 3
0
 internal static void UpdateParts(SerializedMultiTarget serializedObject, ConfigData.MultiTargetPartData[] prtConfigs)
 {
     foreach (MultiTargetAbstractBehaviour current in serializedObject.GetBehaviours())
     {
         Transform transform = current.transform.Find("ChildTargets");
         if (transform == null)
         {
             GameObject expr_38 = new GameObject();
             expr_38.name             = "ChildTargets";
             expr_38.transform.parent = current.transform;
             transform = expr_38.transform;
         }
         transform.localPosition = Vector3.zero;
         transform.localRotation = Quaternion.identity;
         transform.localScale    = Vector3.one;
         Material   maskMaterial = AssetDatabase.LoadAssetAtPath <Material>("Assets/Vuforia/Materials/DepthMask.mat");
         ConfigData configData   = ConfigDataManager.Instance.GetConfigData(serializedObject.GetDataSetName());
         if (configData == null)
         {
             Debug.LogError("Could not update Multi Target parts. A data set with the given name does not exist.");
             UnityEngine.Object.DestroyImmediate(transform);
         }
         else
         {
             if (MultiTargetEditor.mPlaneMesh == null)
             {
                 Mesh mesh = new Mesh();
                 mesh.vertices = new Vector3[]
                 {
                     new Vector3(-0.5f, 0f, -0.5f),
                     new Vector3(-0.5f, 0f, 0.5f),
                     new Vector3(0.5f, 0f, -0.5f),
                     new Vector3(0.5f, 0f, 0.5f)
                 };
                 mesh.uv = new Vector2[]
                 {
                     new Vector2(1f, 1f),
                     new Vector2(1f, 0f),
                     new Vector2(0f, 1f),
                     new Vector2(0f, 0f)
                 };
                 mesh.normals   = new Vector3[4];
                 mesh.triangles = new int[]
                 {
                     0,
                     1,
                     2,
                     2,
                     1,
                     3
                 };
                 MultiTargetEditor.mPlaneMesh = mesh;
                 MultiTargetEditor.mPlaneMesh.RecalculateNormals();
             }
             List <GameObject> list = new List <GameObject>();
             for (int i = 0; i < transform.childCount; i++)
             {
                 list.Add(transform.GetChild(i).gameObject);
             }
             int num = prtConfigs.Length;
             for (int j = 0; j < num; j++)
             {
                 if (!configData.ImageTargetExists(prtConfigs[j].name))
                 {
                     Debug.LogError("No Image Target named " + prtConfigs[j].name);
                 }
                 else
                 {
                     ConfigData.ImageTargetData imageTargetData;
                     configData.GetImageTarget(prtConfigs[j].name, out imageTargetData);
                     GameObject gameObject = null;
                     if (list.Count > 0)
                     {
                         gameObject = list[0];
                         list.RemoveAt(0);
                         if (gameObject.GetComponent <MeshRenderer>() == null || gameObject.GetComponent <MeshFilter>() == null || gameObject.GetComponent <MaskOutAbstractBehaviour>() == null)
                         {
                             UnityEngine.Object.DestroyImmediate(gameObject);
                             gameObject = null;
                         }
                     }
                     if (gameObject == null)
                     {
                         gameObject = new GameObject();
                         gameObject.AddComponent <MeshRenderer>();
                         gameObject.AddComponent <MeshFilter>().sharedMesh = MultiTargetEditor.mPlaneMesh;
                         gameObject.transform.parent = transform.transform;
                         MaskOutAbstractBehaviour maskOutAbstractBehaviour = BehaviourComponentFactory.Instance.AddMaskOutBehaviour(gameObject);
                         if (maskOutAbstractBehaviour != null)
                         {
                             maskOutAbstractBehaviour.maskMaterial = maskMaterial;
                         }
                     }
                     gameObject.name = prtConfigs[j].name;
                     Vector2 size       = imageTargetData.size;
                     Vector3 localScale = new Vector3(size.x, 1f, size.y);
                     gameObject.transform.localPosition = prtConfigs[j].translation;
                     gameObject.transform.localRotation = prtConfigs[j].rotation;
                     gameObject.transform.localScale    = localScale;
                     MultiTargetEditor.UpdateMaterial(serializedObject.GetDataSetName(), gameObject);
                 }
             }
             using (List <GameObject> .Enumerator enumerator2 = list.GetEnumerator())
             {
                 while (enumerator2.MoveNext())
                 {
                     UnityEngine.Object.DestroyImmediate(enumerator2.Current);
                 }
             }
         }
     }
 }
Esempio n. 4
0
 public MultiTargetAccessor(MultiTargetAbstractBehaviour target)
 {
     this.mTarget           = target;
     this.mSerializedObject = new SerializedMultiTarget(new SerializedObject(this.mTarget));
 }