Skip to content

Instantly share code, notes, and snippets.

View nicloay's full-sized avatar
✌️

Nikolay nicloay

✌️
View GitHub Profile
@nicloay
nicloay / SetRendererLayerWizard.cs
Created January 28, 2014 16:42
Unity wizard to change sorting layer and order for one or several objects. Here http://youtu.be/lIx9j5o8uEQ you can find screencast how to use it
using UnityEngine;
using UnityEditor;
using System;
using System.Collections.Generic;
public class SetRendererLayerWizard : ScriptableWizard {
public Renderer renderer;
public Renderer[] rendererList;
public SortingLayer sortingLayer;
@nicloay
nicloay / ai.export.js
Created February 5, 2014 17:59
Export adobe illustrator visible layers to png files with the same layer name structure (layers->sublayers becomes folder->subfolders)
// Export Layers as PNG files with original layer structure
var options = new ExportOptionsPNG24();
var doc = app.activeDocument;
$.writeln("trying to save");
var newdoc = app.documents.add(doc.documentColorSpace, doc.width, doc.height);
newdoc.artboards[0].artboardRect = doc.artboards[0].artboardRect;
@nicloay
nicloay / spine_controller.cs
Created February 14, 2014 14:57
example controller which works with mecanim
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Rigidbody2D))]
public class KevinController : MonoBehaviour {
public float maxSpeed = 10f;
public float groundCheckRadius = 0.1f;
public LayerMask groundCechkLayerMask;
public float jumpForce = 100f;
public float runJumpForce = 200f;
@nicloay
nicloay / rotate.cs
Last active August 29, 2015 13:56
rotate around pivot issue
// enstead of this
GUIUtility.RotateAroundPivot(angle,
new Vector2(brushRect.x + brushRect.width * relativePivot.x,
brushRect.y + brushRect.height * relativePivot.y)
);
/////// should use
Matrix4x4 getMatrix(Rect rect){
Matrix4x4 result;
@nicloay
nicloay / gist:9466391
Last active August 29, 2015 13:57 — forked from supairish/gist:2951524
http://habrahabr.ru/post/215233/ protect nginx from google DDOS + http://habrahabr.ru/post/215543/ (wordpress DDOS)
http {
map $http_user_agent $limit_bots {
default '';
~*(google|bing|yandex|msnbot|wordpress) $binary_remote_addr;
}
limit_req_zone $limit_bots zone=bots:10m rate=1r/m;
server {
@nicloay
nicloay / LiftingPlatformController.cs
Last active August 29, 2015 13:57
Unity3d lifting platform (no lag) dont use it!!! see https://gist.github.com/nicloay/9662874
using UnityEngine;
using System.Collections;
public class LiftingPlatformController : MonoBehaviour {
public float routeLenght = 10;
public float verticalSpeed = 10;
[Range (0,1)]
public float startRelativePosition=0;
@nicloay
nicloay / HorizontalMovePlatformController.cs
Last active August 29, 2015 13:57
Unity3d horizontal mobile platform controller. no lag with physics. don't use it.. see https://gist.github.com/nicloay/9662874
public class HorizontalMovePlatformController : MonoBehaviour {
public float routeLenght = 10;
public float horizontalSpeed = 10;
[Range (0,1)]
public float startRelativePosition=0;
public bool goRight;
Vector3 basePosition, remotePosition;
void Start(){
basePosition = transform.position;
@nicloay
nicloay / MobilePlatformController.cs
Created March 20, 2014 12:38
mobile platfrom which move along the vector path
using UnityEngine;
using System.Collections;
public class MobilePlatformController: MonoBehaviour {
public Vector2 route;
public float timePerCycle = 2.0f;
[Range (0,2)]
public float startRelativePosition=0;
@nicloay
nicloay / floodfill_part.cs
Last active August 29, 2015 13:58
this code is evil, but works fas
static PointsRegion __newPointsRegion;
static int __yy,__xx;
static bool __prevPixelSeed;
private static void scanUpBelowPixelsRegionForward (ref int xLeft, ref int xRight, ref int baseY, ref int maxY, ref PointsRegion pointsRegion,
ref Color32[,] colors, ref bool[,] persistentBorder, ref Color32 seedColor, ref Queue queue, bool[,] resultRegion) {
__newPointsRegion = new PointsRegion ();
__yy = baseY + pointsRegion.direction;
@nicloay
nicloay / IosBuildList.cs
Last active August 29, 2015 14:00
unity3d build manager works on free version. it's just a mockup, after i'll add preprocess build there to manager resource folders
using UnityEngine;
using System.Collections.Generic;
public class IosBuildList : ScriptableObject{
public List<IosBuildConfig> configs;
}