Skip to content

Instantly share code, notes, and snippets.

View nicloay's full-sized avatar
✌️

Nikolay nicloay

✌️
View GitHub Profile
@nicloay
nicloay / spotify2VK.js
Created June 25, 2014 18:27
gracemonkey script transfer music from spotify in to vkontakte (right now, not sure that copy past works well, so I past spotify uri directly to the file)
// ==UserScript==
// @name SpotifyVK
// @namespace com.nicloy.vkspotify
// @description Import music from spotify to vk albums
// @grant GM_xmlhttpRequest
// @include http://vk.com/audio*
// @include https://vk.com/audio*
// @version 1
// ==/UserScript==
@nicloay
nicloay / DragonImporter.cs
Last active May 30, 2016 20:06
DragonBones importer https://drive.google.com/file/d/0B-19PBUPw77UYVN6NVhpclhJUHM/edit?usp=sharing here is a package in case if I missed something.
using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;
using System.Xml;
using System.Collections.Generic;
using System.Xml.Serialization;
using animaster;
using System.Linq;
@nicloay
nicloay / MonoSingleton.cs
Last active August 23, 2022 07:51
Unity3d post vk screenshot
using UnityEngine;
/*
*
* This script created by UNITY COMUNITY and available here http://wiki.unity3d.com/index.php?title=Singleton
*
*
*/
public abstract class MonoSingleton<T> : MonoBehaviour where T : MonoSingleton<T>
{
@nicloay
nicloay / gist:4d0d45a09229b36745bc
Created December 2, 2014 21:19
Rotate elements in 2d array around pivot point (in my case i hardcoded pivot at {2:2} position}
static int cos90 = 0;
static int sin90 = 1;
void RotateAroundCenter(ref int x, ref int y){
int xNew, yNew;
x -= 2; //piwot point x = 2
y -= 2; //piwot point y = 2;
xNew = x * cos90 - y * sin90;
yNew = x * sin90 + y * cos90;
x = xNew + 2;
y = yNew + 2;
@nicloay
nicloay / AtlasTexturePreprocessor.cs
Last active April 27, 2019 05:10
Unity3d Automatically fix texture size on import (very useful if you have big textures which has bigger size than default 1024 or 2048 value)
// reflexion method posted by numberkruncher
// here http://forum.unity3d.com/threads/getting-original-size-of-texture-asset-in-pixels.165295/
public class AtlasTexturePostprocessor : AssetPostprocessor {
public const int PixelsPerUnit = 100;
void OnPreprocessTexture(){
Texture2D tex = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Texture2D )) as Texture2D;
TextureImporter importer = assetImporter as TextureImporter;
int textureHeight;
@nicloay
nicloay / GravityTest.cs
Last active August 29, 2015 14:15
Gravity test calculation
using UnityEngine;
using System.Collections;
using UnityTest;
/// <summary>
/// Gravity test.
///
/// see formulas here http://error454.com/2013/10/23/platformer-physics-101-and-the-3-fundamental-equations-of-platformers/
///
/// d = v*t + 0.5f * a * t * t //d -distance, v - initial velocity, a - aceleration, t - time
///
@nicloay
nicloay / KineticTest.cs
Last active August 29, 2015 14:15
Kinetic test at unity3d - apply initial forces and stop rigidbody2d at random time
using UnityEngine;
using System.Collections;
using UnityTest;
/// <summary>
///
/// Kinetic test.
///
/// some usefull info here http://www.moaisnippets.info/using-box2d-impulses-to-move-objects
/// impulse = mass * velocity;
using UnityEngine;
using UnityEngine.UI;
public class DisableToggleBG : MonoBehaviour {
Image cr;
void Awake () {
cr = GetComponent<Image>();
GetComponentInParent<Toggle>().onValueChanged.AddListener((state) => {OnParentToggleChange(state);});
}
@nicloay
nicloay / GameManager.cs
Last active September 11, 2015 12:35
Unity3d pause monobehaviour without timescale
using UnityEngine;
using System.Collections.Generic;
public class GameManager : MonoBehaviour {
readonly List<LifeTimeComponent> registeredComponents = new List<LifeTimeComponent>();
public void RegisterLifeComponent(LifeTimeComponent component){
if (!registeredComponents.Contains(component))
registeredComponents.Add(component);
}
@nicloay
nicloay / test.cs
Last active October 29, 2015 11:24
performance
using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour {
int arraySize = 1024*2048;
string status = "unknown";
float avgFPSIn = 0.0f;
float avgFpsOut = 0.0f;
float fps = 0.0f;