Skip to content

Instantly share code, notes, and snippets.

View AGeorgy's full-sized avatar

George Ananchenko AGeorgy

View GitHub Profile
@LotteMakesStuff
LotteMakesStuff / EditorDispatcher.cs
Last active February 13, 2024 13:22
Allows threaded Unity Editor code to dispatch an action or coroutine to the main thread.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEditor;
using UnityEngine;
public static class EditorDispatcher
{
private static readonly Queue<Action> dispatchQueue = new Queue<Action>();
@ulrikdamm
ulrikdamm / EditPrefab.cs
Last active May 14, 2024 16:41
Unity editor script for better editing of prefabs. Put in Assets/Editor.
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
// Adds a "Edit Prefab" option in the Assets menu (or right clicking an asset in the project browser).
// This opens an empty scene with your prefab where you can edit it.
// Put this script in your project as Assets/Editor/EditPrefab.cs
public class EditPrefab {
static Object getPrefab(Object selection) {
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System;
using System.IO;
public static class CopyFilesBuildPostProcessor
{
private const string PathToCopy = "PathToFiles";
Shader "KumoKairo/Gradient Moon Skybox"
{
Properties
{
_SkyTint("Sky Tint", Color) = (.5, .5, .5, 1)
_GroundColor("Ground", Color) = (.369, .349, .341, 1)
_Exponent("Exponent", Range(0, 15)) = 1.0
_SunPosition("Sun Position", Vector) = (0.0, 0.0, 1.0)
_SunColor("Sun Color", Color) = (1.0, 1.0, 1.0, 1.0)
@LotteMakesStuff
LotteMakesStuff / TrafficLightAttribute.cs
Last active April 8, 2025 21:13
TrafficLight control/layout/property drawer: Adds a new editor control that draws lil Traffic Lights in the inspector. its really useful for visualizing state. For example, checkboxes can be hard to read at a glace, but a Red or Green status light is easy! Recommend you use the attached package, as it has all the icon image files.
// Non Editor code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class TrafficLightAttribute : PropertyAttribute
{
public bool DrawLabel = true;
public string CustomLabel;
public bool AlsoDrawDefault;
@mzaks
mzaks / EntitasBT.cs
Last active July 24, 2017 09:37
A behaviour tree system for Entitas
public sealed class BTSystem: IExecuteSystem
{
IBehaviorNode rootNode;
public BTSystem(IBehaviorNode rootNode)
{
this.rootNode = rootNode;
}
void Execute()
{
@mzaks
mzaks / AbstractEventLogger.cs
Created July 8, 2017 10:53
Event Logger for Entitas-CSharp
using System;
using System.Collections.Generic;
namespace Entitas
{
public abstract class AbstractEventLogger : IEventLogger
{
private readonly Dictionary<Pool, byte> poolIdmap = new Dictionary<Pool, byte>();
private readonly Dictionary<Entity, byte> poolIdmapForEntity = new Dictionary<Entity, byte>();
protected string[] poolNames;
@LotteMakesStuff
LotteMakesStuff / StaticCoroutineRunner.cs
Created June 19, 2017 22:32
Ever wanted to run a Unity Coroutine from game code thats not in a MonoBehaviour (for example, a static manager class). Now you can friends!! this class automates creating a dummy game object to run your coroutine and cleans itself up automagically when the routine has finished
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CoroutineRunner : MonoBehaviour
{
public static void RunCoroutine(IEnumerator coroutine)
{
var go = new GameObject("runner");
DontDestroyOnLoad(go);
[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget buildTarget, string pathToBuildProject)
{
if (buildTarget != BuildTarget.iOS)
return;
StripMethods(pathToBuiltProject);
}
private static string[] s_stripList =
@FNGgames
FNGgames / TimerSystem.cs
Last active October 20, 2021 10:05
Entitas Timer System
using Entitas;
using UnityEngine;
public class TimerSystem : IExecuteSystem, ICleanupSystem
{
readonly IGroup<GameEntity> _timers;
readonly IGroup<GameEntity> _timerCompletes;
readonly GameContext _context;
public TimerSystem(Contexts contexts)