Skip to content

Instantly share code, notes, and snippets.

View romainPechot's full-sized avatar

Romain Péchot romainPechot

View GitHub Profile
@romainPechot
romainPechot / ReadOnlyInspectorDrawer.cs
Last active October 21, 2015 12:09
ReadOnlyDrawer for the [ReadOnlyInspector] PropertyAttribute
using UnityEngine;
using UnityEditor;
// put this script inside an Editor folder.
[CustomPropertyDrawer(typeof(ReadOnlyInspector))]
public class ReadOnlyInspectorDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
@romainPechot
romainPechot / ReadOnlyInspector.cs
Last active October 21, 2015 12:09
[ReadOnly] attribute. Combined with [SerializeField] on a private variable.
using UnityEngine;
// put this script inside your Scripts folder.
public class ReadOnlyInspector : PropertyAttribute { }
@romainPechot
romainPechot / ClearPlayerPrefs.cs
Created October 10, 2015 10:52
Quick Unity Editor Tool for cleaning ALL the PlayerPrefs
using UnityEngine;
using UnityEditor;
public class ClearPlayerPrefs
{
[MenuItem("Tools/Clear PlayerPrefs")]
private static void ClearAllPlayerPrefs()
{
if(EditorUtility.DisplayDialog("Clear ALL PlayerPrefs", "Do you really want to clear ALL the PlayerPrefs\nof this project ?\n\nYou cannot undo this action.", "Yep", "Nah"))
{
@romainPechot
romainPechot / ComponentsViewer.cs
Created October 9, 2015 13:05
Unity EditorWindow to show how many components there is inside a gameObject hierarchy (put the script inside an "Editor" folder)
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class ComponentsViewer : EditorWindow
{
[MenuItem("Window/Help/GameObject/Components Viewer")]
private static void Init()
@romainPechot
romainPechot / DualMap.shader
Last active February 7, 2020 07:55
Dual Maps Shader. Use last texture like a filter. Show first texture if pixel transparent, second if pixel is full visible (crossfade if value is inbetween)
Shader "DualMaps"
{
Properties
{
_MainTex("Main (RGB)", 2D) = "black" {}
_SecTex("Main (RGB)", 2D) = "white" {}
_FilTex("Filter (Alpha)", 2D) = "black"{}
}
SubShader
@romainPechot
romainPechot / PaddleBounceDirectionController.cs
Last active October 1, 2015 12:05
simple paddle bounce controller for arkanoid like game
using UnityEngine;
using System.Collections;
public class PaddleBounceDirectionController : MonoBehaviour
{
[SerializeField]
private Transform bounceSurface;
[SerializeField]
private float bounceSurfaceLength = 2f;
@romainPechot
romainPechot / CircleLineRenderer.cs
Created August 19, 2015 14:37
Circle Line Renderer
[System.Serializable]
public class CirclelLineRenderer
{
[SerializeField]
private LineRenderer lineRenderer;
public LineRenderer LINE_RENDERER
{
get { return lineRenderer; }
set
@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()
@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()
using UnityEngine;
using System.Collections;
[System.Serializable]
public class TwirlLineRenderer
{
[SerializeField] private LineRenderer lineRenderer;
[SerializeField] private float radius = 1f;