private static void AddVirtualButton(ImageTargetBehaviour it, ConfigData.VirtualButtonData vb) { IEditorVirtualButtonBehaviour newVBBehaviour = it.CreateVirtualButton(vb.name, new Vector2(0.0f, 0.0f), new Vector2(1.0f, 1.0f)); if (newVBBehaviour != null) { newVBBehaviour.SetPosAndScaleFromButtonArea( new Vector2(vb.rectangle[0], vb.rectangle[1]), new Vector2(vb.rectangle[2], vb.rectangle[3])); VirtualButtonEditor.CreateVBMesh(newVBBehaviour); // Load default material. VirtualButtonEditor.CreateMaterial(newVBBehaviour); newVBBehaviour.enabled = vb.enabled; // Add Component to destroy VirtualButton meshes at runtime. newVBBehaviour.gameObject.AddComponent <TurnOffBehaviour>(); // Make sure Virtual Button is correctly aligned with Image Target newVBBehaviour.UpdatePose(); } else { Debug.LogError("VirtualButton could not be added!"); } }
public void EditorUpdate() { TrackableBehaviour[] trackables = (TrackableBehaviour[])UnityEngine.Object.FindObjectsOfType(typeof(TrackableBehaviour)); VirtualButtonAbstractBehaviour[] vbs = (VirtualButtonAbstractBehaviour[])UnityEngine.Object.FindObjectsOfType(typeof(VirtualButtonAbstractBehaviour)); this.CorrectTrackableScales(trackables); VirtualButtonEditor.CorrectPoses(vbs); if (this.mDoDeserialization) { ConfigDataManager.Instance.DoRead(); DataSetLoadEditor.OnConfigDataChanged(); this.ApplyDataSetAppearance(); this.mDoDeserialization = false; } if (this.mApplyAppearance) { this.UpdateTrackableAppearance(trackables); this.mApplyAppearance = false; } if (this.mApplyProperties) { this.UpdateTrackableProperties(trackables); this.mApplyProperties = false; } if (this.mDoSerialization) { ConfigData configData = this.CreateDataSetFromTrackables(trackables); if (!ConfigParser.Instance.structToFile(this.mDataSetExportPath, configData)) { UnityEngine.Debug.LogError("Export of scene file failed."); } this.mDoSerialization = false; } if (this.mValidateScene) { this.CheckForDuplicates(trackables); WordEditor.CheckForDuplicates(); VirtualButtonEditor.Validate(); this.mValidateScene = false; } if (this.mGoToTargetManagerPage) { this.mGoToTargetManagerPage = false; Process.Start("https://developer.vuforia.com/target-manager"); } if (this.mGoToSampleAppPage) { this.mGoToSampleAppPage = false; Process.Start("https://developer.vuforia.com/resources/sample-apps"); } if (this.mLastUpdate.Add(UPDATE_INTERVAL) < DateTime.Now) { SetUnityVersion(); this.mLastUpdate = DateTime.Now; } }
private static void AddVirtualButton(ImageTargetAbstractBehaviour it, ConfigData.VirtualButtonData vb) { IEditorVirtualButtonBehaviour behaviour = it.CreateVirtualButton(vb.name, new Vector2(0f, 0f), new Vector2(1f, 1f)); if (behaviour != null) { behaviour.SetPosAndScaleFromButtonArea(new Vector2(vb.rectangle[0], vb.rectangle[1]), new Vector2(vb.rectangle[2], vb.rectangle[3])); VirtualButtonEditor.CreateVBMesh(behaviour); VirtualButtonEditor.CreateMaterial(behaviour); behaviour.enabled = vb.enabled; BehaviourComponentFactory.Instance.AddTurnOffBehaviour(behaviour.gameObject); behaviour.UpdatePose(); } else { Debug.LogError("VirtualButton could not be added!"); } }
// Update method triggered by Unity. // Used to check scene content changes. // Be aware that this update callback only is called once a SceneManager // instance has been created. // Be aware that the instance is destroyed if the SceneManager file is // recompiled. public void EditorUpdate() { TrackableBehaviour[] trackables = (TrackableBehaviour[])UnityEngine.Object.FindObjectsOfType( typeof(TrackableBehaviour)); VirtualButtonBehaviour[] virtualButtons = (VirtualButtonBehaviour[])UnityEngine.Object.FindObjectsOfType( typeof(VirtualButtonBehaviour)); // Correct scales of Trackables. CorrectTrackableScales(trackables); // Correct Virtual Button poses. VirtualButtonEditor.CorrectPoses(virtualButtons); // We do deserialization and serialization in this order to avoid // overwriting the config.xml file. if (mDoDeserialization) { ConfigDataManager.Instance.DoRead(); DataSetLoadEditor.OnConfigDataChanged(); ApplyDataSetAppearance(); mDoDeserialization = false; } if (mApplyAppearance) { // We apply the newly read values to the scene. UpdateTrackableAppearance(trackables); mApplyAppearance = false; } if (mApplyProperties) { // We apply the newly read values to the scene. UpdateTrackableProperties(trackables); mApplyProperties = false; } if (mDoSerialization) { ConfigData sceneData = CreateDataSetFromTrackables(trackables); if (!ConfigParser.Instance.structToFile(mDataSetExportPath, sceneData)) { Debug.LogError("Export of scene file failed."); } mDoSerialization = false; } if (mValidateScene) { // Check if there are duplicate trackables in the scene. CheckForDuplicates(trackables); // Check if there are trackables from different data sets in the scene. CheckDataSets(trackables); // Validate all Virtual Buttons in the scene. VirtualButtonEditor.Validate(); mValidateScene = false; } if (mGoToARPage) { mGoToARPage = false; System.Diagnostics.Process.Start( "https://ar.qualcomm.com/qdevnet/projects"); } }
// Update method triggered by Unity. // Used to check scene content changes. // Be aware that this update callback only is called once a SceneManager // instance has been created. // Be aware that the instance is destroyed if the SceneManager file is // recompiled. public void EditorUpdate() { TrackableBehaviour[] trackables = (TrackableBehaviour[])UnityEngine.Object.FindObjectsOfType( typeof(TrackableBehaviour)); VirtualButtonBehaviour[] virtualButtons = (VirtualButtonBehaviour[])UnityEngine.Object.FindObjectsOfType( typeof(VirtualButtonBehaviour)); // Correct scales of Trackables. CorrectTrackableScales(trackables); // Correct Virtual Button poses. VirtualButtonEditor.CorrectPoses(virtualButtons); // We do deserialization and serialization in this order to avoid // overwriting the config.xml file. if (mDoDeserialization) { ConfigDataManager.Instance.DoRead(); DataSetLoadEditor.OnConfigDataChanged(); ApplyDataSetAppearance(); mDoDeserialization = false; } if (mApplyAppearance) { // We apply the newly read values to the scene. UpdateTrackableAppearance(trackables); mApplyAppearance = false; } if (mApplyProperties) { // We apply the newly read values to the scene. UpdateTrackableProperties(trackables); mApplyProperties = false; } if (mDoSerialization) { ConfigData sceneData = CreateDataSetFromTrackables(trackables); if (!ConfigParser.Instance.structToFile(mDataSetExportPath, sceneData)) { Debug.LogError("Export of scene file failed."); } mDoSerialization = false; } if (mValidateScene) { // Check if there are duplicate trackables in the scene. CheckForDuplicates(trackables); //check for duplicate word trackables in the scene WordEditor.CheckForDuplicates(); // Validate all Virtual Buttons in the scene. VirtualButtonEditor.Validate(); mValidateScene = false; } if (mGoToTargetManagerPage) { mGoToTargetManagerPage = false; System.Diagnostics.Process.Start( "https://developer.vuforia.com/target-manager"); } if (mGoToSampleAppPage) { mGoToSampleAppPage = false; System.Diagnostics.Process.Start( "https://developer.vuforia.com/resources/sample-apps"); } if (mLastUpdate.Add(UPDATE_INTERVAL) < DateTime.Now) { SetUnityVersion(); mLastUpdate = DateTime.Now; } }