Skip to content

Instantly share code, notes, and snippets.

@capyvara
capyvara / gist:5230032
Last active May 18, 2018 19:25
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.
// 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
@capyvara
capyvara / Singletons.cs
Created September 17, 2013 22:09
MonoBehaviour based singletons
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 / CSharpProjectProcessor.cs
Last active February 12, 2016 18:15
PostProcessor for MonoDevelop project files in Unity
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
public class CSharpProjectProcessor : AssetPostprocessor
{
[MenuItem("Assets/Clean MonoDevelop Files")]
static void CleanMonoDevelopFiles()
{
@capyvara
capyvara / gist:63ced16b9033108a9574bb953969553a
Created May 19, 2018 23:09
UNET transport layer structs
// 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;
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; } }