Skip to content

Instantly share code, notes, and snippets.

View romainPechot's full-sized avatar

Romain Péchot romainPechot

View GitHub Profile
@romainPechot
romainPechot / SetActiveGameObject.cs
Created April 21, 2015 12:53
An Unity editor tool shortcut to quickly de-activate the gameObject(s) selected.
using UnityEngine;
using UnityEditor;
using System.Collections;
public class SetActiveGameObject : Editor
{
[MenuItem("Tools/On-Off GameObject %g")]
private static void EnableDisableGameObject()
{
// fetch
@romainPechot
romainPechot / SearchTagLayer.cs
Created April 21, 2015 13:20
An Unity editor window helper to show gameObjects in scene or project per tag or layer.
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class SearchTagLayer : EditorWindow
{
//Scene/Project
private string[] _as_sceneProject = new string[2]{"Scene", "Project"};
private int _i_sceneProjectIndex = 0;
@romainPechot
romainPechot / EventListener.cs
Last active August 29, 2015 14:19
Generic Event Listener. Example : http://imgur.com/a4yVrQ1
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public static class EventListener
{
private const int listListenerSizeMin = 10;
public static bool debugCalls = false;
@romainPechot
romainPechot / Ratio.cs
Created May 6, 2015 10:10
Unity CSharp encapsulation float as Ratio (auto clamped, IS_COMPLETE ?, Reset(), etc).
using UnityEngine;
[System.Serializable]
public class Ratio
{
private float val = 0f;
public virtual float VALUE{get{return val;}}
public virtual bool IS_RESET{get{return val == 0f;}}
@romainPechot
romainPechot / MouseClickPosition.cs
Created May 6, 2015 13:10
Move Gameobject with mouse click relative to camera.
using UnityEngine;
using System.Collections;
public class MouseClickPosition : MonoBehaviour
{
public Camera cam;
public Transform target;
public bool useRaycast = false;
@romainPechot
romainPechot / SC_PlayerCameraCutScene.cs
Created May 26, 2015 14:28
Look At Monobehaviour for camera in cinematic or cut scene
using UnityEngine;
using System.Collections;
public class SC_PlayerCameraCutScene : MonoBehaviour
{
#region Static
// CONST
private const float lerpLookAtSpeedOn = 1f;
private const float lerpLookAtSpeedOff = 1f;
@romainPechot
romainPechot / CameraHelper.cs
Created July 2, 2015 14:14
Set an object width scale relative to a screen pixel value.
using UnityEngine;
public static class CameraHelper
{
public static float GetPixelWidthToWorldScale(Camera camera, Vector3 worldTargetPosition, float pixelWidth)
{
return GetPixelWidthToWorldScale(camera, worldTargetPosition, pixelWidth, 1f);
}// GetPixelWidthToWorldScale()
using UnityEngine;
using System.Collections;
[System.Serializable]
public class TwirlLineRenderer
{
[SerializeField] private LineRenderer lineRenderer;
[SerializeField] private float radius = 1f;
@romainPechot
romainPechot / CheckEmptyMeshes.cs
Created July 4, 2015 10:35
Unity editor window help finder for empty Meshfilter & MeshCollider
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class CheckEmptyMesh : EditorWindow
{
[MenuItem("Window/Check Empty Mesh")]
private static void Init()
@romainPechot
romainPechot / intExtensions.cs
Created July 22, 2015 13:45
int extensions. Mostly usefull for index array manipulation.
using UnityEngine;
using System.Collections;
public static class intExtensions
{
public static bool CheckIndex(this int index, ICollection col)
{
return ((index >= 0) && (index < col.Count));
}// CheckIndex()