1
This commit is contained in:
@@ -4,17 +4,12 @@ using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityEngine.Networking;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Text;
|
||||
using System.IO.Compression;
|
||||
using System.Data;
|
||||
using UnityEngine.UIElements;
|
||||
namespace BITKit
|
||||
{
|
||||
@@ -402,18 +397,6 @@ namespace BITKit
|
||||
text = text.Remove(0, text.Split('\n')[0].Length + 1);
|
||||
return text;
|
||||
}
|
||||
public static TaskAwaiter GetAwaiter(this AsyncOperation asyncOp)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
asyncOp.completed += obj => { tcs.SetResult(null); };
|
||||
return ((Task)tcs.Task).GetAwaiter();
|
||||
}
|
||||
public static TaskAwaiter GetAwaiter(this System.Action action)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
action += () => { tcs.SetResult(null); };
|
||||
return ((Task)tcs.Task).GetAwaiter();
|
||||
}
|
||||
public static float GetDifference(this IEnumerable<float> self)
|
||||
{
|
||||
return self.Max() - self.Min();
|
||||
@@ -665,13 +648,32 @@ namespace BITKit
|
||||
|
||||
public static Vector2 GetScreenPosition(this VisualElement self, Vector3 worldPosition)
|
||||
{
|
||||
var pos = RuntimePanelUtils
|
||||
.CameraTransformWorldToPanel(self.panel, worldPosition, Camera.main);
|
||||
try
|
||||
{
|
||||
var panel = self.panel;
|
||||
if (panel is null)
|
||||
{
|
||||
panel = self.parent.panel;
|
||||
}
|
||||
|
||||
pos.x -= self.layout.width / 2;
|
||||
pos.y -= self.layout.height / 2;
|
||||
if (panel is null)
|
||||
{
|
||||
panel = self.parent.parent.panel;
|
||||
}
|
||||
|
||||
return pos;
|
||||
var pos = RuntimePanelUtils
|
||||
.CameraTransformWorldToPanel(panel, worldPosition, Camera.main);
|
||||
|
||||
pos.x -= self.layout.width / 2;
|
||||
pos.y -= self.layout.height / 2;
|
||||
|
||||
return pos;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
public static Vector2 GetPosition(this VisualElement self)
|
||||
|
Reference in New Issue
Block a user