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
| dispatch_async (dispatch_get_main_queue (), | |
| { | |
| // sume code here | |
| () | |
| }); |
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
| import UIKit | |
| // Usage example: | |
| // let deviceType : DeviceTypes = UIDevice().deviceType | |
| // let deviceName : String = deviceType.rawValue | |
| public enum DeviceTypes : String { | |
| case simulator = "Simulator", | |
| iPad2 = "iPad 2", |
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
| var data: [CGFloat] = [10, 50, 20, 5, 5, 10] | |
| let minValue = data.reduce(data[0], { min($0, $1) }) | |
| let maxValue = data.reduce(data[0], { max($0, $1) }) |
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
| let rates = responseDictionary["rates"] as NSDictionary | |
| let stringArray = rates.allKeys as [String] | |
| var dates = Array<NSDate>() | |
| for s in stringArray { | |
| dates.append(dateFormater.dateFromString(s)!) | |
| } | |
| dates.sort({$0.timeIntervalSinceNow < $1.timeIntervalSinceNow}) |
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
| extension Int { | |
| var ordinal: String { | |
| get { | |
| var suffix: String = "" | |
| var ones: Int = self % 10; | |
| var tens: Int = (self/10) % 10; | |
| if (tens == 1) { | |
| suffix = "th"; | |
| } else if (ones == 1){ |
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
| //Greg Lukosek 2015 | |
| //lukos86@gmail.com | |
| using UnityEngine; | |
| using UnityEditor; | |
| public class TexturePostProcessor : AssetPostprocessor | |
| { | |
| void OnPostprocessTexture(Texture2D texture) |
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 Bounds GetCombinedBounds(GameObject parent) { | |
| Bounds combinedBounds = new Bounds(); | |
| //grab all child renderers | |
| Renderer[] renderers = GetComponentsInChildren<Renderer>(GetComponent<Renderer>()); | |
| //grow combined bounds with every children renderer | |
| foreach (Renderer rendererChild in renderers) { |
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
| $ adb logcat | |
| and it will start printing out everything that is going on on the device. To limit it to only show the output from inside Unity, you can try this: | |
| $ adb logcat -s Unity | |
| or, to get a little bit more info about what's going on: | |
| $ adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG |
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
| void App::OnLaunched(LaunchActivatedEventArgs^ e) | |
| { | |
| m_SplashScreen = e->SplashScreen; | |
| InitializeUnity(e->Arguments); | |
| //these two lines | |
| auto av = Windows::UI::ViewManagement::ApplicationView::GetForCurrentView(); | |
| av->SetDesiredBoundsMode(Windows::UI::ViewManagement::ApplicationViewBoundsMode::UseCoreWindow); | |
| } |