This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct Binding | |
{ | |
//WeakReference for garbige collection | |
public System.Reflection.PropertyInfo To; | |
public System.Reflection.PropertyInfo From; //memberinfo, methodinfo | |
public WeakReference ToSource; | |
public WeakReference FromSource; | |
public Delegate Convertation; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Autogramma.CombApp; | |
using Autogramma.CombApp.Events; | |
using System; | |
using System.Collections.Generic; | |
public class EventsAggregator | |
{ | |
public abstract class AbstractEventAggregator<TAction> | |
{ | |
private List<WeakReference> _listeners = new List<WeakReference>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.Events; | |
using UnityEngine.EventSystems; | |
using System.Linq; | |
using UnityEngine.UI; | |
public static class EventsExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Attach this to any object in your scene, to make it work */ | |
using System; | |
using System.Collections; | |
using UnityEngine; | |
using System.Threading; | |
public class MainThread : MonoBehaviour | |
{ | |
private static InvokePump mPump; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string NumToShortStr(this double num) | |
{ | |
string prefix = string.Empty; | |
if (num < 0) | |
prefix = "-"; | |
num = Math.Abs(num); | |
if (num >= 1000000000000D) | |
return prefix + (num / 1000000000000D).ToString("0.#").Replace(',', '.') + "T"; | |
if (num >= 1000000000D) | |
return prefix + (num / 1000000000D).ToString("0.#").Replace(',', '.') + "B"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region COLOR | |
static public Color ParseColor(string text, int offset) { return ParseColor24(text, offset); } | |
static public Color ParseColor24(string text, int offset) | |
{ | |
int r = (HexToDecimal(text[offset]) << 4) | HexToDecimal(text[offset + 1]); | |
int g = (HexToDecimal(text[offset + 2]) << 4) | HexToDecimal(text[offset + 3]); | |
int b = (HexToDecimal(text[offset + 4]) << 4) | HexToDecimal(text[offset + 5]); | |
float f = 1f / 255f; | |
return new Color(f * r, f * g, f * b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void ExitApp() { | |
if(Application.isEditor) | |
UnityEditor.EditorApplication.isPlaying = false; | |
else if(Application.isMobilePlatform) | |
System.Diagnostics.Process.GetCurrentProcess().Kill(); | |
else | |
Application.Quit(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LineRenderer Create3DLineRendererLine(IList<Vector3> points, Transform parentForLine, float width) | |
{ | |
GameObject line = new GameObject("lineRenderer"); | |
line.transform.parent = parentForLine; | |
line.layer = parentForLine.gameObject.layer; | |
line.transform.localPosition = Vector3.zero; | |
line.transform.localScale = Vector3.one; | |
LineRenderer lr = line.AddComponent<LineRenderer>(); | |
lr.positionCount = points.Count; | |
lr.startWidth = width; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool IsCursorOrTouchUnderUI() | |
{ | |
if (EventSystem.current == null) | |
return true; | |
if (EventSystem.current.enabled == false) | |
return true; | |
if (EventSystem.current.currentSelectedGameObject != null) | |
return true; | |
if (EventSystem.current.IsPointerOverGameObject()) //лишняя и грузит? Если проблем нет, то удалить | |
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string GetTimeLeftString(this TimeSpan timeLeft) | |
{ | |
var ts = timeLeft; | |
if (ts.TotalSeconds < 0) | |
return "..."; | |
var result = string.Format("{0}:{1}", ts.Minutes.ToString("00"), ts.Seconds.ToString("00")); | |
if (timeLeft.TotalHours > 1d) |
OlderNewer