Skip to content

Instantly share code, notes, and snippets.

View attilam's full-sized avatar

Attila Malarik attilam

View GitHub Profile
@attilam
attilam / FittedBoxCollider.cs
Created October 24, 2013 08:05
Small Unity3D editor script that will create a BoxCollider that encapsulates all Renderers in the selected Transform's hierarchy.
using UnityEngine;
using UnityEditor;
using System.Collections;
public class FittedBoxCollider {
[MenuItem("GameObject/Create Other/Create Fitted BoxCollider")]
static void FittedBoxColliderMenu() {
Transform transform = Selection.activeTransform;
Quaternion rotation = transform.rotation;
transform.rotation = Quaternion.identity;
@attilam
attilam / DynamicEvent.cs
Created September 15, 2013 09:08
Stupid little class to fit all sorts of functionality into one place as possible, to be used in an interactive environment (I'm not proud of it, but pressed on time it's proven very helpful)
using UnityEngine;
using Holoville.HOTween;
[System.Serializable]
public class DynamicEvent {
[System.Serializable]
public class AnimationSetup {
public GameObject gameObject;
public string animation;
}
@attilam
attilam / CreateEmptyAtSelection.cs
Last active March 31, 2020 16:32
Tiny Unity3D editor script to create a new GameObject at selection. Invoke with Alt+N.
using UnityEngine;
using UnityEditor;
public class CreateEmptyAtSelection : ScriptableObject {
[MenuItem("GameObject/Create Empty at Selection &n")]
static void CreateEmpty() {
GameObject go = new GameObject();
if (Selection.activeTransform != null) {
@attilam
attilam / PostprocessBuildPlayer
Created February 19, 2013 08:39
Unity3D iOS: Auto add 'Application supports iTunes file sharing' to Info.plist
#!/bin/bash
plist=$1"/Info.plist"
/usr/libexec/PlistBuddy -c "Add :UIFileSharingEnabled bool true" $plist
@attilam
attilam / MeasuringTape.cs
Last active June 21, 2017 08:31
Quick Measuring Tape Unity Editor Script
using UnityEngine;
using System.Collections;
public class MeasuringTape : MonoBehaviour {
public Vector3 target = Vector3.zero;
}
@attilam
attilam / RevealPersistentDataDirectory.cs
Created December 6, 2012 17:20
Reveal Persistent Data Directory for current project in Unity
using UnityEngine;
using UnityEditor;
using System.Diagnostics;
public class RevealPersistentDataDirectory : MonoBehaviour {
[MenuItem("Assets/Reveal Persistent Data Directory")]
static void DoMenu() {
Process process = new Process();
process.StartInfo.FileName = ( (Application.platform == RuntimePlatform.WindowsEditor) ? "explorer.exe" : "open" );
process.StartInfo.Arguments = "file://"+Application.persistentDataPath;
@attilam
attilam / RaycastWithTag.cs
Created November 14, 2012 14:31
Raycast for the closest object with a specific tag in Unity
public static bool RaycastWithTag(Ray ray, out RaycastHit hit, float distance, string tag, int layerMask = System.Int32.MaxValue) {
RaycastHit[] hits = Physics.RaycastAll(ray, distance, layerMask);
hit = new RaycastHit();
hit.distance = distance;
foreach(RaycastHit ahit in hits) {
if ( ahit.distance < hit.distance && ahit.transform.CompareTag(tag) ) {
hit = ahit;
}
}
@attilam
attilam / GameEvent.cs
Last active April 20, 2021 15:36
Generic message-based GameEvent Class for Unity
using UnityEngine;
using System.Collections;
public delegate void GameEventDelegate(GameEvent evt = null);
[System.Serializable]
public class GameEvent {
public GameObject target;