Skip to content

Instantly share code, notes, and snippets.

View gekidoslair's full-sized avatar
💭
Surfin the Chaos

Mike Wuetherick gekidoslair

💭
Surfin the Chaos
View GitHub Profile
@gekidoslair
gekidoslair / SpawnOnAwake.cs
Created December 16, 2022 21:54
Simple class that allows you to spawn / instantiate any number of prefab game objects when a Unity scene loads. Useful for Bootstrap scenes & more
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace PixelWizards.GameSystem.Controllers
{
/// <summary>
/// Spawns any number of prefabs on Awake() when the scene loads
/// </summary>
public class SpawnOnAwake : MonoBehaviour
@gekidoslair
gekidoslair / OnlyOneCanSurvive.cs
Created October 12, 2021 02:19
Unity - Only One Can Survive
using UnityEngine;
namespace PixelWizards.GameSystem.Controllers
{
/// <summary>
/// Lets us include specific prefabs in multiple scenes and make sure we don't end up with duplicates in the end
/// sort of an inverse singleton pattern. Basically add this to a prefab, then add that prefab into any scene and
/// no matter what only one is ever active
/// </summary>
public class OnlyOneCanSurvive : MonoBehaviour
PHP script that uses Unity Publisher API for PHP (https://github.com/LostPolygon/Unity-Publisher-API-PHP) to retrieve new asset sales, put them into a MySQL database, and notify about the sales via e-mail.
Data is inserted into `sales` table, which can be created from sales_table.sql file. Just set up the credentials and put this script on cron with whatever interval you want. Delete the email notification part if you don't need it.
Requires PHP 5.4, php_json extension, and remote socket access.
Also, I know it's ugly, but it does the job and served me well for over a year.
@gekidoslair
gekidoslair / SetShadowQuality.cs
Last active March 10, 2021 06:05 — forked from Nobuyuki-Kobayashi/SetShadowQuality.cs
Configure Unity's built in Shadow Settings from script at runtime QualitySettings.shadowCascade4Split
//
// QualitySettings/Shadows内のShadow Distance/Shadow Cascades/Cascade splitsをシーンから設定する.
//
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace UnityChan
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
/// <summary>
/// A simple free camera to be added to a Unity game object.
///
/// Keys:
@gekidoslair
gekidoslair / photon-pun-cheatsheet.md
Created July 3, 2020 17:51 — forked from ssshake/isWrit
Photon PUN Cheat Sheet

Photon Methods

public class Blank : Photon.PunBehaviour

instead of mono behavior, use this to receive photon callbacks in your script.

public override void OnLeftRoom()

An example of overriding a punbehavior callback

@gekidoslair
gekidoslair / EditorNote.cs
Last active May 30, 2020 16:51
Add to any gameobject to provide scene-view annotations
using UnityEditor;
using UnityEngine;
namespace PixelWizards.Utilities
{
public class EditorNote : MonoBehaviour
{
[TextArea]
public string m_Text;
public Vector3 m_Offset;
@gekidoslair
gekidoslair / BoneDebug.cs
Created April 13, 2020 23:00
Simple tool that displays all of the bones that a particular mesh is bound to - useful for debugging skin weighting etc
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class BoneDebug : MonoBehaviour
{
SkinnedMeshRenderer skm;
public List<Transform> bones = new List<Transform>();
@gekidoslair
gekidoslair / TextureProcessor.cs
Last active April 13, 2020 18:30
Batch apply textures to materials
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[System.Serializable]
public class MaterialEntry
{
public Material material;
public List<Texture2D> textures;
@gekidoslair
gekidoslair / textureassign.cs
Created February 18, 2020 01:34
Add textures to a material based on a naming convention
/// <summary>
/// Grab the end of the string for our naming convention and see if it matches a known convention
/// </summary>
/// <param name="texture"></param>
/// <param name="material"></param>
private static void SetTexture(Texture2D texture, Material material)
{
var split = texture.name.Split('_');
var idx = split.Length - 1;
// Debug.Log("Postfix for texture: " + texture.name + " : " + split[idx]);