Skip to content

Instantly share code, notes, and snippets.

View SiarheiPilat's full-sized avatar
:octocat:
Working from home

suasor SiarheiPilat

:octocat:
Working from home
  • Suasor AB
  • Malmö, Sweden
View GitHub Profile
using UnityEngine;
using UnityEditor;
public class ReplaceWithPrefab : EditorWindow
{
[SerializeField] private GameObject prefab;
[MenuItem("Tools/Replace With Prefab")]
static void CreateReplaceWithPrefab()
{
@fishtopher
fishtopher / ShortcutCollisionChecker.cs
Created December 5, 2017 11:21
A little Unity utility to check for shortcut key collisions because it's hard to know if you're duplicating one from anywhere else.
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
// Little utility to check for shortcut key collisions because it's hard to
// know if you're duplicating one from anywhere else.
@Lazersquid
Lazersquid / Reference.cs
Last active January 30, 2023 19:44
Unity generic scriptable object variable reference pattern
using System;
/// <summary>
/// Reference Class.
/// </summary>
[Serializable]
public abstract class Reference
{
}
@runewake2
runewake2 / ProjectileReflectionEmitterUnityNative.cs
Created January 16, 2018 05:37
Demonstrates a projectile reflecting in 3D Space a variable number of times in Unity 3D
using UnityEditor;
using UnityEngine;
/*
* Projectile reflection demonstration in Unity 3D
*
* Demonstrates a projectile reflecting in 3D space a variable number of times.
* Reflections are calculated using Raycast's and Vector3.Reflect
*
* Developed on World of Zero: https://youtu.be/GttdLYKEJAM
@Happsson
Happsson / InactiveCodeDetector.cs
Last active September 14, 2023 15:35
A script that lets you find unused scripts in your unity projects.
/*
This tool iterates through all the files in your project and checks for scripts.
It then goes through all the GameObjects in all the scenes in the project, and
checks for scripts that are not present on any GameObjects.
Note that this does not mean that the script is not used, just that it is possible that it isn't.
The script could still be used in many other ways. This tool is just to narrow the search for
unused code.
// Launch Arc Renderer for Unity 3D from this Tutorial (with minor fixes):
// https://www.youtube.com/watch?v=iLlWirdxass
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent (typeof(LineRenderer))]
public class LaunchArcRenderer : MonoBehaviour {
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
// This is only useful for spritesheets that need to be automatically sliced (Sprite Editor > Slice > Automatic)
public class AutoSpriteSlicer
{
[MenuItem("Tools/Slice Spritesheets %&s")]
@TiborUdvari
TiborUdvari / ExcemptFromEncryption.cs
Last active December 18, 2024 11:01
Marks ITSAppUsesNonExemptEncryption in Unity generated Info.plist file to false. Doing this no longer requires manually marking the app as not using non-exempt encryption in iTunes Connect for Testflight beta testing.
using UnityEngine;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor;
using UnityEditor.iOS.Xcode;
using System.IO;
public class ExcemptFromEncryption : IPostprocessBuildWithReport // Will execute after XCode project is built
{
public int callbackOrder { get { return 0; } }
@johnsoncodehk
johnsoncodehk / CreateScriptAsset.cs
Last active January 18, 2024 10:00
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
@ssshake
ssshake / isWrit
Last active June 21, 2024 10:28
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