Skip to content

Instantly share code, notes, and snippets.

View GenerateLinkXml.cs
using UnityEditor.Build.Pipeline;
using UnityEditor.Build.Pipeline.Injector;
using UnityEditor.Build.Pipeline.Interfaces;
public class GenerateLinkXml : IBuildTask
{
public static readonly string LinkXmlFilename = "link.xml";
public int Version { get { return 1; } }
View gist:63ced16b9033108a9574bb953969553a
// Source: https://forum.unity.com/threads/binary-protocol-specification.417831/
//all 16 and 32 bit data are network ordered
//message length occupy 1 byte length if first bit == 0 or 2 bytes if it equal 1:
int SetLength(char* buffer, uint16_t messageLength)
{
int messageLengthSize = (messageLength > 0x7F) ? 2 : 1;
if (messageLengthSize == 1)
{
*buffer = (uint8_t)messageLength;
@capyvara
capyvara / CSharpProjectProcessor.cs
Last active Feb 12, 2016
PostProcessor for MonoDevelop project files in Unity
View CSharpProjectProcessor.cs
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
public class CSharpProjectProcessor : AssetPostprocessor
{
[MenuItem("Assets/Clean MonoDevelop Files")]
static void CleanMonoDevelopFiles()
{
@capyvara
capyvara / Singletons.cs
Created Sep 17, 2013
MonoBehaviour based singletons
View Singletons.cs
using UnityEngine;
namespace Framework
{
/// <summary>
/// Simple singleton, automatically find a instance and caches it
/// Implementors should make all public methods and properties as static and access Instance
/// </summary>
public abstract class Singleton<T> : MonoBehaviour where T: MonoBehaviour
{
@capyvara
capyvara / gist:5230032
Last active May 18, 2018
Process the Unity generated Xcode project to allow dSYM generation on Release but keeping the distribution size the same, only tested in a clean generated project.
View gist:5230032
// Adjust dSYM generation
var xcodeProjectPath = Path.Combine(xcodeProjectDir, "Unity-iPhone.xcodeproj");
var pbxPath = Path.Combine(xcodeProjectPath, "project.pbxproj");
var sb = new System.Text.StringBuilder();
var xcodeProjectLines = File.ReadAllLines(pbxPath);
foreach (var line in xcodeProjectLines)
{
// Remove from OTHER_LDFLAGS