예제 #1
0
    private void OnMatchOrCreateRequest(RequestLauncher.RequestAnswerDocument item, bool success)
    {
        if (success && String.IsNullOrEmpty(item.Error))
        {
            CameraFrame frame        = item.CameraFrameFromBase64();
            Texture2D   croppedPhoto = new Texture2D(frame.Resolution.width, frame.Resolution.height);
            croppedPhoto.SetPixels32(frame.Data);
            croppedPhoto.Apply();

            DocumentCollection.Instance.AddDocument(croppedPhoto, item.Id);
            DocumentProperties received = DocumentCollection.Instance.Documents[DocumentCollection.Instance.Documents.Count - 1].GetComponent <DocumentManager>().Properties;
            received.Author      = item.Author;
            received.Description = item.Desc;
            received.Label       = item.Label;

            Debug.Log("ici");
            if (item.Link != null) // we are in a link, we need to see if the link localy exists
            {
                Debug.Log("ici");
                List <GameObject> docs = DocumentCollection.Instance.Documents;

                foreach (string id in item.Link)
                {
                    foreach (GameObject doc in docs)
                    {
                        DocumentProperties prop = doc.GetComponent <DocumentManager>().Properties;
                        if (prop != null && id == prop.Id)
                        {
                            if (prop.LinkId != -1)
                            {
                                Debug.Log("la");
                                LinkManager.Instance.Links[prop.LinkId].Add(doc);
                                doc.GetComponent <DocumentManager>().SetColor(LinkManager.Instance.Links[prop.LinkId].LinkColor);
                            }
                            else if (docs[docs.Count - 1] != doc)
                            {
                                Debug.Log("bloup");
                                LinkManager.Instance.OnLinkStarted(doc);
                                LinkManager.Instance.OnLinkEnded(docs[docs.Count - 1], false);
                            }

                            goto EndOfLoop;
                        }
                    }
                }
                EndOfLoop :;
            }
        }
        else
        {
            Debug.Log(item.Error);
            Debug.Log("nop");
            this.photoMode = true;
        }
    }
예제 #2
0
 // TODO: Implement this function
 private void OnUpdateDocument(RequestLauncher.RequestAnswerDocument item, bool success)
 {
     if (String.IsNullOrEmpty(item.Error))
     {
         this.Properties = new DocumentProperties(this.Properties)
         {
             Label       = item.Label,
             Description = item.Desc,
             Author      = item.Author,
         };
     }
 }
예제 #3
0
 private void OnUpdatePhotoRequest(RequestLauncher.RequestAnswerDocument item, bool success)
 {
     if (String.IsNullOrEmpty(item.Error))
     {
         if (item.Image != null)
         {
             CameraFrame frame        = item.CameraFrameFromBase64();
             Texture2D   croppedPhoto = new Texture2D(frame.Resolution.width, frame.Resolution.height);
             croppedPhoto.SetPixels32(frame.Data);
             croppedPhoto.Apply();
             document.GetComponent <DocumentManager>().SetPhoto(croppedPhoto);
             DocumentCollection.Instance.Toggle();
             DocumentCollection.Instance.SetFocusedDocument(document);
         }
     }
     else
     {
         Debug.Log(item.Error);
         Debug.Log("nop");
         this.photoMode = true;
     }
     updatingDocument = false;
 }