Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@unitycoder
unitycoder / GetCurrentUIObject.cs
Created March 12, 2016 08:46
Get Selected UI GameObject with EventSystem
using UnityEngine;
using UnityEngine.EventSystems;
public class GetCurrentUIObject : MonoBehaviour
{
void Update()
{
// prints Null if nothing is selected, or name of the gameobject
Debug.Log(EventSystem.current.currentSelectedGameObject);
}
@unitycoder
unitycoder / TerrainInstance.cs
Created March 16, 2016 14:18
Modify TerrainData in editor runtime, without saving to terrain file
Q) test runtime adjustments to Terrain Data in the Unity Editor without writing to actual terrain file?
A) Instantiate() the TerrainData object to get an in-memory copy, then modify that?
theTerrainData = Terrain.activeTerrain.terrainData;
theTerrainData = TerrainData.Instantiate(theTerrainData);
Terrain.activeTerrain.terrainData = theTerrainData;
Terrain.activeTerrain.Flush();
@unitycoder
unitycoder / VolumetricImageEffect.cs
Created March 23, 2016 15:36
VolumetricImageEffect - Image Effect Script
using UnityEngine;
[ExecuteInEditMode]
public class VolumetricImageEffect : MonoBehaviour
{
public float exposure=0.6f;
public float decay = 0.95f;
public float density = 0.96f;
public float weight = 0.4f;
public float clamp = 1f;
@unitycoder
unitycoder / logcat.sh
Last active November 26, 2018 18:35
How to use adb logcat? (with filter)
adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG -v color
// http://answers.unity3d.com/questions/492681/how-to-use-adb-logcat.html#answer-571021
-s parameter
-s Equivalent to filterspec '*:S' and is used to precede a list of filterspecs that add content.
@unitycoder
unitycoder / SpriteBackgroundRemove.cs
Last active November 20, 2024 06:16
Sprite Background Remover (convert single color mask to transparent)
// original script : http://answers.unity3d.com/answers/252528/view.html
// modified by unitycoder.com
// Usage: Place this script in Editor/ folder
// Start the tool from menu, Window/Tools/Alpha-fy Images
using UnityEngine;
using UnityEditor;
using System.IO;
@unitycoder
unitycoder / CustomPoint.cs
Created March 27, 2016 07:18
Custom Point Helper Gizmo : Use as Spawn point, without adding empty gameobjects
using UnityEngine;
public class CustomPoint : MonoBehaviour
{
public Vector3 offset = Vector2.zero;
public float radius = 0.05f;
void OnDrawGizmosSelected()
{
Gizmos.color = Color.red;
@unitycoder
unitycoder / PythonErrors.py
Last active August 22, 2021 07:41
Python 2.x Notes
triple quotes for easy multiline string!
string1 = ("\n"
"asdfasdf\n"
"asdfasdf\n"
)
string1 = """
asdfasdf
asdfasdf
"""
@unitycoder
unitycoder / csharp.cs
Last active January 23, 2024 15:35
C# Notes
-----------------
-----------------
-----------------
-----------------
-----------------
-----------------
-----------------
-----------------
-----------------
-----------------
Installation failed with the following output:
pkg: /data/local/tmp/Package.apk
Failure [INSTALL_FAILED_OLDER_SDK]
5235 KB/s (22586102 bytes in 4.212s)
UnityEditor.HostView:OnGUI()
// file:AndroidManifest.xml, find line, adjust minSdkVersion, its probably higher than your device
@unitycoder
unitycoder / CloseThreads.py
Last active April 25, 2016 08:59
PythonNotes
# http://stackoverflow.com/a/18416308
from threading import Thread
import time
class MyClass(Thread):
def __init__(self, name):
super(MyClass, self).__init__()
#self.daemon = True
self.cancelled = False