This file contains hidden or 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 ulong HexStringToUlong(this string str) | |
{ | |
return ulong.Parse(str, System.Globalization.NumberStyles.HexNumber); | |
} | |
[NotNull] | |
public static string UlongToHexString(this ulong num) | |
{ | |
return string.Format("{0:x}", num); | |
} |
This file contains hidden or 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
// Copyright 2015 Google Inc. All rights reserved. | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, |
This file contains hidden or 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
internal static class ProtoChangeColorHandler | |
{ | |
private static readonly string[] c_KeyWords = | |
{ | |
"default", "enum", "message", "import", "group", "package", | |
"extend", "extensions", "to", "max", | |
"service", "rpc", "returns", | |
"true", "false", | |
"required", "optional", "repeated", | |
"double", "float", "int32", "int64", "uint32", "uint64", |
This file contains hidden or 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or 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 bool TryGetPlayerInfoByUserName(string userName, out PlayerInfo playerInfo) | |
{ | |
IEnumerable<PlayerInfo> infoQuery = | |
from info in _PlayerInfoDic.Values | |
where info.UserName == userName | |
select info; | |
if (0 != infoQuery.Count()) | |
{ | |
playerInfo = infoQuery.First(); | |
return true; |
This file contains hidden or 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 class RandomMng | |
{ | |
private static Random random = new Random(); | |
public static int GetRandomInt32(ICollection<int> coll) | |
{ | |
int ret; | |
do | |
{ | |
ret = random.Next(); |
This file contains hidden or 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
copy $(TargetPath) $(TargetDir)..\..\..\$(TargetFileName) |
This file contains hidden or 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.Generic; | |
$if$ ($targetframeworkversion$ >= 3.5)using System.Linq; | |
$endif$using System.Text; | |
$if$ ($targetframeworkversion$ >= 4.5)using System.Threading.Tasks; | |
$endif$ | |
namespace $rootnamespace$ | |
{ | |
class $safeitemrootname$ | |
{ |
This file contains hidden or 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
// This sample function uses SharpZipLib (http://icsharpcode.github.io/SharpZipLib/) to extract | |
// a zip file without blocking Unity's main thread. Remember to call it with StartCoroutine(). | |
// Byte data is passed so a MemoryStream object is created inside the function to prevent it | |
// from being reclaimed by the garbage collector. | |
public IEnumerator ExtractZipFile(byte[] zipFileData, string targetDirectory, int bufferSize = 256 * 1024) | |
{ | |
Directory.CreateDirectory(targetDirectory); | |
using (MemoryStream fileStream = new MemoryStream()) |
This file contains hidden or 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
private IEnumerator CopyVersion() | |
{ | |
string _Version_txt_streamingAssetsPath = PathConf.VCRoot + "Version.txt"; | |
if (_Version_txt_streamingAssetsPath.Contains("://")) | |
{ | |
using (WWW www = new WWW(_Version_txt_streamingAssetsPath)) | |
{ | |
yield return www; | |
if (!string.IsNullOrEmpty(www.error)) | |
{ |