Skip to content

Instantly share code, notes, and snippets.

@prime31
prime31 / prime31PostBuildCompletedEvent Example
Created December 13, 2012 01:35
Example of using the new prime31PostBuildCompletedEvent. This event is fired when the prime[31] post build system has completed modifying the Xcode project.
using UnityEngine;
using UnityEditor;
using System.Collections;
public class Test : MonoBehaviour
{
[MenuItem( "MyMenu/Hook up Post Build Event" )]
static void blah()
@prime31
prime31 / DontHideGetComponentCalls.cs
Created January 22, 2013 21:40
Simple fix for when you access any properties that hide GetComponent calls (such as transform, collider, renderer, etc)
public new Transform transform;
public new Collider collider;
public new Renderer renderer;
public new Rigidbody rigidbody;
void Awake()
{
transform = gameObject.transform;
collider = gameObject.collider;
// setup a semi-complex test object
var someObject = new SomeObject();
someObject.anotherObject = new AnotherObject();
someObject.anotherObjectList = new List<AnotherObject>
{
new AnotherObject(), new AnotherObject(), new AnotherObject(), new AnotherObject()
};
// serialize the class to json
var json = Json.jsonEncode( someObject );
function ValidateGooglePlaySignature( $responseData, $signature, $publicKey, &$status, &$response )
{
$responseData = trim( $responseData );
$signature = trim( $signature );
$response = json_decode( $responseData );
// Create an RSA key compatible with openssl_verify from our Google Play sig
$key = "-----BEGIN PUBLIC KEY-----\n".
chunk_split($publicKey, 64,"\n").
'-----END PUBLIC KEY-----';
@prime31
prime31 / gist:5628356
Last active December 17, 2015 14:59
Example of Parse access from Unity
public class TestClass : ParseObject
{
public string someOtherVar;
public Dictionary<string, object> dict;
}
_parse = new Parse( "SNIPPED", "SNIPPED" );
// create object manually
@prime31
prime31 / gist:5675017
Last active April 2, 2024 03:55
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
export "CODESIGN_ALLOCATE=\"/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate\""
# run this for each bundle executable in the Contents/Plugins folder
codesign string.Format( "-f -s \"{0}\" {1} \"{2}\"", certificateName, entitlementsCommand, pathToApp )
productbuild string.Format( "--component \"{0}\" /Applications --sign \"{1}\" --product \"{2}\" \"{3}\"", _pathToAppBundle, _certificateSigner, plistPath, packageFilename )
@prime31
prime31 / P31Prefs.cs
Created July 12, 2013 16:29
Lastest P31Prefs class
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Prime31;
#if UNITY_IPHONE
public class P31Prefs
{
public static bool iCloudDocumentStoreAvailable { get { return _iCloudDocumentStoreAvailable; } }
@prime31
prime31 / Unity Android Activity Sharing
Last active August 22, 2019 15:19
Instructions to make a plugin that needs to override the Unity Activity play nice with others.
In order to take part in the Unity Activity sharing system, there are a few steps you will need to take outlined below. First, some background. You can signify which class you would like to receive all the Activity lifecycle methods. When you implement the methods they should have the exact same signature but they should be *public static void*. That is important! They will not be called if they are not public static void. You can implement 1 or all of the methods. That is entirely up to your needs.
1. Download the Prime31UnityActivity.jar file from here: https://app.box.com/s/xw6hq1ltjaniycc14j21 You are free to distribute the file but *do not change it's name*! That would defeat the purpose of the sharing mechanism!
2. Implement any of the methods that are available in this Gist (https://gist.github.com/prime31/10747997)
3. Perform the AndroidManifest changes below
If successful, on app launch you will see a log that looks like the following:
@prime31
prime31 / Facebook Post Process Fix
Last active December 22, 2015 04:29
Fixes Facebook's post build system to make it compatible with ours
Open the FacebookPostProcess.cs file and find the following line:
[PostProcessBuild]
Change the line to be:
[PostProcessBuild( 999 )]