Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions Assets/Scripts/Tracks/TrackManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public class TrackManager : MonoBehaviour
protected const int k_DesiredSegmentCount = 10;
protected const float k_SegmentRemovalDistance = -30f;
protected const float k_Acceleration = 0.2f;

protected void Awake()
{
m_ScoreAccum = 0.0f;
Expand Down Expand Up @@ -562,7 +562,7 @@ public void SpawnObstacle(TrackSegment segment)

private IEnumerator SpawnFromAssetReference(AssetReference reference, TrackSegment segment, int posIndex)
{
AsyncOperationHandle op = reference.LoadAssetAsync<GameObject>();
AsyncOperationHandle op = Addressables.LoadAssetAsync<GameObject>(reference);
yield return op;
GameObject obj = op.Result as GameObject;
if (obj != null)
Expand Down
8 changes: 8 additions & 0 deletions Packages/com.unity.asset-store-tools/Editor.meta

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

44 changes: 44 additions & 0 deletions Packages/com.unity.asset-store-tools/Editor/AssetStoreTools.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using UnityEditor;
using UnityEngine;
using System;
using AssetStoreTools.Uploader;
using AssetStoreTools.Validator;

namespace AssetStoreTools
{
internal class AssetStoreTools : EditorWindow
{
[MenuItem("Asset Store Tools v2/Asset Store Uploader", false, 0)]
public static void ShowAssetStoreToolsUploader()
{
Type inspectorType = Type.GetType("UnityEditor.InspectorWindow,UnityEditor.dll");
GetWindow<AssetStoreUploader>(inspectorType);
}


[MenuItem("Asset Store Tools v2/Asset Store Validator", false, 1)]
public static void ShowAssetStoreToolsValidator()
{
Type inspectorType = Type.GetType("UnityEditor.InspectorWindow,UnityEditor.dll");
GetWindow<AssetStoreValidation>(typeof(AssetStoreUploader), inspectorType);
}

[MenuItem("Asset Store Tools v2/Publisher Portal", false, 20)]
public static void OpenPublisherPortal()
{
Application.OpenURL("https://publisher.unity.com/");
}

[MenuItem("Asset Store Tools v2/Submission Guidelines", false, 21)]
public static void OpenSubmissionGuidelines()
{
Application.OpenURL("https://assetstore.unity.com/publishing/submission-guidelines/");
}

[MenuItem("Asset Store Tools v2/Provide Feedback", false, 50)]
public static void OpenFeedback()
{
Application.OpenURL("https://forum.unity.com/threads/new-asset-store-tools-version-coming-july-20th-2022.1310939/");
}
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using UnityEditor;
using UnityEngine;
using System;

namespace AssetStoreTools
{
public abstract class AssetStoreToolsWindow : EditorWindow
{
protected abstract string WindowTitle { get; }

protected virtual void Init()
{
titleContent = new GUIContent(WindowTitle);
}

private void OnEnable()
{
Init();
}

}
}

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
using AssetStoreTools.Utility.Json;
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;

namespace AssetStoreTools.Uploader
{
public class AssetStoreUploader : AssetStoreToolsWindow, IHasCustomMenu
{
public const string MinRequiredPackageVersion = "2020.3";

private const string MainWindowVisualTree = "Packages/com.unity.asset-store-tools/Editor/AssetStoreUploader/Styles/Base/BaseWindow_Main";
private const string DebugPhrase = "debug";

// UI Windows
private LoginWindow _loginWindow;
private UploadWindow _uploadWindow;

private readonly List<char> _debugBuffer = new List<char>();

public static bool EnableCustomExporter
{
get => EditorPrefs.GetBool("ASTCustomExporter", false);
set => EditorPrefs.SetBool("ASTCustomExporter", value);
}

public static bool ShowPackageVersionDialog
{
get => Application.unityVersion.CompareTo(MinRequiredPackageVersion) == 1 ? false : EditorPrefs.GetBool("ASTPreUploadVersionCheck", true);
set => EditorPrefs.SetBool("ASTPreUploadVersionCheck", value);
}

protected override string WindowTitle => "Asset Store Uploader";

protected override void Init()
{
if (_loginWindow != null && _uploadWindow != null)
return;

minSize = new Vector2(400, 430);
this.SetAntiAliasing(4);

base.Init();

VisualElement root = rootVisualElement;
root.AddToClassList("root");

// Getting a reference to the UXML Document and adding to the root
var visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>($"{MainWindowVisualTree}.uxml");
VisualElement uxmlRoot = visualTree.CloneTree();
uxmlRoot.style.flexGrow = 1;
root.Add(uxmlRoot);

StyleSelector.SetStyle(root, StyleSelector.Style.Base, !EditorGUIUtility.isProSkin);

// Find necessary windows / views and sets up appropriate functionality
SetupCoreElements();

if (!AssetStoreAPI.IsUploading)
{
// Should only authenticate if the session is available. Other authentications are only available
// in the login window. See "SetupLoginElements".
HideElement(_uploadWindow);
Authenticate();
}
else
{
ShowUploadWindow();
}
}

private void OnGUI()
{
CheckForDebugMode();
}

private void OnDestroy()
{
if (AssetStoreAPI.IsUploading)
EditorUtility.DisplayDialog("Notice", "Assets are still being uploaded to the Asset Store. " +
"If you wish to check on the progress, please re-open the Asset Store Uploader window", "OK");
}

private void SetupCoreElements()
{
_loginWindow = rootVisualElement.Q<LoginWindow>("LoginWindow");
_uploadWindow = rootVisualElement.Q<UploadWindow>("UploadWindow");

_loginWindow.SetupLoginElements(OnLoginSuccess, OnLoginFail);
_uploadWindow.SetupWindows(OnLogout, OnPackageDownloadFail);
}

public void AddItemsToMenu(GenericMenu menu)
{
menu.AddItem(new GUIContent("(Experimental) Enable Custom Exporter"),
EnableCustomExporter,
() =>
{
if (!EnableCustomExporter && !EditorUtility.DisplayDialog("Notice", "Custom exporter is an experimental feature. " +
"It packs selected Assets without using the native Unity API and is observed to be slightly faster.\n\n" +
"Please note that Asset preview images used to showcase specific asset types (Textures, Materials, Prefabs) before importing the package " +
"might not be generated consistently at this time. This does not affect functionality of the package after it gets imported.",
"OK"))
return;
EnableCustomExporter = !EnableCustomExporter;
ASDebug.Log($"Custom exporter set to {EnableCustomExporter}");
});
}

#region Login Interface

private void Authenticate()
{
ShowLoginWindow();

// 1 - Check if there's an active session
// 2 - Check if there's a saved session
// 3 - Attempt to login via Cloud session token
// 4 - Prompt manual login
EnableLoginWindow(false);
AssetStoreAPI.LoginWithSession(OnLoginSuccess, OnLoginFail, OnLoginFailSession);
}

private void OnLoginFail(ASError error)
{
Debug.LogError(error.Message);

_loginWindow.EnableErrorBox(true, error.Message);
EnableLoginWindow(true);
}

private void OnLoginFailSession()
{
// All previous login methods are unavailable
EnableLoginWindow(true);
}

private void OnLoginSuccess(JsonValue json)
{
ASDebug.Log($"Login json\n{json}");

if (!AssetStoreAPI.IsPublisherValid(json, out var error))
{
EnableLoginWindow(true);
_loginWindow.EnableErrorBox(true, error.Message);
ASDebug.Log($"Publisher {json["name"]} is invalid.");
return;
}

ASDebug.Log($"Publisher {json["name"]} is valid.");
AssetStoreAPI.SavedSessionId = json["xunitysession"].AsString();
AssetStoreAPI.LastLoggedInUser = json["username"].AsString();

ShowUploadWindow();
}

private void OnPackageDownloadFail(ASError error)
{
_loginWindow.EnableErrorBox(true, error.Message);
EnableLoginWindow(true);
ShowLoginWindow();
}

private void OnLogout()
{
AssetStoreAPI.SavedSessionId = String.Empty;
AssetStoreCache.ClearTempCache();

_loginWindow.ClearLoginBoxes();
ShowLoginWindow();
EnableLoginWindow(true);
}

#endregion

#region UI Window Utils
private void ShowLoginWindow()
{
HideElement(_uploadWindow);
ShowElement(_loginWindow);
}

private void ShowUploadWindow()
{
HideElement(_loginWindow);
ShowElement(_uploadWindow);

_uploadWindow.ShowAllPackagesView();
_uploadWindow.ShowPublisherEmail(AssetStoreAPI.LastLoggedInUser);
_uploadWindow.LoadPackages(true, OnPackageDownloadFail);
}

private void ShowElement(params VisualElement[] elements)
{
foreach(var e in elements)
e.style.display = DisplayStyle.Flex;
}

private void HideElement(params VisualElement[] elements)
{
foreach(var e in elements)
e.style.display = DisplayStyle.None;
}

private void EnableLoginWindow(bool enable)
{
_loginWindow.SetEnabled(enable);
}

#endregion

#region Debug Utility

private void CheckForDebugMode()
{
Event e = Event.current;

if (e.type != EventType.KeyDown || e.keyCode == KeyCode.None)
return;

_debugBuffer.Add(e.keyCode.ToString().ToLower()[0]);
if (_debugBuffer.Count > DebugPhrase.Length)
_debugBuffer.RemoveAt(0);

if (string.Join(string.Empty, _debugBuffer.ToArray()) != DebugPhrase)
return;

ASDebug.DebugModeEnabled = !ASDebug.DebugModeEnabled;
ASDebug.Log($"DEBUG MODE ENABLED: {ASDebug.DebugModeEnabled}");
_debugBuffer.Clear();
}

#endregion
}
}

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

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading