Skip to content

Instantly share code, notes, and snippets.

@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
@prime31
prime31 / FilePicker.cs
Last active November 20, 2023 02:03
Simple file and folder picker for ImGui.Net
using ImGuiNET;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using Num = System.Numerics;
namespace Nez.ImGuiTools
{
public class FilePicker
@prime31
prime31 / Program.cs
Last active November 16, 2023 10:32
C# Basic ECS implementation example. Not production ready, optimized or even fully functional. It is here to illustrate the patterns for creating an ECS from scratch.
using System;
namespace SimpleECS
{
struct Position
{
public float X, Y;
}
struct Velocity
@prime31
prime31 / ldtk.zig
Created November 4, 2023 23:57
LDtk export from json schema
pub const Ld = struct {
description: []const u8,
title: []const u8,
// renamed from: "$schema
schema: []const u8,
// renamed from: "$ref
ref: []const u8,
version: []const u8,
// renamed from: "LdtkJsonRoot
ldtk_json_root: LdtkJsonRoot,
@prime31
prime31 / Activity Sharing Methods
Last active June 20, 2023 03:04
This is a list of all the available methods for the prime[31] Unity Activity sharing system.
public static void onCreate( Bundle savedInstanceState )
public static void onActivityResult( int request, int response, Intent data )
public static void onRequestPermissionsResult( int requestCode, String[] permissions, int[] grantResults )
public static void onNewIntent( Intent intent )
public static void onStart()
@prime31
prime31 / glowy.wgsl
Created March 28, 2023 14:34
Bevy Material Example
#import bevy_pbr::mesh_view_bindings
#import bevy_pbr::mesh_bindings
#import bevy_pbr::pbr_types
#import bevy_pbr::utils
#import bevy_pbr::clustered_forward
#import bevy_pbr::lighting
#import bevy_pbr::shadows
#import bevy_pbr::pbr_functions
@prime31
prime31 / ExampleUsage.cs
Last active October 24, 2022 09:51 — forked from MattRix/ObjectInspector.cs
Generic inspector class that lets you implement OnScene/InspectorGUI in your class file instead of in a separate custom editor. It also provides attributes for getting Vector3/Vector3[]/List<Vector3> editing capabilities right in the scene view and getting buttons for any methods in your class in the inspector.
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class ExampleUsage : MonoBehaviour
{
// this attribute will add handles for your Vector3s so that you can drag them around in the scene view
@prime31
prime31 / Blobs.cs
Created March 17, 2021 23:07
Unmanaged Resources
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Nez.Unmanaged
{
unsafe public struct BlobAllocator : IDisposable
{
byte* m_RootPtr;
@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 / StripGeneratedSolutionSettings
Created May 2, 2015 19:02
Stick this in an Editor folder in your project. Every time the solution file is recreated by Unity it will remove all the cruft that Unity injects into the file. Hopefully, one day, Unity will actually fix this on their end.
/*
v2: Matt Rix pointed out there's an undocumented ONGeneratedCSProjectFiles() callback
https://gist.github.com/MattRix/0bf8de88e16e8b494dbb
v1: Still available in the gist history if you want a FileSystemWatcher solution!
THE PROBLEM:
- Unity constantly rewrites its .sln files whenever you rename/add/remove scripts