Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@unitycoder
unitycoder / gist:5cb0449878b65cf26c52
Last active May 12, 2017 09:13
Unity5 video importer commandline ogg ogv QuickTimeMovie
..Unity5\Editor\Data\Tools\QuicktimeTools.exe transcode -input yourvideo.mp4 -output "yourvideo.ogg" -vbr "4100000.000000" -abr "156000.000000"
// can use also
http://video.online-convert.com/convert-to-ogg
@unitycoder
unitycoder / GetSliderValue
Last active August 29, 2015 14:18
Get UI Slider Value
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class GetSliderValue : MonoBehaviour {
public YourScript yourScript;
void Awake ()
{
@unitycoder
unitycoder / Physics2DRaycast.cs
Last active August 29, 2015 14:18
Physics2D.Raycast
using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour {
public LayerMask targetLayer;
Vector3 prevPos;
void Start () {
@unitycoder
unitycoder / ClearPrefs
Created April 20, 2015 20:39
Reset Build Resolution Settings in Editor
using UnityEngine;
using System.Collections;
using UnityEditor;
public class ClearPrefs : MonoBehaviour {
// otherwise adjusting player settings resolution wont do anything..
// http://answers.unity3d.com/questions/516517/why-doesnt-standalone-build-resolution-settings-af.html
[MenuItem("Edit/Reset Playerprefs")]
@unitycoder
unitycoder / PlanarUVMap.cs
Last active August 29, 2015 14:19
Set UV map to Planar
using UnityEngine;
using System.Collections;
// modified from : http://docs.unity3d.com/ScriptReference/Mesh-uv.html
public class PlanarUVMap : MonoBehaviour {
public bool flipX=false;
void Start()
@unitycoder
unitycoder / gist:d60928218a687783aab3
Created April 30, 2015 22:08
Disable script warnings for unused variables in c#
// http://answers.unity3d.com/questions/21796/disable-warning-messages.html
#pragma warning disable 0168 // variable declared but not used.
#pragma warning disable 0219 // variable assigned but not used.
#pragma warning disable 0414 // private field assigned but not used.
@unitycoder
unitycoder / Remap.cs
Last active January 26, 2023 22:28
Remap value from range to another range
float Remap(float source, float sourceFrom, float sourceTo, float targetFrom, float targetTo)
{
return targetFrom + (source-sourceFrom)*(targetTo-targetFrom)/(sourceTo-sourceFrom);
}
// https://forum.unity.com/threads/re-map-a-number-from-one-range-to-another.119437/
@unitycoder
unitycoder / FixMouseClicksForUI.cs
Last active May 11, 2020 20:18
Ignore UI element from clicking
// ignore mouse clicks for UI
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class FixMouseClicksForUI : MonoBehaviour
{
GameObject lastselect;
@unitycoder
unitycoder / AssetStoreBuddy.js
Last active August 29, 2015 14:20
UnityAssetStoreBuddy
// ==UserScript==
// @name AssetStoreBuddy
// @namespace unitycoder.com
// @include https://www.assetstore.unity3d.com/en/#!/search/*
// @version 1
// @grant none
// ==/UserScript==
// currently need to press F5 to run these
@unitycoder
unitycoder / TrackMouseOverUI.cs
Created May 17, 2015 17:23
Get mouseposition over UI element
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using UnityEngine.UI;
// http://forum.unity3d.com/threads/eventtrigger-move-issue.325103/#post-2114563
public class TrackMouseOverUI: MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
// Called when the pointer enters our GUI component.