Exemplo n.º 1
0
    public void CallPostTarget()
    {
        if (texture == null)
        {
            Debug.Log("Empty image!");
            return;
        }

        if (VerifyUpload() == false)
        {
            return;
        }

        postUploadButton.interactable = false;
        uploadButton.interactable     = false;
        PrintStatusText("Uploading...");

        targetName = nameField.text;

        // Generate list of ProfileData.
        ProfileDataList profileDatas = GenerateDataFromFields();

        // Convert to json to transfer data as metadata
        jsonData = JsonUtility.ToJson(profileDatas);
        print(jsonData);

        StartCoroutine(PostNewTarget());
    }
Exemplo n.º 2
0
    public void HandleTargetFinderResult(Vuforia.TargetFinder.CloudRecoSearchResult targetSearchResult)
    {
        Debug.Log("<color=blue>HandleTargetFinderResult(): " + targetSearchResult.TargetName + "</color>");
        CloudUploading.currentImageData = targetSearchResult;

        if (targetSearchResult.MetaData.Length > 0)
        {
            ProfileDataList profileDataList = JsonUtility.FromJson <ProfileDataList>(targetSearchResult.MetaData);

            cloudTargetInfo.text =
                "Name: " + profileDataList.profileDatasArray[0].value +
                "\nAge: " + profileDataList.profileDatasArray[1].value +
                "\nPhone: " + profileDataList.profileDatasArray[2].value +
                "\nAddress: " + profileDataList.profileDatasArray[3].value +
                "\nIC: " + profileDataList.profileDatasArray[4].value +
                "\nOccupation: " + profileDataList.profileDatasArray[5].value +
                "\nBiography: " + profileDataList.profileDatasArray[6].value;
        }
        else
        {
            Debug.Log("Target lacks MetaData!");

            cloudTargetInfo.text =
                "Name: " + targetSearchResult.TargetName +
                "\nRating: " + starRatings[targetSearchResult.TrackingRating] +
                "\nMetaData: " + ((targetSearchResult.MetaData.Length > 0) ? targetSearchResult.MetaData : "No") +
                "\nTarget Id: " + targetSearchResult.UniqueTargetId;
        }
    }
Exemplo n.º 3
0
    private ProfileDataList GenerateDataFromFields()
    {
        // Generate list of ProfileData.
        ProfileDataList profileDatas = new ProfileDataList {
            profileDatasArray = new ProfileData[7]
        };

        // Initialize variables for list.
        ProfileData nameData = new ProfileData();

        nameData.name  = "name";
        nameData.value = nameField.text;
        profileDatas.profileDatasArray[0] = nameData;

        ProfileData ageData = new ProfileData();

        ageData.name  = "age";
        ageData.value = ageField.text;
        profileDatas.profileDatasArray[1] = ageData;

        ProfileData phoneData = new ProfileData();

        phoneData.name  = "phone";
        phoneData.value = phoneField.text;
        profileDatas.profileDatasArray[2] = phoneData;

        ProfileData addressData = new ProfileData();

        addressData.name  = "address";
        addressData.value = addressField.text;
        profileDatas.profileDatasArray[3] = addressData;

        ProfileData icData = new ProfileData();

        icData.name  = "ic";
        icData.value = icField.text;
        profileDatas.profileDatasArray[4] = icData;

        ProfileData occupationData = new ProfileData();

        occupationData.name  = "occupation";
        occupationData.value = occupationField.text;
        profileDatas.profileDatasArray[5] = occupationData;

        ProfileData biographyData = new ProfileData();

        biographyData.name  = "biography";
        biographyData.value = biographyField.text;
        profileDatas.profileDatasArray[6] = biographyData;

        return(profileDatas);
    }
Exemplo n.º 4
0
    private void SetInputFields(GameObject whichCanvas, bool clear = true)
    {
        // Get all input fields of canvas.
        InputField[] profileFields = whichCanvas.transform.GetComponentsInChildren <InputField>(false);

        nameField       = profileFields[0];
        ageField        = profileFields[1];
        phoneField      = profileFields[2];
        addressField    = profileFields[3];
        icField         = profileFields[4];
        occupationField = profileFields[5];
        biographyField  = profileFields[6];

        // nameField.text = "Van";
        // ageField.text = "18";
        // phoneField.text = "1";
        // addressField.text = "s";
        // icField.text = "24";
        // occupationField.text = "ssd";
        // biographyField.text = "ssds";

        if (clear)
        {
            nameField.text       = "";
            ageField.text        = "";
            phoneField.text      = "";
            addressField.text    = "";
            icField.text         = "";
            occupationField.text = "";
            biographyField.text  = "";
            return;
        }

        // Fill input fields using current image's metadata.
        if (currentImageData != null && currentImageData.MetaData.Length > 0)
        {
            ProfileDataList profileDataList = JsonUtility.FromJson <ProfileDataList>(currentImageData.MetaData);

            nameField.text       = profileDataList.profileDatasArray[0].value;
            ageField.text        = profileDataList.profileDatasArray[1].value;
            phoneField.text      = profileDataList.profileDatasArray[2].value;
            addressField.text    = profileDataList.profileDatasArray[3].value;
            icField.text         = profileDataList.profileDatasArray[4].value;
            occupationField.text = profileDataList.profileDatasArray[5].value;
            biographyField.text  = profileDataList.profileDatasArray[6].value;
        }
    }
Exemplo n.º 5
0
    public void CallPutTarget()
    {
        if (texture == null)
        {
            Debug.Log("Empty image!");
            return;
        }

        if (VerifyUpload() == false)
        {
            return;
        }

        // Only update target if camera quality is medium or high.
        if (userDefinedTargetHandler.m_FrameQuality != Vuforia.ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM &&
            userDefinedTargetHandler.m_FrameQuality != Vuforia.ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH)
        {
            Debug.Log("Camera frame quality: " + userDefinedTargetHandler.m_FrameQuality);
            PrintStatusText("Camera frame must be in medium or high quality!");

            return;
        }

        deleteDeleteButton.interactable = false;
        putEditButton.interactable      = false;
        editButton.interactable         = false;
        PrintStatusText("Saving...");

        targetName = nameField.text;

        // Generate list of ProfileData.
        ProfileDataList profileDatas = GenerateDataFromFields();

        // Convert to json to transfer data as metadata
        jsonData = JsonUtility.ToJson(profileDatas);

        // Update image too.
        StartCoroutine(PutUpdateTarget(true));
    }