Skip to content

Instantly share code, notes, and snippets.

@voxelbustersold
voxelbustersold / Demo.cs
Created September 27, 2019 18:14
Game Center External Authentication
IEnumerator VerifySignature(ExternalAuthenticationCredentials credentials)
{
WWWForm form = new WWWForm();
form.AddField("publicKeyUrl", credentials.iOSCredentials.PublicKeyURL);
form.AddField("timestamp", System.Convert.ToString(credentials.iOSCredentials.Timestamp));
form.AddField("signature", System.Convert.ToBase64String(credentials.iOSCredentials.Signature));
form.AddField("salt", System.Convert.ToBase64String(credentials.iOSCredentials.Salt));
form.AddField("playerId", NPBinding.GameServices.LocalUser.Identifier);
form.AddField("bundleId", NPBinding.Utility.GetBundleIdentifier());
@voxelbustersold
voxelbustersold / MailSharing.cs
Created August 30, 2019 13:28
CPNP 2.0 Mail Sharing
using UnityEngine;
using System.Collections;
using VoxelBusters.NativePlugins;
public class ExampleClass : MonoBehaviour
{
public void Start()
{
if (MailComposer.CanSendMail())
{
@voxelbustersold
voxelbustersold / ShareImageOnInstagram.cs
Created January 4, 2019 08:28
Share image on Instagram from Unity - http://u3d.as/1pMn
using VoxelBusters.InstagramKit;
void ShareImage(string filePath)
{
// Create Story Content Instance
StoryContent content = new StoryContent(filePath, false);
InstagramKitManager.Share(content, OnShareComplete);
}
private void OnShareComplete(bool success, string error)
@voxelbustersold
voxelbustersold / IsServiceAvailable.cs
Last active January 4, 2019 08:41
Instagram Kit for Unity
using VoxelBusters.InstagramKit;
public void IsAvailable()
{
bool isAvailable = InstagramKitManager.IsAvailable();
string message = isAvailable ? "Instagram Kit is available!" : "Instagram Kit is not available. Instagram app may not be installed.";
Debug.Log(message);
}
@voxelbustersold
voxelbustersold / CopyFileToPersistentPath.cs
Created January 4, 2019 07:53
Copy any file to Persistent Path
// Namespace for using utility functions
using VoxelBusters.InstagramKit.Common.Utility;
// Path can be from local or web
private void DownloadFileToPersistentPath(string filePath, string targetFileName)
{
// Downloading if the file doesn't exist
if (!FileOperations.Exists (Application.persistentDataPath + "/" + targetFileName))
{
// Download file from given path
@voxelbustersold
voxelbustersold / SaveTextureToPersistentPath.cs
Last active January 4, 2019 07:50
Save Texture2D to Persistent Path
// Required Namesapce for using Utitlity Functions
using VoxelBusters.InstagramKit.Common.Utility;
// You need pass a texture2D which is marked as Readable in its inspector and pass saveName with extension. Ex: photo.png or photo.jpg
void SaveImage(Texture2D image, string saveName)
{
byte[] data = null;
if (saveName.EndsWith("png"))
{
data = ImageConversion.EncodeToPNG(image);
using UnityEngine;
using System.Collections;
namespace VoxelBusters.NativePlugins
{
/// <summary>
/// This provides unique access to a product which is purchasable. This encloses details for accessing different properties of a in-app product.
/// </summary>
[System.Serializable]
public class BillingProduct
@voxelbustersold
voxelbustersold / SelectiveRendering.cs
Created September 1, 2015 14:27
Selective Rendering
using UnityEngine;
using System.Collections;
//Ideally can use Layers but want to avoid as, max layers avaialble isn't a big number.
public class SelectiveRendering : MonoBehaviour
{
//Working version - Can expect as transform values are required for rendering. But not sure if this is optimal way.
[SerializeField]
private GameObject[] m_targetObjects;