Skip to content

Instantly share code, notes, and snippets.

View arashrasoulzadeh's full-sized avatar
👨‍💻
Coder

Arash Rasoulzadeh arashrasoulzadeh

👨‍💻
Coder
View GitHub Profile
///<summary>
///<para>StringBuilder with array</para>
///</summary>
public static String BuildString(System.Object[] array)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < array.Length; i++)
{
sb.Append(array[i]);
}
String s = BuildString(new System.Object[] { 1,"test",2,true });
//out put is : 1test2true
@arashrasoulzadeh
arashrasoulzadeh / WaitForRealSeconds.cs
Created July 9, 2016 17:34
wait for real seconds
public static IEnumerator WaitForRealSeconds(float time)
{
float start = Time.realtimeSinceStartup;
while (Time.realtimeSinceStartup < start + time)
{
yield return null;
}
}
yield return StartCoroutine (WaitForRealSeconds (0.5f));
//will be done after 0.5 seconds
@arashrasoulzadeh
arashrasoulzadeh / hexToColorUnity.cs
Created July 16, 2016 21:23
Hex Code to Color Variable in unity
public static Color hexToColor(string hex)
{
hex = hex.Replace("0x", "");//in case the string is formatted 0xFFFFFF
hex = hex.Replace("#", "");//in case the string is formatted #FFFFFF
byte a = 255;//assume fully visible unless specified in hex
byte r = byte.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
byte g = byte.Parse(hex.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
byte b = byte.Parse(hex.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
//Only use alpha if the string has enough characters
if (hex.Length == 8)
@arashrasoulzadeh
arashrasoulzadeh / returnUniqueID.cs
Created July 31, 2016 15:56
returnUniqueID of device
///<summary>
///<para>returns unique id of device </para>
///</summary>
public static String returnUniqueID (bool base64)
{
if (base64) {
username = UnityEngine.SystemInfo.deviceUniqueIdentifier;
byte[] bytesToEncode = System.Text.Encoding.UTF8.GetBytes (username);
return Convert.ToBase64String (bytesToEncode);
} else {
@arashrasoulzadeh
arashrasoulzadeh / touchspritedetect.cs
Created September 5, 2016 18:44
Detect touch on sprite , UNITY
public bool uiTouch (GameObject go)
{
if (go.GetComponent<SpriteRenderer> () != null)
if (Input.GetButtonUp ("Fire1") && go.activeInHierarchy) {
//Gets the world position of the mouse on the screen
Vector2 mousePosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
//Checks whether the mouse is over the sprite
bool overSprite = go.GetComponent<SpriteRenderer> ().bounds.Contains (mousePosition);

Keybase proof

I hereby claim:

To claim this, I am signing this object:

<?php
namespace arashrasoulzadeh\auth\src\traits;
use arashrasoulzadeh\auth\src\model\UserAuthMetas;
trait UserMetaTrait
{
/** @var array