Skip to content

Instantly share code, notes, and snippets.

@glebov21
glebov21 / MuteButton.cs
Created February 21, 2018 15:55
Mute (unity3d)
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
[RequireComponent(typeof(Button))]
public class MuteButton : MonoBehaviour {
float defaultVolume = 1f;
void Awake()
{
@glebov21
glebov21 / gist:f95950f1b8ca5e6846d0fa9e9408fcdb
Last active October 3, 2018 12:52
Extensions utils (unity3d)
using OpenTK;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.Profiling;
using System.Linq;
using UnityEngine.UI;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
public static class ChangeNotifier
{
private static Dictionary<Type, List<WeakReference>> listeners = new Dictionary<Type, List<WeakReference>>();
private static List<WeakReference> checkersToRemove = new List<WeakReference>();
using UnityEngine;
using System.Collections;
public class ChangeChecker
{
private bool isUpdated = false;
public bool IsUpdated
{
get
@glebov21
glebov21 / gist:5b0146d67f115fbd526842f295953729
Created February 21, 2018 15:58
WebGL set parameter (low memery) (unity3d)
using UnityEngine;
using System.Collections;
using UnityEditor;
public class WebGL : MonoBehaviour
{
[MenuItem("Tools/SetWebGLParameter")]
public static void SetWebGLParameter()
{
PlayerSettings.SetPropertyString("emscriptenArgs", "-s ALLOW_MEMORY_GROWTH=1 -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2", BuildTargetGroup.WebGL);
@glebov21
glebov21 / TryAgainIfException.cs
Created March 6, 2018 14:48
Try Again If Exception
private bool TryAgainIfException(Action action, int attemts = 10)
{
while (attemts > 0)
{
try
{
action();
return true;
}
catch (Exception e)
@glebov21
glebov21 / gist:a7c11f2efebef561dbe377a1f89ed4f5
Created March 15, 2018 09:25
Draw line on texture Unity3d
void DrawLine(Texture2D tex, int x1, int y1, int x2, int y2, Color col)
{
int dy = (int)(y1-y0);
int dx = (int)(x1-x0);
int stepx, stepy;
if (dy < 0) {dy = -dy; stepy = -1;}
else {stepy = 1;}
if (dx < 0) {dx = -dx; stepx = -1;}
else {stepx = 1;}
@glebov21
glebov21 / gist:4994e64ae20e878cd9a6da2a541e8b69
Created March 16, 2018 12:55
Копировать папку с файлами проекта в output
XCOPY "$(ProjectDir)osmosis-latest" "$(TargetDir)osmosis-latest" /h/i/c/k/e/r/y
using UnityEngine;
public class PinchZoom : MonoBehaviour
{
public float perspectiveZoomSpeed = 0.5f; // The rate of change of the field of view in perspective mode.
public float orthoZoomSpeed = 0.5f; // The rate of change of the orthographic size in orthographic mode.
void Update()
{
@glebov21
glebov21 / gist:947a70c79daf0570d63e0c55bd4f9f1c
Created March 20, 2018 10:53
Восстановить и переустановить nuget пакеты проекта
Update-Package –reinstall