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 UnityEditor;
using UnityEngine;
/// <summary>
/// Folder organizer editor window.
/// http://diegogiacomelli.com.br/using-an-assetpostprocessor-editorwindow-to-keep-assets-organized-on-unity-projects
/// </summary>
public class FolderOrganizerEditorWindow : EditorWindow
{
FolderOrganizerSettings _settings;
@LotteMakesStuff
LotteMakesStuff / LayoutUtils.cs
Last active November 2, 2023 21:04
Simple tool for importing editor layout files (.wlt files) from the asset folder. this is cool cos you can then share layouts with your team via source control
// put me in an Editor folder
using System.IO;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
public static class LayoutUtils
{
// unity stores layouts in a path referenced in WindowLayout.LayoutsPreferencesPath.
// Unfortunately, thats internal - well just creat the path in the same way they do!
@LotteMakesStuff
LotteMakesStuff / AutohookAttribute.cs
Last active January 2, 2024 13:54
[Autohook] property drawer for unity - Add this [Autohook] attribute to a property to and the inspector will automagically hook up a valid reference for you if it can find a component attached to the same game object that matches the field you put it on. You can watch a demo of this in action here https://youtu.be/faVt09NGzws <3
// NOTE DONT put in an editor folder!
using UnityEngine;
public class AutohookAttribute : PropertyAttribute
{
}
@lawrence-laz
lawrence-laz / BaseBehaviour.cs
Created November 30, 2018 18:00
Automatically get components in Unity using [GetComponent] attribute
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;
public class BaseBehaviour : MonoBehaviour
{
protected virtual void OnEnable()
{
@satanas
satanas / scrolling_bg.md
Last active December 29, 2023 01:07
Scrolling Background in Unity

Scrolling Background in 2D

  1. Select the original Texture (not the GameObject).
  2. Change Texture Type to Sprite (2D and UI).
  3. Change Wrap Mode to Repeat.
  4. Click Apply.
  5. Create a Quad object: GameObject -> 3D Object ->Quad.
  6. Scale the Quad to the size you want.
  7. Create a light: GameObject->Light->Directional Light.
  8. Adjust the light intensity to whatever you like.
@James-Frowen
James-Frowen / ExampleInterface.cs
Last active July 20, 2023 15:07
Unity3d, How to show an interface field in Inspector
namespace JamesFrowen
{
public interface ISomeInterface
{
void SomeMethod();
}
[System.Serializable]
public class SomeInterfaceWrapper : InterfaceWrapper<ISomeInterface>
{
@Syy9
Syy9 / UnityEditorWindowHelper.cs
Created July 28, 2018 07:32
How to get Unity default EditorWindow (Game, Scene, Hierarchy...)
using UnityEngine;
using UnityEditor;
using System;
public enum WindowType
{
Game,
Scene,
Hierarchy,
Console,
@Syy9
Syy9 / GetUnityTypes.cs
Last active November 4, 2022 13:02
How to get all EditorWindow types in Unity
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
public static class GetUnityTypes
{
public static List<Type> GetEditorWindowTypes()
{
var result = GetSubClassTypes<EditorWindow>();
@ssshake
ssshake / isWrit
Last active September 29, 2023 06:15
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
@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