Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icosa integration #710

Draft
wants to merge 125 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
11cd2a7
API wrapper (autogenerated)
andybak Nov 1, 2023
a4b5a87
Initial WIP Icosa auth
andybak Nov 1, 2023
37bf5a5
Updated API wrapper
andybak Nov 6, 2023
a7cc5c8
Add Icosa to accounts prefab
andybak Nov 6, 2023
54a59f5
Update IcosaService.cs
andybak Nov 6, 2023
1838374
Icosa UI for accounts panel
andybak Nov 6, 2023
e0bb481
Working device login
andybak Nov 8, 2023
d49b332
rename a bunch of Poly things to Icosa in preperation for getting upl…
andybak Nov 9, 2023
74f21c5
Disable Poly Asset component for now
andybak Nov 9, 2023
ab61c67
Fix for double triggering of key events. Login keyboard switches off …
andybak Nov 9, 2023
d3cf40c
Comment is no longer true - we used a separate codepath for Icosa tokens
andybak Nov 9, 2023
217cd0c
Fixes for Icosa login
andybak Nov 9, 2023
2d1c238
Improved name/photo handling
andybak Nov 13, 2023
5f9c6b4
Remove an assert now we have more than one upload service
andybak Nov 14, 2023
e864cc3
Small refactor
andybak Nov 14, 2023
23675d4
Method is no longer static
andybak Nov 14, 2023
9bee419
Uploads to Icosa (WIP pending backend changes to accept zip files)
andybak Nov 14, 2023
7230154
Fix temp API url
andybak Nov 15, 2023
cfb1b14
Minor cleanup
andybak Nov 15, 2023
2214964
Fix for monoscopic mode
andybak Nov 15, 2023
b8e5eee
Allow real keyboard input while keyboard popups are open
andybak Nov 15, 2023
7f021d8
Merge remote-tracking branch 'upstream/main' into feature/icosa-integ…
andybak Nov 23, 2023
0220e49
Merge remote-tracking branch 'upstream/main' into feature/icosa-integ…
andybak Dec 5, 2023
17505ff
Merge remote-tracking branch 'upstream/main' into feature/icosa-integ…
andybak Dec 7, 2023
75f0c2c
Merge remote-tracking branch 'upstream/main' into feature/icosa-integ…
andybak Dec 7, 2023
efff2ab
Merge remote-tracking branch 'upstream/main' into feature/icosa-integ…
andybak Dec 20, 2023
6e39b39
Merge remote-tracking branch 'upstream/main' into feature/icosa-integ…
andybak Jan 1, 2024
21562dc
Merge remote-tracking branch 'origin/main' into feature/icosa-integra…
andybak Feb 28, 2024
871eeae
Merge remote-tracking branch 'upstream/main' into feature/icosa-integ…
andybak Mar 5, 2024
8f82aa0
Merge remote-tracking branch 'upstream/main' into feature/icosa-integ…
andybak Apr 3, 2024
3ed97a0
dotnet-format
andybak Apr 3, 2024
95fcdaa
Merge remote-tracking branch 'upstream/main' into feature/icosa-integ…
andybak Apr 7, 2024
4233cda
Merge remote-tracking branch 'upstream/main' into feature/icosa-integ…
andybak Apr 27, 2024
01845d2
Merge remote-tracking branch 'origin/main' into feature/icosa-integra…
andybak May 1, 2024
79e1f10
Merge remote-tracking branch 'origin/main' into feature/icosa-integra…
andybak May 2, 2024
848f864
Merge remote-tracking branch 'origin/main' into feature/icosa-integra…
andybak May 3, 2024
6d40d65
Merge branch 'main' into feature/icosa-integration
andybak May 19, 2024
b42acd6
Merge branch 'main' into feature/icosa-integration
andybak May 22, 2024
47f745d
Doh. Send the access token not the userId
andybak May 22, 2024
3eda3c6
Clean up some Icosa code
andybak May 22, 2024
1dee775
Store the upload_job id in the response
andybak May 22, 2024
264606f
Use the current sketch name as the upload name if it's valid
andybak May 22, 2024
8bad587
Unused code
andybak May 22, 2024
6b661e3
Include thumbnail in the zip
andybak May 22, 2024
28299ac
Icosa login, logout and upload API endpoints
andybak May 24, 2024
efd7f2c
Use the new GLTF exporter for editor environment exports
andybak May 26, 2024
a061a33
Helpful comments
andybak May 28, 2024
038aa4f
Cube map rendering editor utility
andybak May 28, 2024
2042cb6
Optional environment export
andybak May 28, 2024
80fafec
Editor utility to export environments as GLB
andybak May 28, 2024
437f4c5
"Save as" API endpoint
andybak May 29, 2024
d456a35
Environment metadata for new GLTF exports
andybak May 29, 2024
df6a67f
Pose metadata for legacy GLTF export
andybak May 29, 2024
269fad0
Merge branch 'main' into feature/icosa-integration
andybak May 29, 2024
604f995
Fix upload naming issues. Include extras in uploaded gltf
andybak May 29, 2024
21068e2
Allow non-runtime gltf export without needing to disable our plugin
andybak May 30, 2024
16c7e3c
Add the scene metadata needed for gltf files to recreate lights
andybak Jun 2, 2024
a60ede9
WIP implementation of sketchbook and poly panel API integration
andybak Jun 10, 2024
3d8fb2f
Create cameras and animation clips for GLTF export (WIP)
andybak Jun 15, 2024
0ad431e
Switch to official UnityGLTF repo
andybak Jun 17, 2024
9e11bf9
Update UnityGLTFSettings.asset
andybak Jun 17, 2024
c0aa661
Move GLTF export standin handling to prefab. Stub out sky export logic
andybak Jun 17, 2024
55c03ce
Missing user config entry
andybak Jun 17, 2024
d0c39b3
Unused import
andybak Jun 17, 2024
4ec1567
Move camera path export logic to the export plugin
andybak Jun 18, 2024
28abbd1
"Camera Path" mode for the spectator cam. (via HTTP API only for now)
andybak Jun 20, 2024
d65cdac
ShouldNodeExport method (needs custom fork of UnityGLTF)
andybak Jun 20, 2024
e5c46a8
Set alphamode and doublesided based on brush manifest.
andybak Jun 30, 2024
09bd471
switch to our fork of UnityGLTF
andybak Jun 30, 2024
6c7f2bc
Bool check was inverted
andybak Jun 30, 2024
69ce46a
Give ConcaveHull it's own copy of the MatteHull material to ease matc…
andybak Jun 30, 2024
194fe2a
manifest and alpha mode logic for new GLTF export
andybak Jun 30, 2024
f7233f6
Can't exclude BaseBrushScript gameobjects if we want to support unbat…
andybak Jun 30, 2024
b2f54b0
API Brush json was included invalid brushes and name matching was buggy
andybak Jul 1, 2024
a1419c3
Revert "Give ConcaveHull it's own copy of the MatteHull material to e…
andybak Jul 1, 2024
8fb9df3
Merge branch 'main' into feature/icosa-integration
andybak Jul 7, 2024
b8cdc01
Updated urls
andybak Jul 10, 2024
d530368
Fix assets api url. remove useless property
andybak Jul 10, 2024
d7112ac
Editor utility to ease testing of logged in actions
andybak Jul 11, 2024
14baac5
Unused method
andybak Jul 11, 2024
ba2d85d
Allow unauthenticated logins
andybak Jul 11, 2024
2f39e33
Use Icosa icon instead of Poly
andybak Jul 11, 2024
fe41fd4
Fixes and changes for Icosa API integration
andybak Jul 12, 2024
7c8911c
Handle weird situations where we init API too early.
andybak Jul 12, 2024
20a4952
Icosa model loading is working finally
andybak Jul 13, 2024
3bcfd28
Fix login base urls and make Icosa urls overrideable
andybak Jul 14, 2024
c7cbd64
Minor changes
andybak Jul 14, 2024
be018e2
Unbreak Google login
andybak Jul 14, 2024
292bce3
Redundant default param
andybak Jul 14, 2024
7cc4890
Google login enum. Remove redundant code
andybak Jul 14, 2024
bcd668e
Fix monoscopic reticle bounds
andybak Jul 14, 2024
45557e7
Remove formerly serialized attributes
andybak Jul 14, 2024
c26aeb3
Allow breaking apart on icosa models
andybak Jul 14, 2024
8f85801
Fix error when breaking up icosa models
andybak Jul 14, 2024
35df610
Use "blocks" pseudo-format
andybak Jul 15, 2024
88dc001
More room for title on sketchbook panel
andybak Jul 15, 2024
b4c6fc4
Use edit_url from upload response instead of job id
andybak Jul 16, 2024
7fab9b2
Remove out of date comment
andybak Aug 5, 2024
8228ffd
Merge remote-tracking branch 'origin/main' into feature/icosa-integra…
andybak Aug 15, 2024
4e3b80a
Merge branch 'main' into feature/icosa-integration
andybak Sep 11, 2024
a8eab36
Icosa panel shouldn't begin fixed
andybak Sep 12, 2024
68c819d
Renable poly button and rename to Icosa
andybak Sep 12, 2024
2e83abc
Disable m_UseLocalFeaturedSketches in the asset catalog
andybak Sep 12, 2024
e9c01c0
Curated also requiresIcosa now. Remove duplicate code.
andybak Sep 12, 2024
a862b99
Add a comment
andybak Sep 12, 2024
1032622
We now have assetId directly in the api results
andybak Sep 12, 2024
698ea97
Better logging
andybak Sep 12, 2024
be6f11e
Remove some logging noise
andybak Sep 12, 2024
426a05d
Update a comment
andybak Sep 12, 2024
33b5394
Some code prepping for dynamic switching between online/offline featu…
andybak Sep 12, 2024
67ff241
We now have assetid available
andybak Sep 12, 2024
ade568e
Handle missing thumbnails better
andybak Sep 12, 2024
ccfd9d3
No need to check GoogleIdentity here
andybak Sep 12, 2024
4ab872d
Make user models panel the default
andybak Sep 12, 2024
a7c7434
Disable m_InternetError as well before figuring out general panel vis…
andybak Sep 12, 2024
41a7ef4
Remove debug log
andybak Sep 12, 2024
653e3a6
Tweak default lister params
andybak Sep 14, 2024
97c5097
Limit the number of pages we retrieve
andybak Sep 14, 2024
ac0121e
Not sure what changed the main scene
andybak Sep 14, 2024
0f89153
Avoid errors when author is missing
andybak Sep 14, 2024
193bb31
Log a warning if we can't find a GLTF2
andybak Sep 15, 2024
60e864c
Sort featured sketches by "best"
andybak Sep 15, 2024
cb24340
Update packages-lock.json
andybak Sep 25, 2024
f0b4547
Comment
andybak Sep 25, 2024
08bb3d4
Comment
andybak Sep 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Assets/Editor/DummyCommandRefs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ public static void Prefabs_Panels_MemoryWarningPanel()
public static void Prefabs_Panels_PolyPanel()
{
Use(GlobalCommands.LoginToGenericCloud);
Use(GlobalCommands.ViewPolyGallery);
Use(GlobalCommands.ViewPolyPage);
Use(GlobalCommands.ViewBlocksGallery);
Use(GlobalCommands.ViewIcosaHomePage);
}

public static void Prefabs_Panels_PolyPanel_Mobile()
{
Use(GlobalCommands.LoginToGenericCloud);
Use(GlobalCommands.ViewPolyGallery);
Use(GlobalCommands.ViewPolyPage);
Use(GlobalCommands.ViewBlocksGallery);
Use(GlobalCommands.ViewIcosaHomePage);
}

public static void Prefabs_Panels_ReferencePanel_ReferencePanel_Mobile()
Expand Down
191 changes: 128 additions & 63 deletions Assets/Editor/GlTF_EditorExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@
using System.Text;
using JetBrains.Annotations;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SimpleJSON;
using UnityEditor;
using UnityEditor.ShaderGraph.Serialization;
using UnityEngine;
using UnityGLTF;
using UnityGLTF.Extensions;
using UObject = UnityEngine.Object;

namespace TiltBrush
Expand Down Expand Up @@ -95,7 +100,7 @@ private static void ExportBrushStrokes_gltf1()
{
new ExportGlTF().ExportBrushStrokes(
GetExportBaseName() + ".gltf",
AxisConvention.kGltfAccordingToPoly,
AxisConvention.kGltfAccordingToIcosa,
binary: false,
doExtras: true,
gltfVersion: 1,
Expand Down Expand Up @@ -128,75 +133,135 @@ private static bool ExportBrushStrokes_Enabled()
[MenuItem("Open Brush/glTF/Export Environments to glTF", false, 4)]
private static void ExportEnvironments()
{
#if !GAMEOBJ_EXPORT_TO_GLTF
Debug.LogError("Enable the define and fix up the code");
#else
// Save the original RenderSettings
Environment.RenderSettingsLite originalRenderSettings = Environment.GetRenderSettings();

// Clear out the existing environments directory to do a clean export
string projectPath = Path.GetDirectoryName(Application.dataPath);
string environmentExportPath = Path.Combine(projectPath,
ExportUtils.kProjectRelativeEnvironmentExportRoot);
try {
Directory.Delete(environmentExportPath, recursive: true);
} catch (DirectoryNotFoundException) {
// It's okay if this directory doesn't exist yet as it will be created later.
}
// Save the original RenderSettings
Environment.RenderSettingsLite originalRenderSettings = Environment.GetRenderSettings();

// Clear out the existing textures directory to do a clean export
string textureExportPath = Path.Combine(projectPath,
ExportUtils.kProjectRelativeTextureExportRoot);
try {
Directory.Delete(textureExportPath, recursive: true);
} catch (DirectoryNotFoundException) {
// It's okay if this directory doesn't exist yet as it will be created later.
}
if (!FileUtils.InitializeDirectoryWithUserError(
textureExportPath, "Failed to export, can't create texture export directory")) {
return;
}
// Clear out the existing environments directory to do a clean export
string projectPath = Path.GetDirectoryName(Application.dataPath);
string environmentExportPath = Path.Combine(projectPath,
ExportUtils.kProjectRelativeEnvironmentExportRoot);
try
{
Directory.Delete(environmentExportPath, recursive: true);
}
catch (DirectoryNotFoundException)
{
// It's okay if this directory doesn't exist yet as it will be created later.
}

// Get the environment
TiltBrushManifest manifest = AssetDatabase.LoadAssetAtPath<TiltBrushManifest>("Assets/Manifest.asset");
foreach (Environment env in manifest.Environments) {
// Copy over the RenderSettings
Environment.SetRenderSettings(env.m_RenderSettings);

// Set up the environment
string envGuid = env.m_Guid.ToString("D");
Debug.LogFormat("Exporting environment: {0}", env.m_RenderSettings.m_EnvironmentPrefab);
GameObject envPrefab = Resources.Load<GameObject>(env.m_RenderSettings.m_EnvironmentPrefab);
GameObject envGameObject = UObject.Instantiate(envPrefab);
envGameObject.name = envGuid;

// Hide game objects that don't get exported to Poly.
foreach (Transform child in envGameObject.transform) {
if (SceneSettings.ExcludeFromPolyExport(child)) {
child.gameObject.SetActive(false);
}
}
// Clear out the existing textures directory to do a clean export
string textureExportPath = Path.Combine(projectPath,
ExportUtils.kProjectRelativeTextureExportRoot);
try
{
Directory.Delete(textureExportPath, recursive: true);
}
catch (DirectoryNotFoundException)
{
// It's okay if this directory doesn't exist yet as it will be created later.
}
if (!FileUtils.InitializeDirectoryWithUserError(
textureExportPath, "Failed to export, can't create texture export directory"))
{
return;
}

// Set up the environment export directory
string directoryName = Path.Combine(environmentExportPath, envGuid);
if (!FileUtils.InitializeDirectoryWithUserError(
directoryName, "Failed to export, can't create environment export directory")) {
return;
}
// Get the environment
TiltBrushManifest manifest = AssetDatabase.LoadAssetAtPath<TiltBrushManifest>("Assets/Manifest.asset");
JToken colorToJArray(Color c) => JToken.FromObject(new { c.r, c.g, c.b, c.a });
JToken vector3ToJArray(Vector3 c) => JToken.FromObject(new { c.x, c.y, c.z });
var envJson = new JObject();
foreach (Environment env in manifest.Environments)
{
// Copy over the RenderSettings
Environment.SetRenderSettings(env.m_RenderSettings);

// Set up the environment
string envGuid = env.m_Guid.ToString("D");
var envJsonItem = new JObject();
envJsonItem["name"] = env.name;
envJsonItem["guid"] = envGuid;
var envRenderSettingsJson = new JObject();
envRenderSettingsJson["fogEnabled"] = env.m_RenderSettings.m_FogEnabled;
envRenderSettingsJson["fogColor"] = colorToJArray(env.m_RenderSettings.m_FogColor);
envRenderSettingsJson["fogDensity"] = env.m_RenderSettings.m_FogDensity;
envRenderSettingsJson["fogStartDistance"] = env.m_RenderSettings.m_FogStartDistance;
envRenderSettingsJson["fogEndDistance"] = env.m_RenderSettings.m_FogEndDistance;
envRenderSettingsJson["clearColor"] = colorToJArray(env.m_RenderSettings.m_ClearColor);
envRenderSettingsJson["ambientColor"] = colorToJArray(env.m_RenderSettings.m_AmbientColor);
envRenderSettingsJson["skyboxExposure"] = env.m_RenderSettings.m_SkyboxExposure;
envRenderSettingsJson["skyboxTint"] = colorToJArray(env.m_RenderSettings.m_SkyboxTint);
envRenderSettingsJson["environmentPrefab"] = env.m_RenderSettings.m_EnvironmentPrefab;
envRenderSettingsJson["environmentReverbZone"] = env.m_RenderSettings.m_EnvironmentReverbZonePrefab;
envRenderSettingsJson["skyboxCubemap"] = env.m_RenderSettings.m_SkyboxCubemap != null ?
env.m_RenderSettings.m_SkyboxCubemap.name : "";
envRenderSettingsJson["reflectionCubemap"] = env.m_RenderSettings.m_ReflectionCubemap != null ?
env.m_RenderSettings.m_ReflectionCubemap.name : "";
envRenderSettingsJson["reflectionIntensity"] = env.m_RenderSettings.m_ReflectionIntensity;
envJsonItem["renderSettings"] = envRenderSettingsJson;
var envLights = new JArray();
foreach (var light in env.m_Lights)
{
var envLight = new JObject();
envLight["color"] = colorToJArray(light.Color);
envLight["position"] = vector3ToJArray(light.m_Position);
envLight["rotation"] = vector3ToJArray(light.m_Rotation.eulerAngles);
envLight["type"] = light.m_Type.ToString();
envLight["range"] = light.m_Range;
envLight["spotAngle"] = light.m_SpotAngle;
envLight["shadowsEnabled"] = light.m_ShadowsEnabled;
envLights.Add(envLight);

string basename = FileUtils.SanitizeFilename(envGameObject.name);
string gltfName = Path.Combine(directoryName, basename + ".gltf");
}
envJsonItem["lights"] = envLights;
envJsonItem["teleportBoundsHalfWidth"] = env.m_TeleportBoundsHalfWidth;
envJsonItem["controllerXRayHeight"] = env.m_ControllerXRayHeight;
envJsonItem["widgetHome"] = vector3ToJArray(env.m_WidgetHome);
envJsonItem["skyboxColorA"] = colorToJArray(env.m_SkyboxColorA);
envJsonItem["skyboxColorB"] = colorToJArray(env.m_SkyboxColorB);
envJson[envGuid] = envJsonItem;

Debug.LogFormat("Exporting environment: {0}", env.m_RenderSettings.m_EnvironmentPrefab);
GameObject envPrefab = Resources.Load<GameObject>(env.m_RenderSettings.m_EnvironmentPrefab);
GameObject envGameObject = UObject.Instantiate(envPrefab);
envGameObject.name = envGuid;

// Hide game objects that don't get exported to Poly.
foreach (Transform child in envGameObject.transform)
{
if (SceneSettings.ExcludeFromPolyExport(child))
{
child.gameObject.SetActive(false);
}
}

var exporter = new ExportGlTF();
exporter.ExportGameObject(envGameObject, gltfName, env);
// Set up the environment export directory
string directoryName = Path.Combine(environmentExportPath, envGuid);
if (!FileUtils.InitializeDirectoryWithUserError(
directoryName, "Failed to export, can't create environment export directory"))
{
return;
}

// DestroyImmediate is required because editor mode never runs object garbage collection.
UObject.DestroyImmediate(envGameObject);
}
string basename = FileUtils.SanitizeFilename(envGameObject.name);

var settings = GLTFSettings.GetOrCreateSettings();
settings.UseMainCameraVisibility = false;
var context = new ExportContext();
var unityGltfexporter = new GLTFSceneExporter(envGameObject.transform, context);
unityGltfexporter.SaveGLB(directoryName, basename + ".glb");

// DestroyImmediate is required because editor mode never runs object garbage collection.
UObject.DestroyImmediate(envGameObject);
}

string jsonString = envJson.ToString();
string path = Path.Combine(environmentExportPath, "environments.json");
File.WriteAllText(path, jsonString);

// Restore the original RenderSettings
Environment.SetRenderSettings(originalRenderSettings);

// Restore the original RenderSettings
Environment.SetRenderSettings(originalRenderSettings);
#endif
}

private static Dictionary<Guid, BrushDescriptor> GetBrushes()
Expand Down
69 changes: 69 additions & 0 deletions Assets/Editor/RenderCubeMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using UnityEngine;
using UnityEditor;
using System.IO;

public class RenderCubeMap : EditorWindow
{
[SerializeField]
static int faceSize = 1024;

[MenuItem("Open Brush/RenderCubeMap", false, 11)]
static void Init()
{
var cam = Camera.main;
var camPos = cam.transform.position;
var camRot = cam.transform.rotation;

// cam.fieldOfView = 45;
// cam.farClipPlane = 4000;
// cam.allowMSAA = false;

cam.transform.position = new Vector3(0, 10, 0);
cam.transform.rotation = Quaternion.identity;

RenderToCubeMap(Camera.main);

cam.transform.position = camPos;
cam.transform.rotation = camRot;
}

static void RenderToCubeMap(Camera Cam)
{
Cubemap cubemap = new Cubemap(faceSize, TextureFormat.ARGB32, false);

var cubeSavePath = Application.dataPath + "/cube" + ".png";

Cam.RenderToCubemap(cubemap, 63);
Texture2D flattenedTexture = new Texture2D(faceSize * 4, faceSize * 3, TextureFormat.ARGB32, false);
for (int i = 0; i < 6; i++)
{
int x = 0, y = 0;
switch (i)
{
case 0: x = faceSize; y = faceSize * 2; break; // Top
case 1: x = faceSize; y = 0; break; // Bottom
case 2: x = faceSize * 3; y = faceSize; break; // Right
case 3: x = 0; y = faceSize; break; // Left
case 4: x = faceSize; y = faceSize; break; // Front
case 5: x = faceSize * 2; y = faceSize; break; // Back
}
Graphics.CopyTexture(cubemap, i, 0, 0, 0, faceSize, faceSize, flattenedTexture, 0, 0, x, y);
}

byte[] bytes = flattenedTexture.EncodeToPNG();
DestroyImmediate(flattenedTexture, true);
File.WriteAllBytes(cubeSavePath, bytes);

// var tex2DSavePath = Application.dataPath + "/360tex" + ".jpg";
// renderTexCube.ConvertToEquirect(renderTex2D);
DestroyImmediate(cubemap, true);
// Texture2D tex2d = new Texture2D(faceSize, 2048, TextureFormat.RGB24,false);
// RenderTexture.active = renderTex2D;
// tex2d.ReadPixels(new Rect(0,0,renderTex2D.width, renderTex2D.height),0,0);
// DestroyImmediate(renderTex2D, true);
// tex2d.Apply();
// bytes = tex2d.EncodeToJPG();
// DestroyImmediate(tex2d, true);
// File.WriteAllBytes(tex2DSavePath, bytes);
}
}
11 changes: 11 additions & 0 deletions Assets/Editor/RenderCubeMap.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions Assets/Editor/SetIcosaToken.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2021 The Tilt Brush Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace TiltBrush
{

using UnityEngine;
using UnityEditor;

public class SetIcosaToken : EditorWindow
{
private static string key = "IcosaToken";
private static string value = "";

[MenuItem("Open Brush/Icosa/Set Login Token")]
public static void ShowWindow()
{
value = PlayerPrefs.GetString(key);
GetWindow<SetIcosaToken>("Set Icosa Login Token");
}

void OnGUI()
{
GUILayout.Label("Enter Token", EditorStyles.boldLabel);
value = EditorGUILayout.TextField("Value", value);

if (GUILayout.Button("Save"))
{
PlayerPrefs.SetString(key, value);
PlayerPrefs.Save();
Debug.Log($"Saved: {key} = {value}");
}

if (GUILayout.Button("Load"))
{
value = PlayerPrefs.GetString(key, "");
Debug.Log($"Loaded: {key} = {value}");
}

if (GUILayout.Button("Delete"))
{
PlayerPrefs.DeleteKey(key);
Debug.Log($"Deleted: {key}");
}
}
}
}
3 changes: 3 additions & 0 deletions Assets/Editor/SetIcosaToken.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading