public static bool Render(JCubemapRendererArgs args) { GameObject go = new GameObject("~CubemapRendererCamera"); go.transform.position = args.CameraPosition; Camera cam = go.AddComponent <Camera>(); cam.clearFlags = args.CameraClearFlag; cam.nearClipPlane = args.CameraNearPlane; cam.farClipPlane = args.CameraFarPlane; cam.backgroundColor = args.CameraBackgroundColor; bool result = cam.RenderToCubemap(args.Cubemap, (int)args.Face); JUtilities.DestroyGameobject(go); return(result); }
private void Export() { JUtilities.EnsureDirectoryExists(Directory); Cubemap cube = new Cubemap(Resolution, TextureFormat.ARGB32, false); JCubemapRendererArgs args = new JCubemapRendererArgs() { CameraPosition = this.CameraPosition, CameraNearPlane = this.CameraNearPlane, CameraFarPlane = this.CameraFarPlane, CameraClearFlag = this.CameraClearFlag, CameraBackgroundColor = this.CameraBackgroundColor, Resolution = this.Resolution, Cubemap = cube, Face = (CubemapFace)63 }; JCubemapRenderer.Render(args); string fileName = Path.Combine(Directory, "Cubemap-" + JCommon.GetUniqueID() + ".cubemap"); AssetDatabase.CreateAsset(cube, fileName); if (ExportFaceTextures) { ExportFace(cube, CubemapFace.PositiveX); ExportFace(cube, CubemapFace.NegativeX); ExportFace(cube, CubemapFace.PositiveY); ExportFace(cube, CubemapFace.NegativeY); ExportFace(cube, CubemapFace.PositiveZ); ExportFace(cube, CubemapFace.NegativeZ); } AssetDatabase.Refresh(); EditorGUIUtility.PingObject(cube); Selection.activeObject = cube; }