(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| // This file is in the public domain. Where | |
| // a public domain declaration is not recognized, you are granted | |
| // a license to freely use, modify, and redistribute this file in | |
| // any way you choose. | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| // Unity remake of a fake volumetric light glow effect |
| //int vesioncode = context().getPackageManager().getPackageInfo(context().getPackageName(), 0).versionCode; | |
| public static int GetVersionCode() { | |
| AndroidJavaClass contextCls = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | |
| AndroidJavaObject context = contextCls.GetStatic<AndroidJavaObject>("currentActivity"); | |
| AndroidJavaObject packageMngr = context.Call<AndroidJavaObject>("getPackageManager"); | |
| string packageName = context.Call<string>("getPackageName"); | |
| AndroidJavaObject packageInfo = packageMngr.Call<AndroidJavaObject>("getPackageInfo", packageName, 0); | |
| return packageInfo.Get<int>("versionCode"); | |
| } | |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| import struct | |
| import SocketServer | |
| from base64 import b64encode | |
| from hashlib import sha1 | |
| from mimetools import Message | |
| from StringIO import StringIO | |
| # import threading | |
| class WebSocketsHandler(SocketServer.StreamRequestHandler): |
| using UnityEngine; | |
| using System.Collections; | |
| public class NaturalOrientation : MonoBehaviour { | |
| public static int ORIENTATION_UNDEFINED = 0x00000000; | |
| public static int ORIENTATION_PORTRAIT = 0x00000001; | |
| public static int ORIENTATION_LANDSCAPE = 0x00000002; | |
| public static int ROTATION_0 = 0x00000000; |
| import struct | |
| import SocketServer | |
| from base64 import b64encode | |
| from hashlib import sha1 | |
| from mimetools import Message | |
| from StringIO import StringIO | |
| class WebSocketsHandler(SocketServer.StreamRequestHandler): | |
| magic = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11' |
| function sendError(message, url, lineNum) { | |
| var i; | |
| // First check the URL and line number of the error | |
| url = url || window.location.href; | |
| lineNum = lineNum || 'None'; | |
| // If the error is from these 3rd party script URLs, we ignore | |
| // We could also just ignore errors from all scripts that aren't our own | |
| var scriptURLs = [ |
| // Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible). | |
| // Tweak the makePrettyJSON_ function to customize what kind of JSON to export. | |
| var FORMAT_ONELINE = 'One-line'; | |
| var FORMAT_MULTILINE = 'Multi-line'; | |
| var FORMAT_PRETTY = 'Pretty'; | |
| var LANGUAGE_JS = 'JavaScript'; | |
| var LANGUAGE_PYTHON = 'Python'; |
| Shader "Mobile/Ambient Diffuse Detail" { | |
| Properties { | |
| _Color ("Main Color", Color) = (1,1,1,1) | |
| _MainTex ("Base (RGB)", 2D) = "white" {} | |
| _Detail ("Detail (RGB)", 2D) = "gray" {} | |
| } | |
| SubShader { | |
| Pass{ | |
| // Drop this script in the Editor directory in your project (creating the Editor directory if it's not there yet) | |
| // Then re-import the assets in the directories covered by this script (right click and reimport) | |
| // | |
| // I would replace my path checking with the path checking from this gist: | |
| // https://gist.github.com/1842177 | |
| // | |
| // The texture settings for icons might want to use some of his settings combined with mine as well | |
| using UnityEngine; |