Skip to content

Instantly share code, notes, and snippets.

View JakubNei's full-sized avatar

Jakub Nei JakubNei

View GitHub Profile
@JakubNei
JakubNei / DependencyAttribute.cs
Last active June 8, 2023 17:15
Beginnings of simple one dependency injection. For: https://github.com/aeroson/mcs-ICodeCompiler/issues/6
using System;
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class DependencyAttribute : Attribute
{
}
@JakubNei
JakubNei / MyQuaternion.cs
Last active June 8, 2023 17:14
A custom completely managed implementation of UnityEngine.Quaternion. Base is decompiled UnityEngine.Quaternion. Doesn't implement methods marked Obsolete. Does implicit coversions to and from UnityEngine.Quaternion
using System;
using UnityEngine.Internal;
using UnityEngine;
using System.Runtime.Serialization;
using System.Xml.Serialization;
/// <summary>
/// Quaternions are used to represent rotations.
/// A custom completely managed implementation of UnityEngine.Quaternion
/// Base is decompiled UnityEngine.Quaternion
@JakubNei
JakubNei / ComponentsCopier.cs
Last active January 31, 2023 05:41
A simple little editor extension to copy and paste all components
/*
A simple little editor extension to copy and paste all components
Help from http://answers.unity3d.com/questions/541045/copy-all-components-from-one-character-to-another.html
license: WTFPL (http://www.wtfpl.net/)
author: aeroson
*/
using UnityEngine;
using UnityEditor;
@JakubNei
JakubNei / Screen Gray.shader
Last active January 17, 2023 21:43
Unity screen grayscale grabpass overlay shader for Unity's default quad mesh that can be put onto objects. Due to frustum culling it is only visible if the quad is in camera's view. If you want it to be visible more you can scale the the quad transform up to make the bounding box/sphere bigger. If you need this grayscale effect all the time, it …
// Unity screen grayscale grabpass overlay shader for Unity's default quad mesh that can be put onto objects.
// Due to frustum culling it is only visible if the quad is in camera's view.
// If you want it to be visible more you can scale the the quad transform up to make the bounding box/sphere bigger.
// If you need this grayscale effect all the time, it would make more sense to instead use post processing shader/stack.
// license: Unlicense
Shader "FX/Screen Gray"
{
Properties
{
@JakubNei
JakubNei / DeferredSynchronizeInvoke.cs
Last active January 11, 2023 11:06
Implementation of ISynchronizeInvoke for Unity3D game engine. Can be used to invoke anything on main Unity thread. ISynchronizeInvoke is used extensively in .NET forms, it's is elegant and quite useful in Unity as well. I implemented it so i can use it with System.IO.FileSystemWatcher.SynchronizingObject.
/*
Implementation of ISynchronizeInvoke for Unity3D game engine.
Can be used to invoke anything on main Unity thread.
ISynchronizeInvoke is used extensively in .NET forms, it's is elegant and quite useful in Unity as well.
I implemented it so i can use it with System.IO.FileSystemWatcher.SynchronizingObject.
help from: http://www.codeproject.com/Articles/12082/A-DelegateQueue-Class
example usage: https://gist.github.com/aeroson/90bf21be3fdc4829e631
version: aeroson 2017-07-13 (author yyyy-MM-dd)
using System;
using UnityEngine;
public static class ApplicationState
{
/// <summary>
/// Is editor either currently in play mode, or about to switch to it?
/// </summary>
public static bool isPlayingOrWillChangePlaymode { get { return Application.isEditor ? InternalEditorState.isPlayingOrWillChangePlaymode : true; } }
/// <summary>
//
// Mono.CSharp CSharpCodeCompiler Class implementation
//
// Authors:
// Sean Kasun (seank@users.sf.net)
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// Copyright (c) Novell, Inc. (http://www.novell.com)
//
@JakubNei
JakubNei / Bounding26Dop.cpp
Last active October 5, 2021 11:16
Unreal Engine Bounding 26 DOP, Implements discrete oriented polytopes (DOP for short). Is an extension of bounding box, box has 6 directions and represents 6 distances, 26 DOP has 26 directions and represents 26 distances in those directions . Has similar API as UE4's FSphere, FBox and FBoxSphereBounds.
#include "Bounding26Dop.h"
#include "Math/UnrealMathUtility.h"
#include "Containers/UnrealString.h"
#include "Logging/LogMacros.h"
#include "Engine/Polys.h"
#include "DrawDebugHelpers.h"
#include "GenericPlatform/GenericPlatformMath.h"
#include "Async/ParallelFor.h"
#include "Serialization/StructuredArchiveFormatter.h"
@JakubNei
JakubNei / NeitriUnityExtensions.cs
Created July 10, 2017 02:05
Collection of useful Unity3D extensions I've made over the years. I usually carry this to any project I work on.
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Version: 2017-07-06 (yyyy-MM-dd)
/// Many useful Unity3D extensions I've made over the years.
/// All in one class.
/// </summary>
public static class NeitriUnityExtensions
{
// #define USE_VEXE_FAST_REFLECTION // download it at https://github.com/vexe/Fast.Reflection increases reflection invoke performance significantly
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Reflection;
#if USE_VEXE_FAST_REFLECTION