Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View SiarheiPilat's full-sized avatar
🍌
Working from home

spilat12 SiarheiPilat

🍌
Working from home
View GitHub Profile
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
// NOTE: This DOES work, but need to do it twice??
// This is only useful for spritesheets that need to be automatically sliced (Sprite Editor > Slice > Automatic)
public class AutoSpriteSlicer
@SiarheiPilat
SiarheiPilat / MultiScreenshotCapture.cs
Last active January 13, 2024 11:55 — forked from yasirkula/MultiScreenshotCapture.cs
Capture multiple screenshots with different resolutions simultaneously in Unity 3D
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace MultiScreenshotCaptureNamespace
{
internal static class ReflectionExtensions
@SiarheiPilat
SiarheiPilat / IncrementBuildNumber.cs
Created March 8, 2023 03:32 — forked from martinpi/IncrementBuildNumber.cs
Automatically increment the iOS build number in Unity conforming to Apple's guidelines before every build. Be sure to drop into a folder name "Editor". Worked in autumn 2020.
using UnityEngine;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor;
public class IncrementBuildNumber : IPreprocessBuildWithReport {
public int callbackOrder { get { return 0; } } // Part of the IPreprocessBuildWithReport interface
public void OnPreprocessBuild(BuildReport report) {
if (report.summary.platform == BuildTarget.iOS) {
@SiarheiPilat
SiarheiPilat / CreateScriptAsset.cs
Created January 13, 2022 15:05 — forked from johnsoncodehk/CreateScriptAsset.cs
Create script from template in project
// Not support of 2019.1.0f1
static void CreateScriptAsset(string templatePath, string destName) {
#if UNITY_2019_1_OR_NEWER
UnityEditor.ProjectWindowUtil.CreateScriptAssetFromTemplateFile(templatePath, destName);
#else
typeof(UnityEditor.ProjectWindowUtil)
.GetMethod("CreateScriptAsset", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
.Invoke(null, new object[] { templatePath, destName });
#endif
@SiarheiPilat
SiarheiPilat / ReplaceWithPrefab.cs
Last active September 20, 2022 23:01 — forked from unity3dcollege/ReplaceWithPrefab.cs
Updated for the latest API. Accounts for original prefabs and variants.
using UnityEngine;
using UnityEditor;
/// Taken from: https://gist.github.com/SiarheiPilat/05463e64d4662860c6a799bb23d9aec8
/// Forked from: https://gist.github.com/unity3dcollege/c1efea3f87d3775bee3e010e9c6d7648
/// Author: Siarhei Pilat (Suasor AB)
/// License: MIT
public class ReplaceWithPrefab : EditorWindow
{