Beispiel #1
0
        private static readonly string[] _dontIncludeMe = new string[] { "m_Script", "OnTrackerFound", "OnTrackerLost" };       //, "OnMarkerlessTrackingGained", "OnMarkerlessTrackingLost" };

        public void Awake()
        {
            TrackedObject to = target as TrackedObject;

            if (File.Exists(Path.Combine(TEXTURE_PATH, to.targetName)))
            {
                TrackedObjectEditor.UpdateMesh(to);
                TrackedObjectEditor.UpdateMaterial(to);
                TrackedObjectEditor.UpdateScale(to);
            }
        }
Beispiel #2
0
        private static void ConfigureInspector(TrackedObject to)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.TextField("Image File", to.targetName);
            if (GUILayout.Button("...", new GUILayoutOption[] { GUILayout.Width(25) }))
            {
                if (TrackedObjectEditor.BrowseAndLoadTexture(to))
                {
                    TrackedObjectEditor.UpdateMesh(to);
                    TrackedObjectEditor.UpdateMaterial(to);
                    TrackedObjectEditor.UpdateScale(to);
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();

            EditorGUILayout.BeginHorizontal();
            if (to.previewImage == null)
            {
                GUILayout.Label("No Preview\n Available", new GUILayoutOption[] {
                    GUILayout.Height(Screen.width / 4),
                    GUILayout.Width(Screen.width / 4)
                });
            }
            else
            {
                GUILayout.Label(to.previewImage, new GUILayoutOption[] {
                    GUILayout.Height(Screen.width / 10),
                    GUILayout.Width(Screen.width / 10)
                });
                EditorGUILayout.BeginVertical();
                float rwWidth = EditorGUILayout.FloatField("Physical Width (m)", to.WidthInMeters, new GUILayoutOption[0]);
                to.HeightInMeters = (rwWidth / to.previewImage.width) * to.previewImage.height;
                float rwHeight = EditorGUILayout.FloatField("Physical Height (m)", to.HeightInMeters, new GUILayoutOption[0]);

                EditorGUILayout.BeginHorizontal();
                if (Application.isPlaying)
                {
                    string status = to.IsVisible ? "Status: Tracking" : "Status: Not Tracking";
                    EditorGUILayout.LabelField(status, new GUILayoutOption[] { GUILayout.Width(115) });
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();

                //if width is updated in the inspector, adjust the height and update mesh
                if (rwWidth != to.WidthInMeters)
                {
                    to.WidthInMeters  = rwWidth;
                    rwHeight          = (rwWidth / to.previewImage.width) * to.previewImage.height;
                    to.HeightInMeters = rwHeight;
                    TrackedObjectEditor.UpdateMesh(to);
                    TrackedObjectEditor.UpdateMaterial(to);
                    TrackedObjectEditor.UpdateScale(to);
                }

                //if height is updated in the inpector, adjust the width and update mesh
                if (rwHeight != to.HeightInMeters)
                {
                    to.HeightInMeters = rwHeight;
                    rwWidth           = (rwHeight / to.previewImage.height) * to.previewImage.width;
                    to.WidthInMeters  = rwWidth;
                    TrackedObjectEditor.UpdateMesh(to);
                    TrackedObjectEditor.UpdateMaterial(to);
                    TrackedObjectEditor.UpdateScale(to);
                }
            }
            EditorGUILayout.EndHorizontal();
        }