Skip to content

Instantly share code, notes, and snippets.

View randalfien's full-sized avatar

Ondřej Paška randalfien

View GitHub Profile
using UnityEngine;
using UnityEditor;
using Yarn.Unity;
using System.Collections.Generic;
using System.IO;
class YarnAssetPostProcessor : AssetPostprocessor
{
private const string ScriptFolder = "Assets/Yarn/";
private static readonly string _filePath = ScriptFolder + "YarnNodesRef.cs";
@randalfien
randalfien / BuildMenu.cs
Last active February 16, 2021 13:30
Unity Setup Automatic
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEngine;
using Debug = UnityEngine.Debug;
@randalfien
randalfien / MegaSnap
Last active October 1, 2020 17:08
Unity MegaSnap
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
public class SnapUtils
{
[MenuItem("Tools/Megasnap")]
private static void Snap()
{
GameObject[] rootObjects = SceneManager.GetSceneAt(0).GetRootGameObjects();
@randalfien
randalfien / ReplaceSpriteWindow.cs
Created March 1, 2020 14:50
Unity tool to replace a sprite across all scenes
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
/**
* Use this utility to replace one sprite with another across all scenes.
* This can be easily extended for other types as well (AudioClip, Material, etc...)
*/
public static class MyLogger
{
public const int LOG_TYPE_1 = 1;
public const int LOG_TYPE_2 = 2;
public const int LOG_TYPE_3 = 4;
public static int Flags = 1; // Bit flags to turn individual log types on/off
[System.Diagnostics.Conditional("DEBUG")] // All calls to this method will be stripped when compiling without the DEBUG symbol
public static void Log(string msg, int type = 0)
@randalfien
randalfien / MarkUnused.cs
Last active October 24, 2022 09:51
Unity Mark Unused Assets
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
public class MarkUnused
{
private const string UnusedLabel = "Unused"; // All unused assets will be tagged with this label
using UnityEditor;
using System.Text.RegularExpressions;
/*
This script gives you the option to assign assets to asset bundles based on the file names.
Change the string constants below to fit your needs
*/
public class AssetBundlesUtils
{
@randalfien
randalfien / boo.cs
Last active October 31, 2018 10:18
Spooky Unity
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
class BooPostprocessor : AssetPostprocessor
{
void OnPreprocessTexture() // called when a new texture is added or when you click Apply in texture importer inspector
{
TextureImporter textureImporter = (TextureImporter)assetImporter;
textureImporter.spritePixelsPerUnit = Random.Range(1, 100);
@randalfien
randalfien / MultipartImage.as
Last active February 3, 2016 16:56
Adobe AIR - Starling Image extension that let's you use a multipart image, similar to css background-position.
package cz.fishtrone.utils
{
import starling.display.Image;
import starling.textures.Texture;
/**
* Give a texture that is made of {parts} images, one below another, spaced evenly and specify which image {part} you want to see
*/
public class MultipartImage extends Image