Exemplo n.º 1
0
        void FitCamera()
        {
            if (currentObjectType == 0)
            {
                mainCam.transform.position = new Vector3(15, 52, 13);
                mainCam.transform.rotation = Quaternion.Euler(0, 0, 0);
            }
            else
            {
                transform.rotation = Quaternion.Euler(0, 0, 0);
                Bounds  itemBounds     = currentItem.GetComponent <BoxCollider>().bounds; //prefabList[currIndex].GetComponent<BoxCollider>().bounds;
                float   cameraDistance = (currentObjectType == 1) ? 5.0f : 1f;            // Constant factor
                Vector3 objectSizes    = itemBounds.max - itemBounds.min;
                float   objectSize     = Mathf.Max(objectSizes.x, objectSizes.y, objectSizes.z);
                float   cameraView     = 2.0f * Mathf.Tan(0.5f * Mathf.Deg2Rad * mainCam.gameObject.GetComponent <Camera>().fieldOfView); // Visible height 1 meter in front
                float   distance       = cameraDistance * objectSize / cameraView;                                                        // Combined wanted distance from the object
                distance += 0.5f * objectSize;                                                                                            // Estimated offset from the center to the outside of the object
                mainCam.gameObject.transform.position = currentItem.transform.position - distance * mainCam.transform.forward;            //itemBounds.center - distance * mainCam.transform.forward;
            }
            StoreItem temp = storeData.data[currIndex];

            objectTitle.transform.GetChild(0).GetComponent <TMPro.TextMeshProUGUI>().text = (temp.type == "accessory") ? temp.name.Split('-')[1] : temp.name;
            price.transform.GetChild(0).GetComponent <Text>().text = "$" + temp.price;
        }