コード例 #1
0
    /// <summary>
    /// Generates a NPOT 6x1 cubemap in the following format PX NX PY NY PZ NZ
    /// </summary>
    void GenerateTexture(Cubemap cubemap, string pathName)
    {
        // Encode the texture and save it to disk
        pathName = pathName.Replace(".cubemap", (textureFormat == TexFormat.PNG) ? ".png" : ".jpg").ToLower();
        pathName = pathName.Replace(cubeMapFolder.ToLower(), "");
        string format   = textureFormat.ToString();
        string fullPath = EditorUtility.SaveFilePanel(string.Format("Save Cubemap Screenshot as {0}", format), "", pathName, format.ToLower());

        if (!string.IsNullOrEmpty(fullPath))
        {
            Debug.Log("Saving: " + fullPath);
            OVRCubemapCapture.SaveCubemapCapture(cubemap, fullPath);
        }
    }
コード例 #2
0
    public static void TriggerCubemapCapture(Vector3 capturePos, int cubemapSize = 2048, string pathName = null)
    {
        GameObject gameObject = new GameObject("CubemapCamera", new Type[]
        {
            typeof(Camera)
        });

        gameObject.hideFlags          = HideFlags.HideAndDontSave;
        gameObject.transform.position = capturePos;
        gameObject.transform.rotation = Quaternion.identity;
        Camera component = gameObject.GetComponent <Camera>();

        component.farClipPlane = 10000f;
        component.enabled      = false;
        Cubemap cubemap = new Cubemap(cubemapSize, TextureFormat.RGB24, false);

        OVRCubemapCapture.RenderIntoCubemap(component, cubemap);
        OVRCubemapCapture.SaveCubemapCapture(cubemap, pathName);
        UnityEngine.Object.DestroyImmediate(cubemap);
        UnityEngine.Object.DestroyImmediate(gameObject);
    }