Initial Commit
This commit is contained in:
parent
53eb92e9af
commit
270ab7d11f
15341 changed files with 700234 additions and 0 deletions
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Unity.Cloud.Collaborate.Utilities
|
||||
{
|
||||
static class ExtensionMethods
|
||||
{
|
||||
// Credit: https://stackoverflow.com/a/4405876
|
||||
/// <summary>
|
||||
/// Take the first letter of the string and capitalise it.
|
||||
/// </summary>
|
||||
/// <param name="input">String to work with.</param>
|
||||
/// <returns>String with first letter capitalised.</returns>
|
||||
/// <exception cref="ArgumentNullException">If string is null.</exception>
|
||||
/// <exception cref="ArgumentException">If string is empty.</exception>
|
||||
public static string FirstCharToUpper(this string input)
|
||||
{
|
||||
switch (input)
|
||||
{
|
||||
case null: throw new ArgumentNullException(nameof(input));
|
||||
case "": throw new ArgumentException($"{nameof(input)} cannot be empty", nameof(input));
|
||||
default: return input.First().ToString().ToUpper() + input.Substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Editor/Utilities/ExtensionMethods.cs.meta
generated
Normal file
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Editor/Utilities/ExtensionMethods.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a302d64f7a6389743801a4d85d302fc9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,62 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Unity.Cloud.Collaborate.Utilities
|
||||
{
|
||||
static class MenuUtilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Corner of the anchor element the dialogue should anchor to.
|
||||
/// </summary>
|
||||
public enum AnchorPoint
|
||||
{
|
||||
TopLeft,
|
||||
TopRight,
|
||||
BottomLeft,
|
||||
BottomRight
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Direction the dialogue should open from its anchor.
|
||||
/// </summary>
|
||||
public enum OpenDirection
|
||||
{
|
||||
UpLeft,
|
||||
UpRight,
|
||||
DownLeft,
|
||||
DownRight
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Given an element and an anchor point, calculate the world coords to draw a menu at.
|
||||
/// </summary>
|
||||
/// <param name="e">Element to start at.</param>
|
||||
/// <param name="anchorPoint">Corner of the element to calculate.</param>
|
||||
/// <returns>World coordinates from the given values.</returns>
|
||||
public static (float X, float Y) GetMenuPosition(VisualElement e, AnchorPoint anchorPoint)
|
||||
{
|
||||
// Calculate position of the start corner.
|
||||
(float x, float y) anchorCoords;
|
||||
switch (anchorPoint)
|
||||
{
|
||||
case AnchorPoint.TopLeft:
|
||||
anchorCoords = (e.worldBound.xMin, e.worldBound.yMin);
|
||||
break;
|
||||
case AnchorPoint.TopRight:
|
||||
anchorCoords = (e.worldBound.xMax, e.worldBound.yMin);
|
||||
break;
|
||||
case AnchorPoint.BottomLeft:
|
||||
anchorCoords = (e.worldBound.xMin, e.worldBound.yMax);
|
||||
break;
|
||||
case AnchorPoint.BottomRight:
|
||||
anchorCoords = (e.worldBound.xMax, e.worldBound.yMax);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(anchorPoint), anchorPoint, null);
|
||||
}
|
||||
|
||||
return anchorCoords;
|
||||
}
|
||||
}
|
||||
}
|
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Editor/Utilities/MenuUtilities.cs.meta
generated
Normal file
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Editor/Utilities/MenuUtilities.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5f83c607c6ee0cc4ca8ad15cb879dee9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using UnityEditor.Connect;
|
||||
|
||||
namespace Unity.Cloud.Collaborate.Utilities
|
||||
{
|
||||
internal static class OpenLinksUtility
|
||||
{
|
||||
public static void OpenMembersLink()
|
||||
{
|
||||
string url;
|
||||
var config = UnityConnect.instance.configuration;
|
||||
switch (config)
|
||||
{
|
||||
case "development": url = "https://dev-developer.cloud.unity3d.com/orgs/{0}/projects/{1}/users"; break;
|
||||
case "staging": url = "https://staging-developer.cloud.unity3d.com/orgs/{0}/projects/{1}/users"; break;
|
||||
case "production": url = "https://developer.cloud.unity3d.com/orgs/{0}/projects/{1}/users"; break;
|
||||
default:
|
||||
UnityEngine.Debug.LogError($"Unexpected connection configuration {config}"); return;
|
||||
}
|
||||
|
||||
// url = url.Replace("%%ORGID%%", UnityConnect.instance.projectInfo.organizationId).Replace("%%UPID%%", UnityConnect.instance.projectInfo.projectGUID);
|
||||
url = string.Format(url, UnityConnect.instance.projectInfo.organizationId, UnityConnect.instance.projectInfo.projectGUID);
|
||||
UnityConnect.instance.OpenAuthorizedURLInWebBrowser(url);
|
||||
}
|
||||
}
|
||||
}
|
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Editor/Utilities/OpenLinksUtility.cs.meta
generated
Normal file
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Editor/Utilities/OpenLinksUtility.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1368dd525e9009940aba9e7dbc654456
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,2 @@
|
|||
# Unity Collaborate Utility Code
|
||||
This directory contains utility classes and logic for the package.
|
7
Library/PackageCache/com.unity.collab-proxy@1.3.9/Editor/Utilities/README.md.meta
generated
Normal file
7
Library/PackageCache/com.unity.collab-proxy@1.3.9/Editor/Utilities/README.md.meta
generated
Normal file
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7d5cb2eb08aa12d48adcc34cd4e115c2
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
|
||||
namespace Unity.Cloud.Collaborate.Utilities
|
||||
{
|
||||
static class StringUtility
|
||||
{
|
||||
public static string TrimAndToLower(string value)
|
||||
{
|
||||
return string.IsNullOrEmpty(value)
|
||||
? string.Empty
|
||||
: value.Trim().ToLower();
|
||||
}
|
||||
}
|
||||
}
|
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Editor/Utilities/StringUtility.cs.meta
generated
Normal file
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Editor/Utilities/StringUtility.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4554dad88a0d391499f99187f1643edf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.Cloud.Collaborate.Utilities
|
||||
{
|
||||
internal static class Threading
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the current thread is the main thread, false otherwise.
|
||||
/// </summary>
|
||||
public static bool IsMainThread => InternalEditorUtility.CurrentThreadIsMainThread();
|
||||
|
||||
/// <summary>
|
||||
/// Ensure that the provided action is executed on the UI/main thread.
|
||||
/// </summary>
|
||||
/// <param name="action">Action to perform on the UI/main thread.</param>
|
||||
public static void EnsureUiThread(Action action)
|
||||
{
|
||||
if (IsMainThread)
|
||||
{
|
||||
action();
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorApplication.delayCall += () => action();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Editor/Utilities/Threading.cs.meta
generated
Normal file
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Editor/Utilities/Threading.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1dfb36541d6f17a488b8de6d9993eaaf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,114 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using JetBrains.Annotations;
|
||||
using Unity.Cloud.Collaborate.Settings;
|
||||
|
||||
namespace Unity.Cloud.Collaborate.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Static class that presents methods to provide timestamps for the UI.
|
||||
/// </summary>
|
||||
static class TimeStamp
|
||||
{
|
||||
/// <summary>
|
||||
/// Bool to decide whether timestamps should be exact values or relative values.
|
||||
/// </summary>
|
||||
public static bool UseRelativeTimeStamps =>
|
||||
CollabSettingsManager.Get(CollabSettings.settingRelativeTimestamp, fallback: true);
|
||||
|
||||
/// <summary>
|
||||
/// Values to translate a number to a string representation.
|
||||
/// </summary>
|
||||
static readonly string[] k_UnitsMap = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };
|
||||
|
||||
/// <summary>
|
||||
/// Get the localized or relative timestamp for the given DateTime based on the current settings.
|
||||
/// </summary>
|
||||
/// <param name="dateTime">DateTime to convert.</param>
|
||||
/// <returns>String representation of the given DateTime.</returns>
|
||||
[NotNull]
|
||||
public static string GetTimeStamp(DateTimeOffset dateTime)
|
||||
{
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||
return UseRelativeTimeStamps
|
||||
? GetElapsedTime(dateTime)
|
||||
: GetLocalisedTimeStamp(dateTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the localised timestamp for the given DateTime.
|
||||
/// </summary>
|
||||
/// <param name="dateTime">DateTime to convert.</param>
|
||||
/// <returns>Localised string representation of the given DateTime.</returns>
|
||||
[NotNull]
|
||||
public static string GetLocalisedTimeStamp(DateTimeOffset dateTime)
|
||||
{
|
||||
return dateTime.ToString(CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern);
|
||||
}
|
||||
|
||||
// Original credit: https://codereview.stackexchange.com/questions/93239/get-elapsed-time-as-human-friendly-string
|
||||
/// <summary>
|
||||
/// Convert a DateTime into a relative timestamp.
|
||||
/// </summary>
|
||||
/// <param name="dateTime">Datetime to calculate the timestamp from.</param>
|
||||
/// <returns>Relative timestamp for the given DateTime.</returns>
|
||||
[NotNull]
|
||||
static string GetElapsedTime(DateTimeOffset dateTime)
|
||||
{
|
||||
var offset = DateTimeOffset.Now.Subtract(dateTime);
|
||||
|
||||
// The trick: make variable contain date and time representing the desired timespan,
|
||||
// having +1 in each date component.
|
||||
var date = DateTimeOffset.MinValue + offset;
|
||||
|
||||
return ProcessPeriod(date.Year - 1, date.Month - 1, "year")
|
||||
?? ProcessPeriod(date.Month - 1, date.Day - 1, "month")
|
||||
?? ProcessPeriod(date.Day - 1, date.Hour, "day", "Yesterday")
|
||||
?? ProcessPeriod(date.Hour, date.Minute, "hour")
|
||||
?? ProcessPeriod(date.Minute, date.Second, "minute")
|
||||
?? ProcessPeriod(date.Second, 0, "second")
|
||||
?? "Right now";
|
||||
}
|
||||
|
||||
// Original credit: https://codereview.stackexchange.com/questions/93239/get-elapsed-time-as-human-friendly-string
|
||||
/// <summary>
|
||||
/// Output the string representation for the given time frame. If it's not in that time frame, it returns null.
|
||||
/// </summary>
|
||||
/// <param name="value">Bigger time value.</param>
|
||||
/// <param name="subValue">Smaller time value eg: minutes if value is hours.</param>
|
||||
/// <param name="name">Name of the period.</param>
|
||||
/// <param name="singularName">Name for period that is singular. Null if it's not singular eg: yesterday.</param>
|
||||
/// <returns>String representation of the period, or null if it's outside of it.</returns>
|
||||
[CanBeNull]
|
||||
static string ProcessPeriod(int value, int subValue, string name, string singularName = null)
|
||||
{
|
||||
// If the value is less than this time frame, skip.
|
||||
if (value == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// If a multiple of this time frame eg: 20 minutes.
|
||||
if (value != 1)
|
||||
{
|
||||
// Convert values specified to string numbers.
|
||||
var stringValue = value <k_UnitsMap.Length ? k_UnitsMap[value] : value.ToString();
|
||||
return subValue == 0
|
||||
? $"{stringValue.FirstCharToUpper()} {name}s ago"
|
||||
: $"About {stringValue} {name}s ago";
|
||||
}
|
||||
|
||||
// Special case for one-off names eg: yesterday.
|
||||
if (!string.IsNullOrEmpty(singularName))
|
||||
{
|
||||
return singularName;
|
||||
}
|
||||
|
||||
// Singular time frame eg: an hour, a minute.
|
||||
var articleSuffix = name[0] == 'h' ? "n" : string.Empty;
|
||||
return subValue == 0
|
||||
? $"A{articleSuffix} {name} ago"
|
||||
: $"About a{articleSuffix} {name} ago";
|
||||
}
|
||||
}
|
||||
}
|
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Editor/Utilities/TimeStamp.cs.meta
generated
Normal file
11
Library/PackageCache/com.unity.collab-proxy@1.3.9/Editor/Utilities/TimeStamp.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f802c3808a2e25047bdff19441653ffe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue