Exemple #1
0
    public void RaycastAndUpdatePanel()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            //If new asset Selected, refresh panel and assign new selected object
            if (selectedAsset != hit.transform.gameObject)
            {
                gameObject.SetActive(false);
                gameObject.SetActive(true);
            }
            selectedAsset = hit.transform.gameObject;
            //Activate Panel
            canvas.enabled = true;

            ////////////////////////////////////
            /// Update Properties of Panel/////
            /// ////////////////////////////////

            //Update Data
            nameText.text = selectedAsset.name;

            //Check if Synced Asset
            SyncedAsset sa = selectedAsset.GetComponent <SyncedAsset>();
            if (sa != null)
            {
                if (!sa.sa_alwaysStatic)
                {
                    movementButtons.gameObject.SetActive(true);
                }

                //Check if RTLS
                DisplayRTLS();
            }
            else
            {
                movementButtons.gameObject.SetActive(false);
                addRTLSPanel.SetActive(false);
            }

            //Check if Asset has Telemetry

            DisplayTelemetry();


            //Check if Zones
            DisplayZoneInfo();

            //Size Panel
            updatePanelsLayout();
        }
        //No asset selected
        else
        {
            canvas.enabled = false;
            addTelemetryPanel.SetActive(false);
        }
    }
 public void DeleteAsset(GameObject asset)
 {
     if (asset != null)
     {
         SyncedAsset sa = asset.GetComponent <SyncedAsset>();
         if (sa != null)
         {
             db.deleteAsset(sa._id, sa._rev);
         }
         Destroy(asset);
     }
     else
     {
         Debug.Log("Asset was null");
     }
 }
    public void OnTakePictureHandler()
    {
        //CancelInvoke("CheckCameraRotation");
        Debug.Log(_camTexture.width.ToString() + " " + _camTexture.height.ToString());
        cameraPicture = new Texture2D(_camTexture.width, _camTexture.height, TextureFormat.ARGB32, false);
        cameraPicture.SetPixels(_camTexture.GetPixels());
        cameraPicture.Apply();
        cameraPhotoPlaceholder.texture = cameraPicture;
        takePicturePanel.SetActive(false);
        _camTexture.Stop();
        byte[] bytes       = cameraPicture.EncodeToPNG();
        string newImageURL = synchedHazard.name + SyncedAsset.GetUTCTimeStamp() + ".png";

        synchedHazard.sa_imageURL.Add(newImageURL);
        StartCoroutine(ObjectStorageAPI.main.saveImage(bytes, newImageURL));
    }
    private void placeAsset(AssetType assetType)
    {
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        //If Keyboard place P, if touch screen press screen
        if ((Input.GetKeyDown("p")) || (((Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began)) && !EventSystem.current.IsPointerOverGameObject()))
        {
            if (Input.touchCount == 1)
            {
                drawerActive = false;
            }
            Debug.Log("p is pressed");
            if (Physics.Raycast(ray, out hit, 100.0f))
            {
                Debug.Log("Raycast hit, place Asset: " + assetType.ToString());
                GameObject resource = Resources.Load <GameObject>("AssetsLibrary/" + assetType.ToString());
                if (resource == null)
                {
                    Debug.Log("Missing Resource of type: " + assetType.ToString());
                }
                else
                {
                    GameObject go = (GameObject)Instantiate(resource, new Vector3(hit.point.x, hit.point.y, hit.point.z), Quaternion.Euler(0, 0, 0));
                    //Update SynchedAsset
                    SyncedAsset sa = go.GetComponent <SyncedAsset>();
                    if (sa == null)
                    {
                        Debug.Log("Resource Missing SyncedAsset");
                    }
                    else
                    {
                        sa.sa_type      = assetType.ToString();
                        sa.sa_createdBy = UserSettings.main.userName;
                    }

                    go.name = assetType.ToString();

                    //Return cursor to default
                    Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);

                    AddToTree(go, assetType);
                }
            }
        }
    }