app center;增加發送ping的秒
This commit is contained in:
1 parent
1bd1ffdb5a
commit
d754ff3b15
719 files changed
+34172
-2875
No files matched your search
@@ -0,0 +1,57 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
public class DrawUtils {
|
||||
|
||||
private static Color32[] rotateSquare(Color32[] arr, double phi, Texture2D originTexture)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int i;
|
||||
int j;
|
||||
double sn = Math.Sin(phi);
|
||||
double cs = Math.Cos(phi);
|
||||
Color32[] arr2 = originTexture.GetPixels32();
|
||||
int W = originTexture.width;
|
||||
int H = originTexture.height;
|
||||
int xc = W / 2;
|
||||
int yc = H / 2;
|
||||
for (j = 0; j < H; j++)
|
||||
{
|
||||
for (i = 0; i < W; i++)
|
||||
{
|
||||
arr2[j * W + i] = new Color32(0, 0, 0, 0);
|
||||
x = (int)(cs * (i - xc) + sn * (j - yc) + xc);
|
||||
y = (int)(-sn * (i - xc) + cs * (j - yc) + yc);
|
||||
if ((x > -1) && (x < W) && (y > -1) && (y < H))
|
||||
{
|
||||
arr2[j * W + i] = arr[y * W + x];
|
||||
}
|
||||
}
|
||||
}
|
||||
return arr2;
|
||||
}
|
||||
|
||||
public static Texture2D RotateImage(Texture2D originTexture, int angle)
|
||||
{
|
||||
Texture2D result;
|
||||
result = new Texture2D(originTexture.width, originTexture.height);
|
||||
Color32[] pix1 = result.GetPixels32();
|
||||
Color32[] pix2 = originTexture.GetPixels32();
|
||||
int W = originTexture.width;
|
||||
int H = originTexture.height;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
Color32[] pix3 = rotateSquare(pix2, (Math.PI / 180 * (double)angle), originTexture);
|
||||
for (int j = 0; j < H; j++)
|
||||
{
|
||||
for (var i = 0; i < W; i++)
|
||||
{
|
||||
pix1[result.width / 2 - W / 2 + x + i + result.width * (result.height / 2 - H / 2 + j + y)] = pix3[i + j * W];
|
||||
}
|
||||
}
|
||||
result.SetPixels32(pix1);
|
||||
result.Apply();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2db30e5e160bb48358ce517ac9f8eea8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,157 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AppCenterEditor
|
||||
{
|
||||
public class ProgressBar
|
||||
{
|
||||
public enum ProgressBarStates { off = 0, on = 1, spin = 2, error = 3, warning = 4, success = 5 }
|
||||
public static ProgressBarStates currentProgressBarState = ProgressBarStates.off;
|
||||
|
||||
public static float progress = 0;
|
||||
private static GUIStyle pbarStyle = AppCenterEditorHelper.uiStyle.GetStyle("progressBarFg");
|
||||
private static GUIStyle pbarBgStyle = AppCenterEditorHelper.uiStyle.GetStyle("progressBarBg");
|
||||
|
||||
private static float progressWidth = 0;
|
||||
private static float animationSpeed = 1f;
|
||||
private static float tickRate = .15f;
|
||||
private static float stTime;
|
||||
private static float endTime;
|
||||
private static float lastUpdateTime;
|
||||
private static bool isReveresed;
|
||||
|
||||
public static void UpdateState(ProgressBarStates state)
|
||||
{
|
||||
if (currentProgressBarState == ProgressBarStates.off && state != ProgressBarStates.off)
|
||||
{
|
||||
stTime = (float)EditorApplication.timeSinceStartup;
|
||||
endTime = stTime + animationSpeed;
|
||||
}
|
||||
|
||||
currentProgressBarState = state;
|
||||
}
|
||||
|
||||
//not a good way to do this right now.
|
||||
public static void UpdateProgress(float p)
|
||||
{
|
||||
progress = p;
|
||||
}
|
||||
|
||||
public static void Draw()
|
||||
{
|
||||
var progressMaxWidth = AppCenterEditor.InnerContainerWidth;
|
||||
|
||||
pbarBgStyle = AppCenterEditorHelper.uiStyle.GetStyle("progressBarBg");
|
||||
if (currentProgressBarState == ProgressBarStates.off)
|
||||
{
|
||||
stTime = 0;
|
||||
endTime = 0;
|
||||
progressWidth = 0;
|
||||
lastUpdateTime = 0;
|
||||
isReveresed = false;
|
||||
|
||||
progressWidth = progressMaxWidth;
|
||||
pbarStyle = AppCenterEditorHelper.uiStyle.GetStyle("progressBarClear");
|
||||
pbarBgStyle = AppCenterEditorHelper.uiStyle.GetStyle("progressBarClear");
|
||||
//return;
|
||||
}
|
||||
else if (EditorWindow.focusedWindow != AppCenterEditor.window)
|
||||
{
|
||||
// pause draw while we are in the bg
|
||||
return;
|
||||
}
|
||||
else if (currentProgressBarState == ProgressBarStates.success)
|
||||
{
|
||||
if ((float)EditorApplication.timeSinceStartup - stTime < animationSpeed)
|
||||
{
|
||||
progressWidth = progressMaxWidth;
|
||||
pbarStyle = AppCenterEditorHelper.uiStyle.GetStyle("progressBarSuccess");
|
||||
}
|
||||
else if (AppCenterEditor.blockingRequests.Count > 0)
|
||||
{
|
||||
UpdateState(ProgressBarStates.spin);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateState(ProgressBarStates.off);
|
||||
}
|
||||
}
|
||||
else if (currentProgressBarState == ProgressBarStates.warning)
|
||||
{
|
||||
if ((float)EditorApplication.timeSinceStartup - stTime < animationSpeed)
|
||||
{
|
||||
progressWidth = progressMaxWidth;
|
||||
pbarStyle = AppCenterEditorHelper.uiStyle.GetStyle("progressBarWarn");
|
||||
}
|
||||
else if (AppCenterEditor.blockingRequests.Count > 0)
|
||||
{
|
||||
UpdateState(ProgressBarStates.spin);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateState(ProgressBarStates.off);
|
||||
}
|
||||
}
|
||||
else if (currentProgressBarState == ProgressBarStates.error)
|
||||
{
|
||||
if ((float)EditorApplication.timeSinceStartup - stTime < animationSpeed)
|
||||
{
|
||||
progressWidth = progressMaxWidth;
|
||||
pbarStyle = AppCenterEditorHelper.uiStyle.GetStyle("progressBarError");
|
||||
}
|
||||
else if (AppCenterEditor.blockingRequests.Count > 0)
|
||||
{
|
||||
UpdateState(ProgressBarStates.spin);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateState(ProgressBarStates.off);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if ((float)EditorApplication.timeSinceStartup - lastUpdateTime > tickRate)
|
||||
{
|
||||
lastUpdateTime = (float)EditorApplication.timeSinceStartup;
|
||||
pbarStyle = AppCenterEditorHelper.uiStyle.GetStyle("progressBarFg");
|
||||
|
||||
if (currentProgressBarState == ProgressBarStates.on)
|
||||
{
|
||||
progressWidth = progressMaxWidth * progress;
|
||||
}
|
||||
else if (currentProgressBarState == ProgressBarStates.spin)
|
||||
{
|
||||
var currentTime = (float)EditorApplication.timeSinceStartup;
|
||||
if (currentTime < endTime && !isReveresed)
|
||||
{
|
||||
UpdateProgress((currentTime - stTime) / animationSpeed);
|
||||
progressWidth = progressMaxWidth * progress;
|
||||
}
|
||||
else if (currentTime < endTime && isReveresed)
|
||||
{
|
||||
UpdateProgress((currentTime - stTime) / animationSpeed);
|
||||
progressWidth = progressMaxWidth - progressMaxWidth * progress;
|
||||
}
|
||||
else
|
||||
{
|
||||
isReveresed = !isReveresed;
|
||||
stTime = (float)EditorApplication.timeSinceStartup;
|
||||
endTime = stTime + animationSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using (new AppCenterGuiFieldHelper.UnityHorizontal(pbarBgStyle))
|
||||
{
|
||||
if (isReveresed)
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
EditorGUILayout.LabelField("", pbarStyle, GUILayout.Width(progressWidth));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eea75b0d7b5ef4c108f3f7d94c1db778
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user